MCPcopy Create free account
hub / github.com/cli/cli / GetImageDigest

Method GetImageDigest

pkg/cmd/attestation/artifact/oci/client.go:49–69  ·  view source on GitHub ↗

where name is formed like ghcr.io/github/my-image-repo

(imgName string)

Source from the content-addressed store, hash-verified

47
48// where name is formed like ghcr.io/github/my-image-repo
49func (c LiveClient) GetImageDigest(imgName string) (*v1.Hash, name.Reference, error) {
50 name, err := c.parseReference(imgName)
51 if err != nil {
52 return nil, nil, fmt.Errorf("failed to create image tag: %v", err)
53 }
54 // The user must already be authenticated with the container registry
55 // The authn.DefaultKeychain argument indicates that Get should checks the
56 // user's configuration for the registry credentials
57 desc, err := c.get(name, remote.WithAuthFromKeychain(authn.DefaultKeychain))
58 if err != nil {
59 var transportErr *transport.Error
60 if errors.As(err, &transportErr) {
61 if accessErr := checkForUnauthorizedOrDeniedErr(*transportErr); accessErr != nil {
62 return nil, nil, accessErr
63 }
64 }
65 return nil, nil, fmt.Errorf("failed to fetch remote image: %v", err)
66 }
67
68 return &desc.Digest, name, nil
69}
70
71func (c LiveClient) GetAttestations(ref name.Reference, digest string) ([]*api.Attestation, error) {
72 attestations := make([]*api.Attestation, 0)

Calls 3

getMethod · 0.80
ErrorfMethod · 0.65

Tested by 4