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

Function loadBundlesFromJSONLinesFile

pkg/cmd/attestation/verification/attestation.go:58–83  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

56}
57
58func loadBundlesFromJSONLinesFile(path string) ([]*api.Attestation, error) {
59 fileContent, err := os.ReadFile(path)
60 if err != nil {
61 return nil, err
62 }
63
64 attestations := []*api.Attestation{}
65
66 decoder := json.NewDecoder(bytes.NewReader(fileContent))
67
68 for decoder.More() {
69 var b bundle.Bundle
70 b.Bundle = new(protobundle.Bundle)
71 if err := decoder.Decode(&b); err != nil {
72 return nil, err
73 }
74 a := api.Attestation{Bundle: &b}
75 attestations = append(attestations, &a)
76 }
77
78 if len(attestations) == 0 {
79 return nil, ErrEmptyBundleFile
80 }
81
82 return attestations, nil
83}
84
85func GetOCIAttestations(client oci.Client, artifact artifact.DigestedArtifact) ([]*api.Attestation, error) {
86 attestations, err := client.GetAttestations(artifact.NameRef(), artifact.DigestWithAlg())

Calls

no outgoing calls