diff --git a/pkg/packages.go b/pkg/packages.go index 35ff19f..15e1358 100644 --- a/pkg/packages.go +++ b/pkg/packages.go @@ -18,6 +18,7 @@ import ( "context" "crypto/sha256" "encoding/base64" + "fmt" "io" "os" "path/filepath" @@ -42,6 +43,7 @@ func Ensure(want spec.JsonnetFile, vendorDir string, locks map[string]spec.Depen list = append(list, l) continue } + expectedSum := d.Sum // either not present or not intact: download again dir := filepath.Join(vendorDir, d.Name) @@ -51,6 +53,9 @@ func Ensure(want spec.JsonnetFile, vendorDir string, locks map[string]spec.Depen if err != nil { return nil, errors.Wrap(err, "downloading") } + if expectedSum != "" && d.Sum != expectedSum { + return fmt.Errorf("checksum mismatch for %s. Expected %s but got %s", d.Name, expectedSum, d.Sum) + } list = append(list, *locked) }