1
0
mirror of https://github.com/ko-build/ko.git synced 2025-11-06 09:19:12 +02:00

Don't set image.base.name if base is specified by digest (#408)

* Don't set image.base.name if base is specified by digest

* don't set empty annotation

* annotate Results, not Images and Indexes separately

* moar cleanup

* skip annotations check for images in indexes, these won't be annotated anymore
This commit is contained in:
Jason Hall
2021-08-11 16:52:01 -04:00
committed by GitHub
parent 466dbab6c4
commit 86a7b6f4b8
2 changed files with 29 additions and 22 deletions

View File

@@ -343,7 +343,7 @@ func TestGoBuildNoKoData(t *testing.T) {
})
}
func validateImage(t *testing.T, img v1.Image, baseLayers int64, creationTime v1.Time) {
func validateImage(t *testing.T, img v1.Image, baseLayers int64, creationTime v1.Time, checkAnnotations bool) {
t.Helper()
ls, err := img.Layers()
@@ -483,6 +483,9 @@ func validateImage(t *testing.T, img v1.Image, baseLayers int64, creationTime v1
})
t.Run("check annotations", func(t *testing.T) {
if !checkAnnotations {
t.Skip("skipping annotations check")
}
mf, err := img.Manifest()
if err != nil {
t.Fatalf("Manifest() = %v", err)
@@ -540,7 +543,7 @@ func TestGoBuild(t *testing.T) {
t.Fatalf("Build() not an image: %v", result)
}
validateImage(t, img, baseLayers, creationTime)
validateImage(t, img, baseLayers, creationTime, true)
// Check that rebuilding the image again results in the same image digest.
t.Run("check determinism", func(t *testing.T) {
@@ -622,7 +625,7 @@ func TestGoBuildIndex(t *testing.T) {
if err != nil {
t.Fatalf("idx.Image(%s) = %v", desc.Digest, err)
}
validateImage(t, img, baseLayers, creationTime)
validateImage(t, img, baseLayers, creationTime, false)
}
if want, got := images, int64(len(im.Manifests)); want != got {