MCPcopy Create free account
hub / github.com/conforma/cli / resolveDigest

Method resolveDigest

internal/image/process.go:90–105  ·  view source on GitHub ↗

resolveDigest queries the image repository to determine the image digest and returns a new instance of ImageReference with the updated digest value.

(ctx context.Context, opts ...name.Option)

Source from the content-addressed store, hash-verified

88// resolveDigest queries the image repository to determine the image digest and
89// returns a new instance of ImageReference with the updated digest value.
90func (i ImageReference) resolveDigest(ctx context.Context, opts ...name.Option) (*ImageReference, error) {
91 remoteHead := remote.Head
92 if rh, ok := ctx.Value(RemoteHead).(func(name.Reference, ...remote.Option) (*v1.Descriptor, error)); ok {
93 remoteHead = rh
94 }
95 descriptor, err := remoteHead(i.ref, remote.WithAuthFromKeychain(authn.DefaultKeychain))
96 if err != nil {
97 return nil, err
98 }
99 digest := descriptor.Digest.String()
100 if digest == "" {
101 return nil, fmt.Errorf("digest for image %q is empty", i.ref.String())
102 }
103
104 return NewImageReference(fmt.Sprintf("%s:%s@%s", i.Repository, i.Tag, digest), opts...)
105}
106
107func (i *ImageReference) String() string {
108 // An image reference has at most 3 parts (repo, tag, digest) plus 2 separators

Callers 1

ParseAndResolveFunction · 0.95

Calls 3

NewImageReferenceFunction · 0.85
ErrorfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected