(c *v1.Commit)
| 165 | } |
| 166 | |
| 167 | func 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 | |
| 203 | func (r *RendererV02) subject() ([]*intoto.ResourceDescriptor, error) { |
| 204 | raw, err := json.Marshal(r.att) |
no test coverage detected