func updateDiscoveryNote()

in pkg/vul/discovery.go [44:68]


func updateDiscoveryNote(ctx context.Context, parent string, discoveryNoteID string, c *ca.Client) error {
	// Create Note
	req := &g.CreateNoteRequest{
		Parent: parent,
		NoteId: discoveryNoteID,
		Note: &g.Note{
			ShortDescription: "aactl discovery note",
			Kind:             g.NoteKind_DISCOVERY,
			Type: &g.Note_Discovery{
				Discovery: &g.DiscoveryNote{AnalysisKind: g.NoteKind_DISCOVERY},
			},
		},
	}
	noteName := fmt.Sprintf("%s/notes/%s", parent, discoveryNoteID)
	_, err := c.GetGrafeasClient().CreateNote(ctx, req)
	if err != nil {
		// If note already exists, skip
		if status.Code(err) == codes.AlreadyExists {
			log.Debug().Msgf("already exists: %s", noteName)
		} else {
			return errors.Wrap(err, "error creating discovery note")
		}
	}
	return nil
}