MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / commitAnnotations

Function commitAnnotations

pkg/attestation/renderer/chainloop/v02.go:167–201  ·  view source on GitHub ↗
(c *v1.Commit)

Source from the content-addressed store, hash-verified

165}
166
167func commitAnnotations(c *v1.Commit) (*structpb.Struct, error) {
168 annotationsRaw := map[string]interface{}{
169 subjectGitAnnotationWhen: c.GetDate().AsTime().Format(time.RFC3339),
170 subjectGitAnnotationAuthorEmail: c.GetAuthorEmail(),
171 subjectGitAnnotationAuthorName: c.GetAuthorName(),
172 subjectGitAnnotationMessage: c.GetMessage(),
173 }
174
175 // add signature only if exists
176 if c.GetSignature() != "" {
177 annotationsRaw[subjectGitAnnotationSignature] = c.GetSignature()
178 }
179
180 // add verification only if exists as well as its fields
181 if pv := c.GetPlatformVerification(); pv != nil {
182 annotationsRaw[subjectGitAnnotationAuthorVerificationStatus] = pv.GetStatus().String()
183 if sig := pv.GetSignatureAlgorithm(); sig != "" {
184 annotationsRaw[subjectGitAnnotationSignatureAlgorithm] = sig
185 }
186 }
187
188 if remotes := c.GetRemotes(); len(remotes) > 0 {
189 remotesRaw := []interface{}{}
190 for _, r := range remotes {
191 remotesRaw = append(remotesRaw, map[string]interface{}{
192 "name": r.GetName(),
193 "url": r.GetUrl(),
194 })
195 }
196
197 annotationsRaw[subjectGitAnnotationRemotes] = remotesRaw
198 }
199
200 return structpb.NewStruct(annotationsRaw)
201}
202
203func (r *RendererV02) subject() ([]*intoto.ResourceDescriptor, error) {
204 raw, err := json.Marshal(r.att)

Callers 1

subjectMethod · 0.85

Calls 12

GetAuthorEmailMethod · 0.80
GetAuthorNameMethod · 0.80
GetSignatureAlgorithmMethod · 0.80
GetRemotesMethod · 0.80
StringMethod · 0.65
GetNameMethod · 0.65
GetDateMethod · 0.45
GetMessageMethod · 0.45
GetSignatureMethod · 0.45
GetStatusMethod · 0.45
GetUrlMethod · 0.45

Tested by

no test coverage detected