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

Function loadBundlesFromJSONLinesFile

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

Source from the content-addressed store, hash-verified

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

Calls

no outgoing calls