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

Function GetLocalAttestations

pkg/cmd/attestation/verification/attestation.go:24–47  ·  view source on GitHub ↗

GetLocalAttestations returns a slice of attestations read from a local bundle file.

(path string)

Source from the content-addressed store, hash-verified

22
23// GetLocalAttestations returns a slice of attestations read from a local bundle file.
24func GetLocalAttestations(path string) ([]*api.Attestation, error) {
25 var attestations []*api.Attestation
26 var err error
27 fileExt := filepath.Ext(path)
28 if fileExt == ".json" {
29 attestations, err = loadBundleFromJSONFile(path)
30 } else if fileExt == ".jsonl" {
31 attestations, err = loadBundlesFromJSONLinesFile(path)
32 } else {
33 return nil, ErrUnrecognisedBundleExtension
34 }
35
36 if err != nil {
37 var pathErr *os.PathError
38 if errors.As(err, &pathErr) {
39 return nil, fmt.Errorf("could not load content from file path %s: %w", path, err)
40 } else if errors.Is(err, bundle.ErrValidation) {
41 return nil, err
42 }
43 return nil, fmt.Errorf("bundle content could not be parsed: %w", err)
44 }
45
46 return attestations, nil
47}
48
49func loadBundleFromJSONFile(path string) ([]*api.Attestation, error) {
50 b, err := bundle.LoadJSONFromPath(path)

Callers 6

runInspectFunction · 0.92
TestGetAttestationDetailFunction · 0.92
getAttestationsForFunction · 0.92
getAttestationsFunction · 0.92
getAttestationsForFunction · 0.85
TestGetLocalAttestationsFunction · 0.85

Calls 3

loadBundleFromJSONFileFunction · 0.85
ErrorfMethod · 0.65

Tested by 4

TestGetAttestationDetailFunction · 0.74
getAttestationsForFunction · 0.74
getAttestationsForFunction · 0.68
TestGetLocalAttestationsFunction · 0.68