From 2e926c83bfa38365f99944036a1f246453d42563 Mon Sep 17 00:00:00 2001 From: kumari tanushree Date: Thu, 28 Dec 2023 14:07:00 +0530 Subject: [PATCH 1/4] Updated describe command to show layers digest as well Signed-off-by: kumari tanushree --- pkg/imgpkg/cmd/describe.go | 8 ++++++ pkg/imgpkg/v1/describe.go | 55 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/pkg/imgpkg/cmd/describe.go b/pkg/imgpkg/cmd/describe.go index b7da3a83e..8616ea0d0 100644 --- a/pkg/imgpkg/cmd/describe.go +++ b/pkg/imgpkg/cmd/describe.go @@ -138,6 +138,10 @@ func (p bundleTextPrinter) printerRec(description v1.Description, originalLogger indentLogger.Logf("- Image: %s\n", b.Image) indentLogger.Logf(" Type: Bundle\n") indentLogger.Logf(" Origin: %s\n", b.Origin) + indentLogger.Logf(" Layers:\n") + for _, d := range b.Layers { + indentLogger.Logf(" - Digest: %s\n", d) + } annotations := b.Annotations p.printAnnotations(annotations, util.NewIndentedLogger(indentLogger)) @@ -160,6 +164,10 @@ func (p bundleTextPrinter) printerRec(description v1.Description, originalLogger if image.ImageType == bundle.ContentImage { indentLogger.Logf(" Origin: %s\n", image.Origin) } + indentLogger.Logf(" Layers:\n") + for _, d := range image.Layers { + indentLogger.Logf(" - Digest: %s\n", d) + } annotations := image.Annotations p.printAnnotations(annotations, util.NewIndentedLogger(indentLogger)) } diff --git a/pkg/imgpkg/v1/describe.go b/pkg/imgpkg/v1/describe.go index 7cc15d365..2a2d7a084 100644 --- a/pkg/imgpkg/v1/describe.go +++ b/pkg/imgpkg/v1/describe.go @@ -12,7 +12,10 @@ import ( "carvel.dev/imgpkg/pkg/imgpkg/lockconfig" "carvel.dev/imgpkg/pkg/imgpkg/registry" "carvel.dev/imgpkg/pkg/imgpkg/signature" + "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" + regname "github.com/google/go-containerregistry/pkg/name" + "github.com/google/go-containerregistry/pkg/v1/remote" ) // Author information from a Bundle @@ -40,6 +43,7 @@ type ImageInfo struct { Annotations map[string]string `json:"annotations,omitempty"` ImageType bundle.ImageType `json:"imageType"` Error string `json:"error,omitempty"` + Layers []string `json:"layers,omitempty"` } // Content Contents present in a Bundle @@ -55,6 +59,7 @@ type Description struct { Annotations map[string]string `json:"annotations,omitempty"` Metadata Metadata `json:"metadata,omitempty"` Content Content `json:"content"` + Layers []string `json:"layers,omitempty"` } // DescribeOpts Options used when calling the Describe function @@ -125,6 +130,29 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes return desc.bundle } + layers := []string{} + parsedImgRef, err := regname.ParseReference(currentBundle.Image, regname.WeakValidation) + if err != nil { + panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", currentBundle.Image, err.Error())) + } + + v1Img, err := remote.Image(parsedImgRef, remote.WithAuthFromKeychain(authn.DefaultKeychain)) + if err != nil { + panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", currentBundle.Image, err.Error())) + } + + imgLayers, err := v1Img.Layers() + if err != nil { + panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", currentBundle.Image, err.Error())) + } + + for _, imgLayer := range imgLayers { + digHash, err := imgLayer.Digest() + if err != nil { + panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", currentBundle.Image, err.Error())) + } + layers = append(layers, digHash.String()) + } desc = refWithDescription{ imgRef: currentBundle, bundle: Description{ @@ -136,6 +164,7 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes Bundles: map[string]Description{}, Images: map[string]ImageInfo{}, }, + Layers: layers, }, } var newBundle *bundle.Bundle @@ -150,6 +179,7 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes } imagesRefs := newBundle.ImagesRefsWithErrors() + sort.Slice(imagesRefs, func(i, j int) bool { return imagesRefs[i].Image < imagesRefs[j].Image }) @@ -172,11 +202,36 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes if err != nil { panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved", ref.Image)) } + layers = []string{} + parsedImgRef, err = regname.ParseReference(ref.Image, regname.WeakValidation) + if err != nil { + panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", ref.Image, err.Error())) + } + + v1Img, err = remote.Image(parsedImgRef, remote.WithAuthFromKeychain(authn.DefaultKeychain)) + if err != nil { + panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", ref.Image, err.Error())) + } + + imgLayers, err = v1Img.Layers() + if err != nil { + panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", ref.Image, err.Error())) + } + + for _, imgLayer := range imgLayers { + digHash, err := imgLayer.Digest() + if err != nil { + panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", ref.Image, err.Error())) + } + layers = append(layers, digHash.String()) + } + desc.bundle.Content.Images[digest.DigestStr()] = ImageInfo{ Image: ref.PrimaryLocation(), Origin: ref.Image, Annotations: ref.Annotations, ImageType: ref.ImageType, + Layers: layers, } } else { desc.bundle.Content.Images[ref.Image] = ImageInfo{ From 8eee075a6e1b380429b7c53c4bcf1f173f7639e6 Mon Sep 17 00:00:00 2001 From: kumari tanushree Date: Fri, 29 Dec 2023 00:17:34 +0530 Subject: [PATCH 2/4] Updated e2e test for describe command Signed-off-by: kumari tanushree --- test/e2e/describe_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/e2e/describe_test.go b/test/e2e/describe_test.go index d838f9db2..4e0ca5b9a 100644 --- a/test/e2e/describe_test.go +++ b/test/e2e/describe_test.go @@ -67,11 +67,13 @@ images: "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, bundleDigest), }, ) - + fmt.Printf("\n\nOutput: %s\n\n", stdout) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Image Origin: %s%s + Layers: + - Digest: "sha256:a37f35f3e418ea6c1b339df0fc89c8d3155d937740445906ba71466996fac625" Annotations: some.annotation: some value some.other.annotation: some other value @@ -80,19 +82,27 @@ images: assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Signature + Layers: + - Digest: "sha256:4197c5ac7fb0ba1e597a2377a1b58332d10f6de53dce9c89fd96a3f37034f88b" Annotations: tag: %s `, env.RelocationRepo, imgSigDigest, imgSigTag)) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Signature + Layers: + - Digest: "sha256:28014a7e4bef0b7c3f1da47d095f8bb131f474bd5fc96caa4d6125818220b00e" Annotations: tag: %s `, env.RelocationRepo, bundleSigDigest, bundleSigTag)) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s - Type: Internal`, env.RelocationRepo, locationsImgDigest)) + Type: Internal + Layers: + - + Digest: "sha256:5d43e9fc8f1ad1b339b5f37bb050b150640ad2c1594345178f1fb38656583a94" +`, env.RelocationRepo, locationsImgDigest)) }) }) From 50da503b9d45af0d771fcea0681bc6e90bad12d7 Mon Sep 17 00:00:00 2001 From: kumari tanushree Date: Fri, 29 Dec 2023 13:30:51 +0530 Subject: [PATCH 3/4] added func to calculate image layers sha in e2e test Signed-off-by: kumari tanushree --- pkg/imgpkg/cmd/describe.go | 4 +- pkg/imgpkg/v1/describe.go | 107 +++++++++--------- test/e2e/describe_test.go | 206 ++++++++++++++++++++++++++-------- test/helpers/image_factory.go | 19 ++++ 4 files changed, 234 insertions(+), 102 deletions(-) diff --git a/pkg/imgpkg/cmd/describe.go b/pkg/imgpkg/cmd/describe.go index 8616ea0d0..a7298e7e6 100644 --- a/pkg/imgpkg/cmd/describe.go +++ b/pkg/imgpkg/cmd/describe.go @@ -140,7 +140,7 @@ func (p bundleTextPrinter) printerRec(description v1.Description, originalLogger indentLogger.Logf(" Origin: %s\n", b.Origin) indentLogger.Logf(" Layers:\n") for _, d := range b.Layers { - indentLogger.Logf(" - Digest: %s\n", d) + indentLogger.Logf(" - Digest: %s\n", d.Digest) } annotations := b.Annotations @@ -166,7 +166,7 @@ func (p bundleTextPrinter) printerRec(description v1.Description, originalLogger } indentLogger.Logf(" Layers:\n") for _, d := range image.Layers { - indentLogger.Logf(" - Digest: %s\n", d) + indentLogger.Logf(" - Digest: %s\n", d.Digest) } annotations := image.Annotations p.printAnnotations(annotations, util.NewIndentedLogger(indentLogger)) diff --git a/pkg/imgpkg/v1/describe.go b/pkg/imgpkg/v1/describe.go index 2a2d7a084..ac0359caa 100644 --- a/pkg/imgpkg/v1/describe.go +++ b/pkg/imgpkg/v1/describe.go @@ -36,6 +36,11 @@ type Metadata struct { Websites []Website `json:"websites,omitempty"` } +// Layers image layers info +type Layers struct { + Digest string `json:"digest,omitempty"` +} + // ImageInfo URLs where the image can be found as well as annotations provided in the Images Lock type ImageInfo struct { Image string `json:"image,omitempty"` @@ -43,7 +48,7 @@ type ImageInfo struct { Annotations map[string]string `json:"annotations,omitempty"` ImageType bundle.ImageType `json:"imageType"` Error string `json:"error,omitempty"` - Layers []string `json:"layers,omitempty"` + Layers []Layers `json:"layers,omitempty"` } // Content Contents present in a Bundle @@ -59,7 +64,7 @@ type Description struct { Annotations map[string]string `json:"annotations,omitempty"` Metadata Metadata `json:"metadata,omitempty"` Content Content `json:"content"` - Layers []string `json:"layers,omitempty"` + Layers []Layers `json:"layers,omitempty"` } // DescribeOpts Options used when calling the Describe function @@ -111,7 +116,7 @@ func DescribeWithRegistryAndSignatureFetcher(bundleImage string, opts DescribeOp topBundle := refWithDescription{ imgRef: bundle.NewBundleImageRef(lockconfig.ImageRef{Image: newBundle.DigestRef()}), } - return topBundle.DescribeBundle(allBundles), nil + return topBundle.DescribeBundle(allBundles) } type refWithDescription struct { @@ -119,40 +124,22 @@ type refWithDescription struct { bundle Description } -func (r *refWithDescription) DescribeBundle(bundles []*bundle.Bundle) Description { +func (r *refWithDescription) DescribeBundle(bundles []*bundle.Bundle) (Description, error) { var visitedImgs map[string]refWithDescription return r.describeBundleRec(visitedImgs, r.imgRef, bundles) } -func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDescription, currentBundle bundle.ImageRef, bundles []*bundle.Bundle) Description { +func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDescription, currentBundle bundle.ImageRef, bundles []*bundle.Bundle) (Description, error) { desc, wasVisited := visitedImgs[currentBundle.Image] if wasVisited { - return desc.bundle - } - - layers := []string{} - parsedImgRef, err := regname.ParseReference(currentBundle.Image, regname.WeakValidation) - if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", currentBundle.Image, err.Error())) - } - - v1Img, err := remote.Image(parsedImgRef, remote.WithAuthFromKeychain(authn.DefaultKeychain)) - if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", currentBundle.Image, err.Error())) + return desc.bundle, nil } - imgLayers, err := v1Img.Layers() + layers, err := getImageLayersInfo(currentBundle.Image) if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", currentBundle.Image, err.Error())) + return desc.bundle, err } - for _, imgLayer := range imgLayers { - digHash, err := imgLayer.Digest() - if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", currentBundle.Image, err.Error())) - } - layers = append(layers, digHash.String()) - } desc = refWithDescription{ imgRef: currentBundle, bundle: Description{ @@ -175,57 +162,40 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes } } if newBundle == nil { - panic(fmt.Sprintf("Internal consistency: bundle with ref '%s' could not be found in list of bundles", currentBundle.PrimaryLocation())) + return desc.bundle, fmt.Errorf("Internal inconsistency: bundle with ref '%s' could not be found in list of bundles", currentBundle.PrimaryLocation()) } imagesRefs := newBundle.ImagesRefsWithErrors() - sort.Slice(imagesRefs, func(i, j int) bool { return imagesRefs[i].Image < imagesRefs[j].Image }) for _, ref := range imagesRefs { if ref.IsBundle == nil { - panic("Internal consistency: IsBundle after processing must always have a value") + return desc.bundle, fmt.Errorf("Internal inconsistency: IsBundle after processing must always have a value") } if *ref.IsBundle { - bundleDesc := r.describeBundleRec(visitedImgs, ref, bundles) + bundleDesc, err := r.describeBundleRec(visitedImgs, ref, bundles) + if err != nil { + return desc.bundle, err + } + digest, err := name.NewDigest(bundleDesc.Image) if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved", bundleDesc.Image)) + return desc.bundle, fmt.Errorf("Internal inconsistency: image %s should be fully resolved", bundleDesc.Image) } desc.bundle.Content.Bundles[digest.DigestStr()] = bundleDesc } else { if ref.Error == "" { digest, err := name.NewDigest(ref.Image) if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved", ref.Image)) - } - layers = []string{} - parsedImgRef, err = regname.ParseReference(ref.Image, regname.WeakValidation) - if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", ref.Image, err.Error())) - } - - v1Img, err = remote.Image(parsedImgRef, remote.WithAuthFromKeychain(authn.DefaultKeychain)) - if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", ref.Image, err.Error())) + return desc.bundle, fmt.Errorf("Internal inconsistency: image %s should be fully resolved", ref.Image) } - - imgLayers, err = v1Img.Layers() + layers, err = getImageLayersInfo(ref.Image) if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", ref.Image, err.Error())) - } - - for _, imgLayer := range imgLayers { - digHash, err := imgLayer.Digest() - if err != nil { - panic(fmt.Sprintf("Internal inconsistency: image %s should be fully resolved, error: %s", ref.Image, err.Error())) - } - layers = append(layers, digHash.String()) + return desc.bundle, err } - desc.bundle.Content.Images[digest.DigestStr()] = ImageInfo{ Image: ref.PrimaryLocation(), Origin: ref.Image, @@ -242,5 +212,32 @@ func (r *refWithDescription) describeBundleRec(visitedImgs map[string]refWithDes } } - return desc.bundle + return desc.bundle, nil +} + +func getImageLayersInfo(image string) ([]Layers, error) { + layers := []Layers{} + parsedImgRef, err := regname.ParseReference(image, regname.WeakValidation) + if err != nil { + return nil, fmt.Errorf("Error: %s in parsing image %s", err.Error(), image) + } + + v1Img, err := remote.Image(parsedImgRef, remote.WithAuthFromKeychain(authn.DefaultKeychain)) + if err != nil { + return nil, fmt.Errorf("Error: %s in getting remote access of image %s", err.Error(), image) + } + + imgLayers, err := v1Img.Layers() + if err != nil { + return nil, fmt.Errorf("Error: %s in getting layers of image %s", err.Error(), image) + } + + for _, imgLayer := range imgLayers { + digHash, err := imgLayer.Digest() + if err != nil { + return nil, fmt.Errorf("Error: %s in getting digest of layer's of image %s", err.Error(), image) + } + layers = append(layers, Layers{Digest: digHash.String()}) + } + return layers, nil } diff --git a/test/e2e/describe_test.go b/test/e2e/describe_test.go index 4e0ca5b9a..6005c7769 100644 --- a/test/e2e/describe_test.go +++ b/test/e2e/describe_test.go @@ -67,42 +67,46 @@ images: "--bundle", fmt.Sprintf("%s%s", env.RelocationRepo, bundleDigest), }, ) - fmt.Printf("\n\nOutput: %s\n\n", stdout) + + digestSha := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + imageDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Image Origin: %s%s - Layers: - - Digest: "sha256:a37f35f3e418ea6c1b339df0fc89c8d3155d937740445906ba71466996fac625" + Layers: + - Digest: %s Annotations: some.annotation: some value some.other.annotation: some other value -`, env.RelocationRepo, imageDigest, env.Image, imageDigest)) +`, env.RelocationRepo, imageDigest, env.Image, imageDigest, digestSha[0])) + digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + imgSigDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Signature - Layers: - - Digest: "sha256:4197c5ac7fb0ba1e597a2377a1b58332d10f6de53dce9c89fd96a3f37034f88b" + Layers: + - Digest: %s Annotations: tag: %s -`, env.RelocationRepo, imgSigDigest, imgSigTag)) +`, env.RelocationRepo, imgSigDigest, digestSha[0], imgSigTag)) + + digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + bundleSigDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Signature - Layers: - - Digest: "sha256:28014a7e4bef0b7c3f1da47d095f8bb131f474bd5fc96caa4d6125818220b00e" + Layers: + - Digest: %s Annotations: tag: %s -`, env.RelocationRepo, bundleSigDigest, bundleSigTag)) +`, env.RelocationRepo, bundleSigDigest, digestSha[0], bundleSigTag)) + digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsImgDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Internal - Layers: - - - Digest: "sha256:5d43e9fc8f1ad1b339b5f37bb050b150640ad2c1594345178f1fb38656583a94" -`, env.RelocationRepo, locationsImgDigest)) + Layers: + - Digest: %s +`, env.RelocationRepo, locationsImgDigest, digestSha[0])) }) }) @@ -175,39 +179,61 @@ images: locationsNestedBundleImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(nestedBundleDigest[1:], ":", "-"))) locationsOuterBundleImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(outerBundleDigest[1:], ":", "-"))) + digestSha := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + nestedBundleDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Bundle Origin: %s%s + Layers: + - Digest: %s Annotations: what is this: this is the nested bundle -`, env.RelocationRepo, nestedBundleDigest, nestedBundle, nestedBundleDigest)) +`, env.RelocationRepo, nestedBundleDigest, nestedBundle, nestedBundleDigest, digestSha[0])) + digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img1Digest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Image Origin: %s -`, env.RelocationRepo, img1Digest, img1DigestRef)) + Layers: + - Digest: %s +`, env.RelocationRepo, img1Digest, img1DigestRef, digestSha[0])) + + digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img2Digest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Image Origin: %s -`, env.RelocationRepo, img2Digest, img2DigestRef)) + Layers: + - Digest: %s +`, env.RelocationRepo, img2Digest, img2DigestRef, digestSha[0])) + + digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsNestedBundleImgDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Internal -`, env.RelocationRepo, locationsNestedBundleImgDigest)) + Layers: + - Digest: %s +`, env.RelocationRepo, locationsNestedBundleImgDigest, digestSha[0])) + + digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img1Digest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Image Origin: %s + Layers: + - Digest: %s Annotations: what is this: this is just an image -`, env.RelocationRepo, img1Digest, img1DigestRef)) +`, env.RelocationRepo, img1Digest, img1DigestRef, digestSha[0])) + + digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsOuterBundleImgDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Internal -`, env.RelocationRepo, locationsOuterBundleImgDigest)) + Layers: + - Digest: %s +`, env.RelocationRepo, locationsOuterBundleImgDigest, digestSha[0])) }) }) @@ -273,33 +299,51 @@ images: }, ) + digestSha := env.ImageFactory.GetImageLayerDigest(nestedBundle + nestedBundleDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Bundle Origin: %s%s -`, nestedBundle, nestedBundleDigest, nestedBundle, nestedBundleDigest)) + Layers: + - Digest: %s +`, nestedBundle, nestedBundleDigest, nestedBundle, nestedBundleDigest, digestSha[0])) + + digestSha = env.ImageFactory.GetImageLayerDigest(img1DigestRef) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s Type: Image Origin: %s -`, img1DigestRef, img1DigestRef)) + Layers: + - Digest: %s +`, img1DigestRef, img1DigestRef, digestSha[0])) + + digestSha = env.ImageFactory.GetImageLayerDigest(img2DigestRef) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s Type: Image Origin: %s -`, img2DigestRef, img2DigestRef)) + Layers: + - Digest: %s +`, img2DigestRef, img2DigestRef, digestSha[0])) + + digestSha = env.ImageFactory.GetImageLayerDigest(imgRef.Context().Name() + "-img2" + "@" + img2SigDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Signature + Layers: + - Digest: %s Annotations: tag: %s -`, imgRef.Context().Name()+"-img2", img2SigDigest, img2SigTag)) +`, imgRef.Context().Name()+"-img2", img2SigDigest, digestSha[0], img2SigTag)) + digestSha = env.ImageFactory.GetImageLayerDigest(img1DigestRef) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s Type: Image Origin: %s -`, img1DigestRef, img1DigestRef)) + Layers: + - Digest: %s +`, img1DigestRef, img1DigestRef, digestSha[0])) }) }) } @@ -359,6 +403,11 @@ images: stdoutLines := strings.Split(stdout, "\n") stdout = strings.Join(stdoutLines[:len(stdoutLines)-1], "\n") + digestSha1 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + imageDigest) + digestSha2 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + bundleSigDigest) + digestSha3 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + imgSigDigest) + digestSha4 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsImgDigest) + digestSha5 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + bundleDigest) require.YAMLEq(t, fmt.Sprintf(`sha: %s content: images: @@ -368,42 +417,56 @@ content: some.other.annotation: some other value image: %s%s imageType: Image + layers: + - digest: %s origin: %s%s "%s": annotations: tag: %s image: %s@%s imageType: Signature + layers: + - digest: %s origin: %s@%s "%s": annotations: tag: %s image: %s@%s imageType: Signature + layers: + - digest: %s origin: %s@%s "%s": image: %s@%s imageType: Internal + layers: + - digest: %s origin: %s@%s image: %s%s +layers: +- digest: %s metadata: {} origin: %s%s `, bundleDigest[1:], imageDigest[1:], env.RelocationRepo, imageDigest, + digestSha1[0], env.Image, imageDigest, bundleSigDigest, bundleSigTag, env.RelocationRepo, bundleSigDigest, + digestSha2[0], env.RelocationRepo, bundleSigDigest, imgSigDigest, imgSigTag, env.RelocationRepo, imgSigDigest, + digestSha3[0], env.RelocationRepo, imgSigDigest, locationsImgDigest, env.RelocationRepo, locationsImgDigest, + digestSha4[0], env.RelocationRepo, locationsImgDigest, - env.RelocationRepo, bundleDigest, env.RelocationRepo, bundleDigest), stdout) + env.RelocationRepo, bundleDigest, digestSha5[0], env.RelocationRepo, bundleDigest), stdout) }) }) @@ -456,7 +519,11 @@ images: }, ) locationsImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(bundleDigest[1:], ":", "-"))) - + digestSha1 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + imageDigest) + digestSha2 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + bundleSigDigest) + digestSha3 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + imgSigDigest) + digestSha4 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsImgDigest) + digestSha5 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + bundleDigest) require.YAMLEq(t, fmt.Sprintf(`content: images: "%s": @@ -465,43 +532,53 @@ images: some.other.annotation: some other value image: %s%s imageType: Image + layers: + - digest: %s origin: %s%s "%s": annotations: tag: %s image: %s@%s imageType: Signature + layers: + - digest: %s origin: %s@%s "%s": annotations: tag: %s image: %s@%s imageType: Signature + layers: + - digest: %s origin: %s@%s "%s": image: %s@%s imageType: Internal + layers: + - digest: %s origin: %s@%s metadata: {} image: %s%s +layers: +- digest: %s origin: %s%s sha: %s `, imageDigest[1:], - env.RelocationRepo, imageDigest, + env.RelocationRepo, imageDigest, digestSha1[0], env.Image, imageDigest, bundleSigDigest, bundleSigTag, - env.RelocationRepo, bundleSigDigest, + env.RelocationRepo, bundleSigDigest, digestSha2[0], env.RelocationRepo, bundleSigDigest, imgSigDigest, imgSigTag, - env.RelocationRepo, imgSigDigest, + env.RelocationRepo, imgSigDigest, digestSha3[0], env.RelocationRepo, imgSigDigest, locationsImgDigest, + env.RelocationRepo, locationsImgDigest, digestSha4[0], env.RelocationRepo, locationsImgDigest, - env.RelocationRepo, locationsImgDigest, - env.RelocationRepo, bundleDigest, env.RelocationRepo, bundleDigest, bundleDigest[1:]), stdout) + env.RelocationRepo, bundleDigest, digestSha5[0], env.RelocationRepo, bundleDigest, bundleDigest[1:]), stdout) }) }) @@ -576,6 +653,13 @@ images: locationsOuterBundleImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(outerBundleDigest[1:], ":", "-"))) stdoutLines := strings.Split(stdout, "\n") stdout = strings.Join(stdoutLines[:len(stdoutLines)-1], "\n") + digestSha1 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img1Digest) + digestSha2 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img2Digest) + digestSha3 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsNestedBundleImgDigest) + digestSha4 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + nestedBundleDigest) + digestSha5 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img1Digest) + digestSha6 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsOuterBundleImgDigest) + digestSha7 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + outerBundleDigest) require.YAMLEq(t, fmt.Sprintf(`sha: %s content: bundles: @@ -587,16 +671,24 @@ content: "%s": image: %s%s imageType: Image + layers: + - digest: %s origin: %s "%s": image: %s%s imageType: Image + layers: + - digest: %s origin: %s "%s": image: %s@%s imageType: Internal + layers: + - digest: %s origin: %s@%s image: %s%s + layers: + - digest: %s metadata: {} origin: %s%s images: @@ -605,29 +697,35 @@ content: what is this: this is just an image image: %s%s imageType: Image + layers: + - digest: %s origin: %s "%s": image: %s@%s imageType: Internal + layers: + - digest: %s origin: %s@%s image: %s%s +layers: +- digest: %s metadata: {} origin: %s%s `, outerBundleDigest[1:], nestedBundleDigest[1:], img1Digest[1:], - env.RelocationRepo, img1Digest, img1DigestRef, + env.RelocationRepo, img1Digest, digestSha1[0], img1DigestRef, img2Digest[1:], - env.RelocationRepo, img2Digest, img2DigestRef, + env.RelocationRepo, img2Digest, digestSha2[0], img2DigestRef, locationsNestedBundleImgDigest, - env.RelocationRepo, locationsNestedBundleImgDigest, env.RelocationRepo, locationsNestedBundleImgDigest, - env.RelocationRepo, nestedBundleDigest, nestedBundle, nestedBundleDigest, + env.RelocationRepo, locationsNestedBundleImgDigest, digestSha3[0], env.RelocationRepo, locationsNestedBundleImgDigest, + env.RelocationRepo, nestedBundleDigest, digestSha4[0], nestedBundle, nestedBundleDigest, img1Digest[1:], - env.RelocationRepo, img1Digest, img1DigestRef, + env.RelocationRepo, img1Digest, digestSha5[0], img1DigestRef, locationsOuterBundleImgDigest, - env.RelocationRepo, locationsOuterBundleImgDigest, env.RelocationRepo, locationsOuterBundleImgDigest, - env.RelocationRepo, outerBundleDigest, env.RelocationRepo, outerBundleDigest, + env.RelocationRepo, locationsOuterBundleImgDigest, digestSha6[0], env.RelocationRepo, locationsOuterBundleImgDigest, + env.RelocationRepo, outerBundleDigest, digestSha7[0], env.RelocationRepo, outerBundleDigest, ), stdout) }) }) @@ -696,6 +794,12 @@ images: stdoutLines := strings.Split(stdout, "\n") stdout = strings.Join(stdoutLines[:len(stdoutLines)-1], "\n") + digestSha1 := env.ImageFactory.GetImageLayerDigest(img1DigestRef) + digestSha2 := env.ImageFactory.GetImageLayerDigest(img2DigestRef) + digestSha3 := env.ImageFactory.GetImageLayerDigest(imgRef.Context().Name() + "-img2" + "@" + img2SigDigest) + digestSha4 := env.ImageFactory.GetImageLayerDigest(nestedBundle + nestedBundleDigest) + digestSha5 := env.ImageFactory.GetImageLayerDigest(img1DigestRef) + digestSha6 := env.ImageFactory.GetImageLayerDigest(outerBundle + outerBundleDigest) require.YAMLEq(t, fmt.Sprintf(`sha: %s content: bundles: @@ -705,43 +809,55 @@ content: "%s": image: %s imageType: Image + layers: + - digest: %s origin: %s "%s": image: %s imageType: Image + layers: + - digest: %s origin: %s "%s": annotations: tag: %s image: %s@%s imageType: Signature + layers: + - digest: %s origin: %s@%s image: %s%s + layers: + - digest: %s metadata: {} origin: %s%s images: "%s": image: %s imageType: Image + layers: + - digest: %s origin: %s image: %s%s +layers: +- digest: %s metadata: {} origin: %s%s `, outerBundleDigest[1:], nestedBundleDigest[1:], img1Digest[1:], - img1DigestRef, img1DigestRef, + img1DigestRef, digestSha1[0], img1DigestRef, img2Digest[1:], - img2DigestRef, img2DigestRef, + img2DigestRef, digestSha2[0], img2DigestRef, img2SigDigest, img2SigTag, + imgRef.Context().Name()+"-img2", img2SigDigest, digestSha3[0], imgRef.Context().Name()+"-img2", img2SigDigest, - imgRef.Context().Name()+"-img2", img2SigDigest, - nestedBundle, nestedBundleDigest, nestedBundle, nestedBundleDigest, + nestedBundle, nestedBundleDigest, digestSha4[0], nestedBundle, nestedBundleDigest, img1Digest[1:], - img1DigestRef, img1DigestRef, - outerBundle, outerBundleDigest, outerBundle, outerBundleDigest, + img1DigestRef, digestSha5[0], img1DigestRef, + outerBundle, outerBundleDigest, digestSha6[0], outerBundle, outerBundleDigest, ), stdout) }) }) diff --git a/test/helpers/image_factory.go b/test/helpers/image_factory.go index e3e1a9998..6e13eb7d1 100644 --- a/test/helpers/image_factory.go +++ b/test/helpers/image_factory.go @@ -42,6 +42,25 @@ func (i *ImageFactory) ImageDigest(imgRef string) string { return digest.String() } +// GetImageLayerDigest will return image's layer digest +func (i *ImageFactory) GetImageLayerDigest(image string) []string { + parsedImgRef, err := name.ParseReference(image, name.WeakValidation) + require.NoError(i.T, err) + + v1Img, err := remote.Image(parsedImgRef, remote.WithAuthFromKeychain(authn.DefaultKeychain)) + require.NoError(i.T, err) + + imgLayers, err := v1Img.Layers() + require.NoError(i.T, err) + digestSha := []string{} + for _, imgLayer := range imgLayers { + digHash, err := imgLayer.Digest() + require.NoError(i.T, err) + digestSha = append(digestSha, digHash.String()) + } + return digestSha +} + func (i *ImageFactory) PushImageWithANonDistributableLayer(imgRef string, mediaType types.MediaType) string { imageRef, err := name.ParseReference(imgRef, name.WeakValidation) require.NoError(i.T, err) From f2dc7d36bdd383151927d530d0003a3225e59f1c Mon Sep 17 00:00:00 2001 From: kumari tanushree Date: Wed, 17 Jan 2024 11:18:17 +0530 Subject: [PATCH 4/4] Renamed function name Signed-off-by: kumari tanushree --- test/e2e/describe_test.go | 76 +++++++++++++++++------------------ test/helpers/image_factory.go | 4 +- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/test/e2e/describe_test.go b/test/e2e/describe_test.go index 6005c7769..8ecf698ec 100644 --- a/test/e2e/describe_test.go +++ b/test/e2e/describe_test.go @@ -68,7 +68,7 @@ images: }, ) - digestSha := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + imageDigest) + digestSha := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + imageDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Image @@ -80,7 +80,7 @@ images: some.other.annotation: some other value `, env.RelocationRepo, imageDigest, env.Image, imageDigest, digestSha[0])) - digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + imgSigDigest) + digestSha = env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + imgSigDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Signature @@ -90,7 +90,7 @@ images: tag: %s `, env.RelocationRepo, imgSigDigest, digestSha[0], imgSigTag)) - digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + bundleSigDigest) + digestSha = env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + bundleSigDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Signature @@ -100,7 +100,7 @@ images: tag: %s `, env.RelocationRepo, bundleSigDigest, digestSha[0], bundleSigTag)) - digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsImgDigest) + digestSha = env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + locationsImgDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Internal @@ -179,7 +179,7 @@ images: locationsNestedBundleImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(nestedBundleDigest[1:], ":", "-"))) locationsOuterBundleImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(outerBundleDigest[1:], ":", "-"))) - digestSha := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + nestedBundleDigest) + digestSha := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + nestedBundleDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Bundle @@ -190,7 +190,7 @@ images: what is this: this is the nested bundle `, env.RelocationRepo, nestedBundleDigest, nestedBundle, nestedBundleDigest, digestSha[0])) - digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img1Digest) + digestSha = env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + img1Digest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Image @@ -199,7 +199,7 @@ images: - Digest: %s `, env.RelocationRepo, img1Digest, img1DigestRef, digestSha[0])) - digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img2Digest) + digestSha = env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + img2Digest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Image @@ -208,7 +208,7 @@ images: - Digest: %s `, env.RelocationRepo, img2Digest, img2DigestRef, digestSha[0])) - digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsNestedBundleImgDigest) + digestSha = env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + locationsNestedBundleImgDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Internal @@ -216,7 +216,7 @@ images: - Digest: %s `, env.RelocationRepo, locationsNestedBundleImgDigest, digestSha[0])) - digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img1Digest) + digestSha = env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + img1Digest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Image @@ -227,7 +227,7 @@ images: what is this: this is just an image `, env.RelocationRepo, img1Digest, img1DigestRef, digestSha[0])) - digestSha = env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsOuterBundleImgDigest) + digestSha = env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + locationsOuterBundleImgDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Internal @@ -299,7 +299,7 @@ images: }, ) - digestSha := env.ImageFactory.GetImageLayerDigest(nestedBundle + nestedBundleDigest) + digestSha := env.ImageFactory.GetImageLayersDigest(nestedBundle + nestedBundleDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s%s Type: Bundle @@ -308,7 +308,7 @@ images: - Digest: %s `, nestedBundle, nestedBundleDigest, nestedBundle, nestedBundleDigest, digestSha[0])) - digestSha = env.ImageFactory.GetImageLayerDigest(img1DigestRef) + digestSha = env.ImageFactory.GetImageLayersDigest(img1DigestRef) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s Type: Image @@ -317,7 +317,7 @@ images: - Digest: %s `, img1DigestRef, img1DigestRef, digestSha[0])) - digestSha = env.ImageFactory.GetImageLayerDigest(img2DigestRef) + digestSha = env.ImageFactory.GetImageLayersDigest(img2DigestRef) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s Type: Image @@ -326,7 +326,7 @@ images: - Digest: %s `, img2DigestRef, img2DigestRef, digestSha[0])) - digestSha = env.ImageFactory.GetImageLayerDigest(imgRef.Context().Name() + "-img2" + "@" + img2SigDigest) + digestSha = env.ImageFactory.GetImageLayersDigest(imgRef.Context().Name() + "-img2" + "@" + img2SigDigest) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s@%s Type: Signature @@ -336,7 +336,7 @@ images: tag: %s `, imgRef.Context().Name()+"-img2", img2SigDigest, digestSha[0], img2SigTag)) - digestSha = env.ImageFactory.GetImageLayerDigest(img1DigestRef) + digestSha = env.ImageFactory.GetImageLayersDigest(img1DigestRef) assert.Contains(t, stdout, fmt.Sprintf( ` - Image: %s Type: Image @@ -403,11 +403,11 @@ images: stdoutLines := strings.Split(stdout, "\n") stdout = strings.Join(stdoutLines[:len(stdoutLines)-1], "\n") - digestSha1 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + imageDigest) - digestSha2 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + bundleSigDigest) - digestSha3 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + imgSigDigest) - digestSha4 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsImgDigest) - digestSha5 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + bundleDigest) + digestSha1 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + imageDigest) + digestSha2 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + bundleSigDigest) + digestSha3 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + imgSigDigest) + digestSha4 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + locationsImgDigest) + digestSha5 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + bundleDigest) require.YAMLEq(t, fmt.Sprintf(`sha: %s content: images: @@ -519,11 +519,11 @@ images: }, ) locationsImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(bundleDigest[1:], ":", "-"))) - digestSha1 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + imageDigest) - digestSha2 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + bundleSigDigest) - digestSha3 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + imgSigDigest) - digestSha4 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsImgDigest) - digestSha5 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + bundleDigest) + digestSha1 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + imageDigest) + digestSha2 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + bundleSigDigest) + digestSha3 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + imgSigDigest) + digestSha4 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + locationsImgDigest) + digestSha5 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + bundleDigest) require.YAMLEq(t, fmt.Sprintf(`content: images: "%s": @@ -653,13 +653,13 @@ images: locationsOuterBundleImgDigest := env.ImageFactory.ImageDigest(fmt.Sprintf("%s:%s.image-locations.imgpkg", env.RelocationRepo, strings.ReplaceAll(outerBundleDigest[1:], ":", "-"))) stdoutLines := strings.Split(stdout, "\n") stdout = strings.Join(stdoutLines[:len(stdoutLines)-1], "\n") - digestSha1 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img1Digest) - digestSha2 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img2Digest) - digestSha3 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsNestedBundleImgDigest) - digestSha4 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + nestedBundleDigest) - digestSha5 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + img1Digest) - digestSha6 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + "@" + locationsOuterBundleImgDigest) - digestSha7 := env.ImageFactory.GetImageLayerDigest(env.RelocationRepo + outerBundleDigest) + digestSha1 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + img1Digest) + digestSha2 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + img2Digest) + digestSha3 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + locationsNestedBundleImgDigest) + digestSha4 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + nestedBundleDigest) + digestSha5 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + img1Digest) + digestSha6 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + "@" + locationsOuterBundleImgDigest) + digestSha7 := env.ImageFactory.GetImageLayersDigest(env.RelocationRepo + outerBundleDigest) require.YAMLEq(t, fmt.Sprintf(`sha: %s content: bundles: @@ -794,12 +794,12 @@ images: stdoutLines := strings.Split(stdout, "\n") stdout = strings.Join(stdoutLines[:len(stdoutLines)-1], "\n") - digestSha1 := env.ImageFactory.GetImageLayerDigest(img1DigestRef) - digestSha2 := env.ImageFactory.GetImageLayerDigest(img2DigestRef) - digestSha3 := env.ImageFactory.GetImageLayerDigest(imgRef.Context().Name() + "-img2" + "@" + img2SigDigest) - digestSha4 := env.ImageFactory.GetImageLayerDigest(nestedBundle + nestedBundleDigest) - digestSha5 := env.ImageFactory.GetImageLayerDigest(img1DigestRef) - digestSha6 := env.ImageFactory.GetImageLayerDigest(outerBundle + outerBundleDigest) + digestSha1 := env.ImageFactory.GetImageLayersDigest(img1DigestRef) + digestSha2 := env.ImageFactory.GetImageLayersDigest(img2DigestRef) + digestSha3 := env.ImageFactory.GetImageLayersDigest(imgRef.Context().Name() + "-img2" + "@" + img2SigDigest) + digestSha4 := env.ImageFactory.GetImageLayersDigest(nestedBundle + nestedBundleDigest) + digestSha5 := env.ImageFactory.GetImageLayersDigest(img1DigestRef) + digestSha6 := env.ImageFactory.GetImageLayersDigest(outerBundle + outerBundleDigest) require.YAMLEq(t, fmt.Sprintf(`sha: %s content: bundles: diff --git a/test/helpers/image_factory.go b/test/helpers/image_factory.go index 6e13eb7d1..aaf41244f 100644 --- a/test/helpers/image_factory.go +++ b/test/helpers/image_factory.go @@ -42,8 +42,8 @@ func (i *ImageFactory) ImageDigest(imgRef string) string { return digest.String() } -// GetImageLayerDigest will return image's layer digest -func (i *ImageFactory) GetImageLayerDigest(image string) []string { +// GetImageLayersDigest will return image's layers digest +func (i *ImageFactory) GetImageLayersDigest(image string) []string { parsedImgRef, err := name.ParseReference(image, name.WeakValidation) require.NoError(i.T, err)