Skip to content

Commit

Permalink
fix(server): Sort requested packages in image name & spec
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tazjin authored and Vincent Ambo committed Aug 17, 2019
1 parent 6d6658c commit 07c728c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions server/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"log"
"os"
"os/exec"
"sort"
"strings"

"cloud.google.com/go/storage"
Expand All @@ -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,
}
}

Expand Down

0 comments on commit 07c728c

Please sign in to comment.