diff --git a/pkg/kbld/image/resolved.go b/pkg/kbld/image/resolved.go index ce7ba18c..e242db6c 100644 --- a/pkg/kbld/image/resolved.go +++ b/pkg/kbld/image/resolved.go @@ -1,6 +1,8 @@ package image import ( + "fmt" + regname "github.com/google/go-containerregistry/pkg/name" ) @@ -33,6 +35,18 @@ func (i ResolvedImage) URL() (string, []ImageMeta, error) { return "", nil, err } + // Resolve image second time because some older registry can + // return "random" digests that change for every request. + // See https://github.com/k14s/kbld/issues/21 for details. + imgDescriptor2, err := i.registry.Generic(tag) + if err != nil { + return "", nil, err + } + + if imgDescriptor.Digest.String() != imgDescriptor2.Digest.String() { + return "", nil, fmt.Errorf("Expected digest resolution to be consistent over two separate requests") + } + url, metas, err := NewDigestedImageFromParts(tag.Repository.String(), imgDescriptor.Digest.String()).URL() if err != nil { return "", nil, err