MCPcopy Index your code
hub / github.com/cli/cli / getAttestationDetail

Function getAttestationDetail

pkg/cmd/attestation/inspect/bundle.go:77–111  ·  view source on GitHub ↗
(tenant string, attr api.Attestation)

Source from the content-addressed store, hash-verified

75}
76
77func getAttestationDetail(tenant string, attr api.Attestation) (AttestationDetail, error) {
78 envelope, err := attr.Bundle.Envelope()
79 if err != nil {
80 return AttestationDetail{}, fmt.Errorf("failed to get envelope from bundle: %v", err)
81 }
82
83 statement, err := envelope.EnvelopeContent().Statement()
84 if err != nil {
85 return AttestationDetail{}, fmt.Errorf("failed to get statement from envelope: %v", err)
86 }
87
88 var predicate Predicate
89 predicateJson, err := json.Marshal(statement.Predicate)
90 if err != nil {
91 return AttestationDetail{}, fmt.Errorf("failed to marshal predicate: %v", err)
92 }
93
94 err = json.Unmarshal(predicateJson, &predicate)
95 if err != nil {
96 return AttestationDetail{}, fmt.Errorf("failed to unmarshal predicate: %v", err)
97 }
98
99 org, repo, err := getOrgAndRepo(tenant, predicate.BuildDefinition.ExternalParameters.Workflow.Repository)
100 if err != nil {
101 return AttestationDetail{}, fmt.Errorf("failed to parse attestation content: %v", err)
102 }
103
104 return AttestationDetail{
105 OrgName: org,
106 OrgID: predicate.BuildDefinition.InternalParameters.GitHub.RepositoryOwnerId,
107 RepositoryName: repo,
108 RepositoryID: predicate.BuildDefinition.InternalParameters.GitHub.RepositoryID,
109 WorkflowID: predicate.RunDetails.Metadata.InvocationID,
110 }, nil
111}

Callers 1

TestGetAttestationDetailFunction · 0.85

Calls 2

getOrgAndRepoFunction · 0.85
ErrorfMethod · 0.65

Tested by 1

TestGetAttestationDetailFunction · 0.68