fix(server): Sort requested packages in image name & spec
Before this change, Nixery would pass on the image name unmodified to Nix which would lead it to cache-bust the manifest and configuration layers for images that are content-identical but have different package ordering. This fixes #38.
This commit is contained in:
parent
0ee239874b
commit
9a95c4124f
1 changed files with 13 additions and 3 deletions
|
@ -27,6 +27,7 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"cloud.google.com/go/storage"
|
||||
|
@ -50,12 +51,21 @@ type Image struct {
|
|||
//
|
||||
// It will expand convenience names under the hood (see the `convenienceNames`
|
||||
// function below).
|
||||
//
|
||||
// Once assembled the image structure uses a sorted representation of
|
||||
// the name. This is to avoid unnecessarily cache-busting images if
|
||||
// only the order of requested packages has changed.
|
||||
func ImageFromName(name string, tag string) Image {
|
||||
packages := strings.Split(name, "/")
|
||||
pkgs := strings.Split(name, "/")
|
||||
expanded := convenienceNames(pkgs)
|
||||
|
||||
sort.Strings(pkgs)
|
||||
sort.Strings(expanded)
|
||||
|
||||
return Image{
|
||||
Name: name,
|
||||
Name: strings.Join(pkgs, "/"),
|
||||
Tag: tag,
|
||||
Packages: convenienceNames(packages),
|
||||
Packages: expanded,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue