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)
| 88 | // resolveDigest queries the image repository to determine the image digest and |
| 89 | // returns a new instance of ImageReference with the updated digest value. |
| 90 | func (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 | |
| 107 | func (i *ImageReference) String() string { |
| 108 | // An image reference has at most 3 parts (repo, tag, digest) plus 2 separators |
no test coverage detected