in pkg/attestation/import.go [126:145]
func postOccurrence(ctx context.Context, c *ca.Client, nr utils.NoteResource, o *g.Occurrence) error {
// Create Occurrence
oreq := &g.CreateOccurrenceRequest{
Parent: nr.Project,
Occurrence: o,
}
occ, err := c.GetGrafeasClient().CreateOccurrence(ctx, oreq)
if err != nil {
// If occurrence already exists, skip
if status.Code(err) == codes.AlreadyExists {
log.Info().Msgf("Already Exists: Occurrence")
} else {
return errors.Wrap(err, "error posting occurrence")
}
} else {
log.Info().Msgf("Created Occurrence: %s", occ.Name)
}
return nil
}