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

Function digestContainerImageArtifact

pkg/cmd/attestation/artifact/image.go:10–30  ·  view source on GitHub ↗
(url string, client oci.Client)

Source from the content-addressed store, hash-verified

8)
9
10func digestContainerImageArtifact(url string, client oci.Client) (*DigestedArtifact, error) {
11 // try to parse the url as a valid registry reference
12 named, err := reference.Parse(url)
13 if err != nil {
14 // cannot be parsed as a registry reference
15 return nil, fmt.Errorf("artifact %s is not a valid registry reference: %v", url, err)
16 }
17
18 digest, nameRef, err := client.GetImageDigest(named.String())
19
20 if err != nil {
21 return nil, err
22 }
23
24 return &DigestedArtifact{
25 URL: fmt.Sprintf("oci://%s", named.String()),
26 digest: digest.Hex,
27 digestAlg: digest.Algorithm,
28 nameRef: nameRef,
29 }, nil
30}

Callers 4

NewDigestedArtifactFunction · 0.85
TestParseImageRefFailureFunction · 0.85
TestFetchImageFailureFunction · 0.85

Calls 3

ErrorfMethod · 0.65
GetImageDigestMethod · 0.65
StringMethod · 0.65

Tested by 3

TestParseImageRefFailureFunction · 0.68
TestFetchImageFailureFunction · 0.68