From b82880ab07b466c03b21930e31fa8d41bce0c916 Mon Sep 17 00:00:00 2001 From: Jalander Ramagiri Date: Mon, 10 Jun 2024 14:47:41 +0100 Subject: [PATCH] adding tag names with cdevents Signed-off-by: Jalander Ramagiri --- pkg/api/types.go | 6 +++--- tools/templates/event.go.tmpl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index 6b86e2b..82fa07d 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -75,7 +75,7 @@ type Context struct { // purpose of the source is to provide global uniqueness for source + id. // The source MAY identify a single producer or a group of producer that // belong to the same application. - Source string `json:"source" jsonschema:"required,minLength=1" validate:"uri-reference"` + Source string `json:"source" jsonschema:"required,minLength=1" validate:"uri-reference" cdevents:"context_source"` // Spec: https://cdevents.dev/docs/spec/#type // Description: defines the type of event, as combination of a subject and @@ -98,14 +98,14 @@ type Reference struct { // Spec: https://cdevents.dev/docs/spec/#format-of-subjects // Description: Uniquely identifies the subject within the source - Id string `json:"id" jsonschema:"required,minLength=1"` + Id string `json:"id" jsonschema:"required,minLength=1" cdevents:"subject_id"` // Spec: https://cdevents.dev/docs/spec/#format-of-subjects // Description: defines the context in which an event happened. The main // purpose of the source is to provide global uniqueness for source + id. // The source MAY identify a single producer or a group of producer that // belong to the same application. - Source string `json:"source,omitempty" validate:"uri-reference"` + Source string `json:"source,omitempty" validate:"uri-reference" cdevents:"subject_source"` } type SubjectBase struct { diff --git a/tools/templates/event.go.tmpl b/tools/templates/event.go.tmpl index 28d590c..4bd99e2 100644 --- a/tools/templates/event.go.tmpl +++ b/tools/templates/event.go.tmpl @@ -41,7 +41,7 @@ var ( type {{.Subject}}{{.Predicate}}SubjectContent struct{ {{ range $i, $field := .Contents }} - {{ .Name }} {{ .Type }} `json:"{{ .NameLower }}{{ if not .Required }},omitempty{{ end }}"{{ if eq .Name "ArtifactId" }} validate:"purl"{{ end }}` + {{ .Name }} {{ .Type }} `json:"{{ .NameLower }}{{ if not .Required }},omitempty{{ end }}"{{ if eq .Name "ArtifactId" }} validate:"purl"{{ end }} cdevents:"{{ .NameLower }}"` {{ end }} } @@ -189,7 +189,7 @@ func New{{.Subject}}{{.Predicate}}EventV{{.VersionName}}(specVersion string) (*{ // {{$.Subject}}{{$.Predicate}}SubjectContent{{ .Name }} holds the content of a {{ .Name }} field in the content type {{$.Subject}}{{$.Predicate}}SubjectContent{{ .Name }} struct{ {{ range $j, $field := .Fields }} - {{ .Name }} {{ .Type }} `json:"{{ .NameLower }}{{ if not .Required }},omitempty{{ end }}"` + {{ .Name }} {{ .Type }} `json:"{{ .NameLower }}{{ if not .Required }},omitempty{{ end }}" cdevents:"{{ .NameLower }}"` {{ end }} } -{{ end }} \ No newline at end of file +{{ end }}