where name is formed like ghcr.io/github/my-image-repo
(imgName string)
| 47 | |
| 48 | // where name is formed like ghcr.io/github/my-image-repo |
| 49 | func (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 | |
| 71 | func (c LiveClient) GetAttestations(ref name.Reference, digest string) ([]*api.Attestation, error) { |
| 72 | attestations := make([]*api.Attestation, 0) |