mirror of
https://code.tvl.fyi/depot.git:/tools/nixery.git
synced 2025-03-15 14:11:51 +00:00
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
6d6658c651
commit
07c728cf31
|
@ -27,6 +27,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"cloud.google.com/go/storage"
|
"cloud.google.com/go/storage"
|
||||||
|
@ -50,12 +51,21 @@ type Image struct {
|
||||||
//
|
//
|
||||||
// It will expand convenience names under the hood (see the `convenienceNames`
|
// It will expand convenience names under the hood (see the `convenienceNames`
|
||||||
// function below).
|
// 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 {
|
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{
|
return Image{
|
||||||
Name: name,
|
Name: strings.Join(pkgs, "/"),
|
||||||
Tag: tag,
|
Tag: tag,
|
||||||
Packages: convenienceNames(packages),
|
Packages: expanded,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user