Skip to content

Commit

Permalink
resolve image references twice to catch any registries that return "r…
Browse files Browse the repository at this point in the history
…andom" digests
  • Loading branch information
cppforlife committed Mar 6, 2020
1 parent 1760ec1 commit 91a5653
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/kbld/image/resolved.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package image

import (
"fmt"

regname "github.com/google/go-containerregistry/pkg/name"
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 91a5653

Please sign in to comment.