diff --git a/.gitmodules b/.gitmodules index 2143500..40ad4aa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ -[submodule "pkg/api/spec"] - path = pkg/api/spec +[submodule "pkg/api/spec-v0.3"] + path = pkg/api/spec-v0.3 url = https://github.com/cdevents/spec + branch = spec-v0.3 diff --git a/pkg/api/bindings_test.go b/pkg/api/bindings_test.go index 0bc51d7..776d49f 100644 --- a/pkg/api/bindings_test.go +++ b/pkg/api/bindings_test.go @@ -16,13 +16,14 @@ limitations under the License. SPDX-License-Identifier: Apache-2.0 */ -package api +package api_test import ( "encoding/json" "os" "testing" + "github.com/cdevents/sdk-go/pkg/api" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" jsonschema "github.com/santhosh-tekuri/jsonschema/v5" @@ -47,51 +48,57 @@ var ( testDataXml = []byte("testData") testChangeId = "myChange123" - eventJsonCustomData *FooSubjectBarPredicateEvent - eventNonJsonCustomData *FooSubjectBarPredicateEvent - eventJsonCustomDataUnmarshalled *FooSubjectBarPredicateEvent + eventJsonCustomData *api.FooSubjectBarPredicateEvent + eventNonJsonCustomData *api.FooSubjectBarPredicateEvent + eventJsonCustomDataUnmarshalled *api.FooSubjectBarPredicateEvent eventJsonCustomDataFile = "json_custom_data" eventImplicitJsonCustomDataFile = "implicit_json_custom_data" eventNonJsonCustomDataFile = "non_json_custom_data" ) -func setContext(event CDEventWriter, subjectId string) { +func panicOnError(err error) { + if err != nil { + panic(err.Error()) + } +} + +func setContext(event api.CDEventWriter, subjectId string) { event.SetSource(testSource) event.SetSubjectId(subjectId) } func init() { - eventJsonCustomData, _ = NewFooSubjectBarPredicateEvent() + eventJsonCustomData, _ = api.NewFooSubjectBarPredicateEvent() setContext(eventJsonCustomData, testSubjectId) - eventJsonCustomData.SetSubjectReferenceField(&Reference{Id: testChangeId}) + eventJsonCustomData.SetSubjectReferenceField(&api.Reference{Id: testChangeId}) eventJsonCustomData.SetSubjectPlainField(testValue) eventJsonCustomData.SetSubjectArtifactId(testArtifactId) - eventJsonCustomData.SetSubjectObjectField(&FooSubjectBarPredicateSubjectContentObjectField{Required: testChangeId, Optional: testSource}) + eventJsonCustomData.SetSubjectObjectField(&api.FooSubjectBarPredicateSubjectContentObjectField{Required: testChangeId, Optional: testSource}) err := eventJsonCustomData.SetCustomData("application/json", testDataJson) panicOnError(err) - eventJsonCustomDataUnmarshalled, _ = NewFooSubjectBarPredicateEvent() + eventJsonCustomDataUnmarshalled, _ = api.NewFooSubjectBarPredicateEvent() setContext(eventJsonCustomDataUnmarshalled, testSubjectId) - eventJsonCustomDataUnmarshalled.SetSubjectReferenceField(&Reference{Id: testChangeId}) + eventJsonCustomDataUnmarshalled.SetSubjectReferenceField(&api.Reference{Id: testChangeId}) eventJsonCustomDataUnmarshalled.SetSubjectPlainField(testValue) eventJsonCustomDataUnmarshalled.SetSubjectArtifactId(testArtifactId) - eventJsonCustomDataUnmarshalled.SetSubjectObjectField(&FooSubjectBarPredicateSubjectContentObjectField{Required: testChangeId, Optional: testSource}) + eventJsonCustomDataUnmarshalled.SetSubjectObjectField(&api.FooSubjectBarPredicateSubjectContentObjectField{Required: testChangeId, Optional: testSource}) err = eventJsonCustomDataUnmarshalled.SetCustomData("application/json", testDataJsonUnmarshalled) panicOnError(err) - eventNonJsonCustomData, _ = NewFooSubjectBarPredicateEvent() + eventNonJsonCustomData, _ = api.NewFooSubjectBarPredicateEvent() setContext(eventNonJsonCustomData, testSubjectId) - eventNonJsonCustomData.SetSubjectReferenceField(&Reference{Id: testChangeId}) + eventNonJsonCustomData.SetSubjectReferenceField(&api.Reference{Id: testChangeId}) eventNonJsonCustomData.SetSubjectPlainField(testValue) eventNonJsonCustomData.SetSubjectArtifactId(testArtifactId) - eventNonJsonCustomData.SetSubjectObjectField(&FooSubjectBarPredicateSubjectContentObjectField{Required: testChangeId, Optional: testSource}) + eventNonJsonCustomData.SetSubjectObjectField(&api.FooSubjectBarPredicateSubjectContentObjectField{Required: testChangeId, Optional: testSource}) err = eventNonJsonCustomData.SetCustomData("application/xml", testDataXml) panicOnError(err) // Extend the map of valid events with the test ones - for k, v := range TestCDEventsByUnversionedTypes { - CDEventsByUnversionedTypes[k] = v + for k, v := range api.TestCDEventsByUnversionedTypes { + api.CDEventsByUnversionedTypes[k] = v } } @@ -101,7 +108,7 @@ func TestAsCloudEvent(t *testing.T) { tests := []struct { name string - event CDEventReader + event api.CDEventReader }{{ name: "event with JSON custom data", event: eventJsonCustomData, @@ -111,8 +118,8 @@ func TestAsCloudEvent(t *testing.T) { }} for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - payloadReceiver := &FooSubjectBarPredicateEvent{} - ce, err := AsCloudEvent(tc.event) + payloadReceiver := &api.FooSubjectBarPredicateEvent{} + ce, err := api.AsCloudEvent(tc.event) if err != nil { t.Fatalf("didn't expected it to fail, but it did: %v", err) } @@ -132,7 +139,7 @@ func TestAsCloudEvent(t *testing.T) { if err != nil { t.Fatalf("somehow cannot unmarshal test event %v, %v", ce, err) } - if d := cmp.Diff(tc.event, payloadReceiver, cmpopts.IgnoreFields(CDEventCustomData{}, "CustomData")); d != "" { + if d := cmp.Diff(tc.event, payloadReceiver, cmpopts.IgnoreFields(api.CDEventCustomData{}, "CustomData")); d != "" { t.Errorf("args: diff(-want,+got):\n%s", d) } if tc.event.GetCustomDataContentType() == "application/json" { @@ -168,7 +175,7 @@ func TestAsCloudEvent(t *testing.T) { } func TestAsCloudEventInvalid(t *testing.T) { - _, err := AsCloudEvent(nil) + _, err := api.AsCloudEvent(nil) if err == nil { t.Fatalf("expected it to fail, but it didn't") } @@ -182,7 +189,7 @@ func TestAsJsonBytes(t *testing.T) { tests := []struct { name string - event CDEvent + event api.CDEvent fileName string }{{ name: "json custom data", @@ -216,7 +223,7 @@ func TestAsJsonBytes(t *testing.T) { t.Fatalf("Failed to validate events %s", err) } // Then test that AsJsonBytes produces a matching JSON from the event - obtainedJsonString, err := AsJsonBytes(tc.event) + obtainedJsonString, err := api.AsJsonBytes(tc.event) if err != nil { t.Fatalf("didn't expected it to fail, but it did: %v", err) } @@ -238,44 +245,44 @@ func TestAsJsonBytes(t *testing.T) { func TestInvalidEvent(t *testing.T) { // mandatory source missing - eventNoSource, _ := NewFooSubjectBarPredicateEvent() + eventNoSource, _ := api.NewFooSubjectBarPredicateEvent() eventNoSource.SetSubjectId(testSubjectId) // mandatory subject id missing - eventNoSubjectId, _ := NewFooSubjectBarPredicateEvent() + eventNoSubjectId, _ := api.NewFooSubjectBarPredicateEvent() eventNoSubjectId.SetSource(testSource) // forced invalid version - eventBadVersion, _ := NewFooSubjectBarPredicateEvent() + eventBadVersion, _ := api.NewFooSubjectBarPredicateEvent() eventBadVersion.Context.Version = "invalid" // mandatory plainField and referenceField missing - eventIncompleteSubject, _ := NewFooSubjectBarPredicateEvent() + eventIncompleteSubject, _ := api.NewFooSubjectBarPredicateEvent() eventIncompleteSubject.SetSource(testSource) eventIncompleteSubject.SetSubjectId(testSubjectId) // invalid source format in context - eventInvalidSource, _ := NewFooSubjectBarPredicateEvent() + eventInvalidSource, _ := api.NewFooSubjectBarPredicateEvent() eventInvalidSource.SetSource("\\--##@@") // invalid source format in reference - eventInvalidSourceReference, _ := NewFooSubjectBarPredicateEvent() + eventInvalidSourceReference, _ := api.NewFooSubjectBarPredicateEvent() eventInvalidSourceReference.SetSubjectReferenceField( - &Reference{Id: "1234", Source: "\\--##@@"}) + &api.Reference{Id: "1234", Source: "\\--##@@"}) // invalid format of purl - eventInvalidPurl, _ := NewFooSubjectBarPredicateEvent() + eventInvalidPurl, _ := api.NewFooSubjectBarPredicateEvent() setContext(eventInvalidPurl, testSubjectId) eventInvalidPurl.SetSubjectArtifactId("not-a-valid-purl") // invalid event type - eventInvalidType := &FooSubjectBarPredicateEvent{ - Context: Context{ + eventInvalidType := &api.FooSubjectBarPredicateEvent{ + Context: api.Context{ Type: "not-a-valid-type", - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: FooSubjectBarPredicateSubject{ - SubjectBase: SubjectBase{ + Subject: api.FooSubjectBarPredicateSubject{ + SubjectBase: api.SubjectBase{ Type: "notAValidSubjectType", }, }, @@ -283,7 +290,7 @@ func TestInvalidEvent(t *testing.T) { tests := []struct { name string - event CDEvent + event api.CDEvent }{{ name: "missing source", event: eventNoSource, @@ -312,7 +319,7 @@ func TestInvalidEvent(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { // First validate that the test JSON compiles against the schema - err := Validate(tc.event) + err := api.Validate(tc.event) if err == nil { t.Fatalf("Expected validation to fail, but it succeeded instead") } @@ -321,7 +328,7 @@ func TestInvalidEvent(t *testing.T) { } func TestAsJsonStringEmpty(t *testing.T) { - obtainedJsonString, err := AsJsonString(nil) + obtainedJsonString, err := api.AsJsonString(nil) if err != nil { t.Fatalf("didn't expected it to fail, but it did: %v", err) } @@ -334,7 +341,7 @@ func TestNewFromJsonString(t *testing.T) { tests := []struct { name string - event CDEvent + event api.CDEvent fileName string }{{ name: "json custom data", @@ -356,7 +363,7 @@ func TestNewFromJsonString(t *testing.T) { if err != nil { t.Fatalf("didn't expected it to fail, but it did: %v", err) } - obtainedEvent, err := NewFromJsonBytes(eventBytes) + obtainedEvent, err := api.NewFromJsonBytes(eventBytes) if err != nil { t.Fatalf("didn't expected it to fail, but it did: %v", err) } @@ -401,12 +408,12 @@ func TestParseType(t *testing.T) { tests := []struct { name string eventType string - want *CDEventType + want *api.CDEventType wantError string }{{ name: "valid", eventType: "dev.cdevents.foosubject.barpredicate.0.1.2-draft", - want: &CDEventType{ + want: &api.CDEventType{ Subject: "foosubject", Predicate: "barpredicate", Version: "0.1.2-draft", @@ -440,7 +447,7 @@ func TestParseType(t *testing.T) { }} for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - obtained, err := ParseType(tc.eventType) + obtained, err := api.ParseType(tc.eventType) if err != nil { if tc.wantError == "" { t.Fatalf("didn't expected it to fail, but it did: %v", err) @@ -459,16 +466,16 @@ func TestParseType(t *testing.T) { } } -func testEventWithVersion(eventVersion string, specVersion string) *FooSubjectBarPredicateEvent { - event, _ := NewFooSubjectBarPredicateEvent() +func testEventWithVersion(eventVersion string, specVersion string) *api.FooSubjectBarPredicateEvent { + event, _ := api.NewFooSubjectBarPredicateEvent() setContext(event, testSubjectId) - event.SetSubjectReferenceField(&Reference{Id: testChangeId}) + event.SetSubjectReferenceField(&api.Reference{Id: testChangeId}) event.SetSubjectPlainField(testValue) event.SetSubjectArtifactId(testArtifactId) - event.SetSubjectObjectField(&FooSubjectBarPredicateSubjectContentObjectField{Required: testChangeId, Optional: testSource}) + event.SetSubjectObjectField(&api.FooSubjectBarPredicateSubjectContentObjectField{Required: testChangeId, Optional: testSource}) err := event.SetCustomData("application/json", testDataJsonUnmarshalled) panicOnError(err) - etype, err := ParseType(event.Context.Type) + etype, err := api.ParseType(event.Context.Type) panicOnError(err) etype.Version = eventVersion event.Context.Version = specVersion @@ -478,16 +485,16 @@ func testEventWithVersion(eventVersion string, specVersion string) *FooSubjectBa func TestNewFromJsonBytes(t *testing.T) { - minorVersion := testEventWithVersion("1.999.0", CDEventsSpecVersion) - patchVersion := testEventWithVersion("1.2.999", CDEventsSpecVersion) - pastPatchVersion := testEventWithVersion("1.2.0", CDEventsSpecVersion) + minorVersion := testEventWithVersion("1.999.0", api.CDEventsSpecVersion) + patchVersion := testEventWithVersion("1.2.999", api.CDEventsSpecVersion) + pastPatchVersion := testEventWithVersion("1.2.0", api.CDEventsSpecVersion) pastSpecVersion := testEventWithVersion("1.2.3", "0.1.0") tests := []struct { testFile string description string wantError string - wantEvent CDEvent + wantEvent api.CDEvent }{{ testFile: "future_event_major_version", description: "A newer major version in the event is backward incompatible and cannot be parsed", @@ -531,7 +538,7 @@ func TestNewFromJsonBytes(t *testing.T) { if err != nil { t.Fatalf("didn't expected it to fail, but it did: %v", err) } - obtained, err := NewFromJsonBytes(eventBytes) + obtained, err := api.NewFromJsonBytes(eventBytes) if err != nil { if tc.wantError == "" { t.Fatalf("didn't expected it to fail, but it did: %v", err) @@ -547,7 +554,7 @@ func TestNewFromJsonBytes(t *testing.T) { t.Fatalf("expected an error, but go none") } else { // Check the event is what is expected - if d := cmp.Diff(tc.wantEvent, obtained, cmpopts.IgnoreFields(Context{}, "Id", "Timestamp")); d != "" { + if d := cmp.Diff(tc.wantEvent, obtained, cmpopts.IgnoreFields(api.Context{}, "Id", "Timestamp")); d != "" { t.Errorf("args: diff(-want,+got):\n%s", d) } } diff --git a/pkg/api/examples_test.go b/pkg/api/examples_v0.3_test.go similarity index 69% rename from pkg/api/examples_test.go rename to pkg/api/examples_v0.3_test.go index 75abd2e..8826851 100644 --- a/pkg/api/examples_test.go +++ b/pkg/api/examples_v0.3_test.go @@ -16,18 +16,19 @@ limitations under the License. SPDX-License-Identifier: Apache-2.0 */ -package api +package api_test import ( "os" "testing" "time" + "github.com/cdevents/sdk-go/pkg/api" "github.com/google/go-cmp/cmp" "github.com/google/uuid" ) -const examplesFolder = "spec/examples" +const examplesFolder = "spec-v0.3/examples" var ( // Examples Data @@ -47,49 +48,49 @@ var ( testEnvironmentId = "test123" testEnvironmentName = "testEnv" testEnvironmentUrl = "https://example.org/testEnv" - testRepoReference = &Reference{ + testRepoReference = &api.Reference{ Id: "TestRepo/TestOrg", Source: "https://example.org"} testIncidentSubjectId = "incident-123" testIncidentSource = "/monitoring/prod1" - testEnvironmentReference = &Reference{ + testEnvironmentReference = &api.Reference{ Id: "prod1", Source: "/iaas/geo1"} - testServiceReference = &Reference{ + testServiceReference = &api.Reference{ Id: "myApp", Source: "/clusterA/namespaceB"} testTestRunId = "myTestCaseRun123" testSignature = "MEYCIQCBT8U5ypDXWCjlNKfzTV4KH516/SK13NZSh8znnSMNkQIhAJ3XiQlc9PM1KyjITcZXHotdMB+J3NGua5T/yshmiPmp" - testTestEnvironment = &Reference{ + testTestEnvironment = &api.Reference{ Id: "dev", Source: "testkube-dev-123"} - testTestCaseStarted = &TestCaseRunStartedSubjectContentTestCase{ + testTestCaseStarted = &api.TestCaseRunStartedSubjectContentTestCase{ Id: "92834723894", Name: "Login Test", Type: "integration", Version: "1.0"} - testTestCaseFinished = &TestCaseRunFinishedSubjectContentTestCase{ + testTestCaseFinished = &api.TestCaseRunFinishedSubjectContentTestCase{ Id: "92834723894", Name: "Login Test", Type: "integration", Version: "1.0"} - testTestCaseQueued = &TestCaseRunQueuedSubjectContentTestCase{ + testTestCaseQueued = &api.TestCaseRunQueuedSubjectContentTestCase{ Id: "92834723894", Name: "Login Test", Type: "integration", Version: "1.0"} - testTestTriggerQueued = &TestCaseRunQueuedSubjectContentTrigger{ + testTestTriggerQueued = &api.TestCaseRunQueuedSubjectContentTrigger{ Type: "schedule"} - testTestTriggerStarted = &TestCaseRunStartedSubjectContentTrigger{ + testTestTriggerStarted = &api.TestCaseRunStartedSubjectContentTrigger{ Type: "schedule"} testTestOutcome = "pass" testTestOutputSubjectId = "testrunreport-12123" testTestOutputSubjectSource = "/event/source/testrunreport-12123" testTestOutputFormat = "video/quicktime" testTestOutputOutputType = "video" - testTestCaseRun = &Reference{Id: testTestRunId, Source: "testkube-dev-123"} + testTestCaseRun = &api.Reference{Id: testTestRunId, Source: "testkube-dev-123"} testTestSuiteRunId = "myTestSuiteRun123" - testTestSuiteStarted = &TestSuiteRunStartedSubjectContentTestSuite{ + testTestSuiteStarted = &api.TestSuiteRunStartedSubjectContentTestSuite{ Id: "92834723894", Name: "Auth TestSuite", Version: "1.0"} - testTestSuiteQueued = &TestSuiteRunQueuedSubjectContentTestSuite{ + testTestSuiteQueued = &api.TestSuiteRunQueuedSubjectContentTestSuite{ Id: "92834723894", Name: "Auth TestSuite", Version: "1.0"} - testTestSuiteFinished = &TestSuiteRunFinishedSubjectContentTestSuite{ + testTestSuiteFinished = &api.TestSuiteRunFinishedSubjectContentTestSuite{ Id: "92834723894", Name: "Auth TestSuite", Version: "1.0"} testTestSuiteOutcome = "fail" testTestSuiteReason = "Host 123.34.23.32 not found" testTestSuiteSeverity = "critical" - testTestSuiteTriggerQueued = &TestSuiteRunQueuedSubjectContentTrigger{Type: "pipeline"} - testTestSuiteTriggerStarted = &TestSuiteRunStartedSubjectContentTrigger{Type: "pipeline"} + testTestSuiteTriggerQueued = &api.TestSuiteRunQueuedSubjectContentTrigger{Type: "pipeline"} + testTestSuiteTriggerStarted = &api.TestSuiteRunStartedSubjectContentTrigger{Type: "pipeline"} examplesConsumed map[string][]byte - examplesProduced map[string]CDEvent + examplesProduced map[string]api.CDEvent err error ) @@ -107,89 +108,89 @@ func init() { } } -func exampleArtifactPackagedEvent(e *ArtifactPackagedEvent) { +func exampleArtifactPackagedEvent(e *api.ArtifactPackagedEventV0_1_1) { // Set example specific fields setContext(e, testArtifactSubjectId) - e.SetSubjectChange(&Reference{Id: testChangeId, Source: testChangeSource}) + e.SetSubjectChange(&api.Reference{Id: testChangeId, Source: testChangeSource}) } -func exampleArtifactPublishedEvent(e *ArtifactPublishedEvent) { +func exampleArtifactPublishedEvent(e *api.ArtifactPublishedEventV0_1_1) { // Set example specific fields setContext(e, testArtifactSubjectId) } -func exampleArtifactSignedEvent(e *ArtifactSignedEvent) { +func exampleArtifactSignedEvent(e *api.ArtifactSignedEventV0_1_0) { // Set example specific fields setContext(e, testArtifactSubjectId) e.SetSubjectSignature(testSignature) } -func exampleBranchCreatedEvent(e *BranchCreatedEvent) { +func exampleBranchCreatedEvent(e *api.BranchCreatedEventV0_1_2) { // Set example specific fields e.SetSubjectRepository(testRepoReference) } -func exampleBranchDeletedEvent(e *BranchDeletedEvent) { +func exampleBranchDeletedEvent(e *api.BranchDeletedEventV0_1_2) { // Set example specific fields e.SetSubjectRepository(testRepoReference) } -func exampleBuildFinishedEvent(e *BuildFinishedEvent) { +func exampleBuildFinishedEvent(e *api.BuildFinishedEventV0_1_1) { // Set example specific fields e.SetSubjectArtifactId(testArtifactId) } -func exampleBuildQueuedEvent(e *BuildQueuedEvent) { +func exampleBuildQueuedEvent(e *api.BuildQueuedEventV0_1_1) { // Set example specific fields } -func exampleBuildStartedEvent(e *BuildStartedEvent) { +func exampleBuildStartedEvent(e *api.BuildStartedEventV0_1_1) { // Set example specific fields } -func exampleChangeAbandonedEvent(e *ChangeAbandonedEvent) { +func exampleChangeAbandonedEvent(e *api.ChangeAbandonedEventV0_1_2) { // Set example specific fields e.SetSubjectRepository(testRepoReference) } -func exampleChangeCreatedEvent(e *ChangeCreatedEvent) { +func exampleChangeCreatedEvent(e *api.ChangeCreatedEventV0_1_2) { // Set example specific fields e.SetSubjectRepository(testRepoReference) } -func exampleChangeMergedEvent(e *ChangeMergedEvent) { +func exampleChangeMergedEvent(e *api.ChangeMergedEventV0_1_2) { // Set example specific fields e.SetSubjectRepository(testRepoReference) } -func exampleChangeReviewedEvent(e *ChangeReviewedEvent) { +func exampleChangeReviewedEvent(e *api.ChangeReviewedEventV0_1_2) { // Set example specific fields e.SetSubjectRepository(testRepoReference) } -func exampleChangeUpdatedEvent(e *ChangeUpdatedEvent) { +func exampleChangeUpdatedEvent(e *api.ChangeUpdatedEventV0_1_2) { // Set example specific fields e.SetSubjectRepository(testRepoReference) } -func exampleEnvironmentCreatedEvent(e *EnvironmentCreatedEvent) { +func exampleEnvironmentCreatedEvent(e *api.EnvironmentCreatedEventV0_1_1) { // Set example specific fields e.SetSubjectName(testEnvironmentName) e.SetSubjectUrl(testEnvironmentUrl) } -func exampleEnvironmentDeletedEvent(e *EnvironmentDeletedEvent) { +func exampleEnvironmentDeletedEvent(e *api.EnvironmentDeletedEventV0_1_1) { // Set example specific fields e.SetSubjectName(testEnvironmentName) } -func exampleEnvironmentModifiedEvent(e *EnvironmentModifiedEvent) { +func exampleEnvironmentModifiedEvent(e *api.EnvironmentModifiedEventV0_1_1) { // Set example specific fields e.SetSubjectName(testEnvironmentName) e.SetSubjectUrl(testEnvironmentUrl) } -func exampleIncidentDetectedEvent(e *IncidentDetectedEvent) { +func exampleIncidentDetectedEvent(e *api.IncidentDetectedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testIncidentSubjectId) e.SetSource(testIncidentSource) @@ -200,7 +201,7 @@ func exampleIncidentDetectedEvent(e *IncidentDetectedEvent) { e.SetSubjectDescription("Response time above threshold of 100ms") } -func exampleIncidentReportedEvent(e *IncidentReportedEvent) { +func exampleIncidentReportedEvent(e *api.IncidentReportedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testIncidentSubjectId) e.SetSource(testIncidentSource) @@ -212,7 +213,7 @@ func exampleIncidentReportedEvent(e *IncidentReportedEvent) { e.SetSubjectTicketURI("https://my-issues.example/incidents/ticket-345") } -func exampleIncidentResolvedEvent(e *IncidentResolvedEvent) { +func exampleIncidentResolvedEvent(e *api.IncidentResolvedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testIncidentSubjectId) e.SetSource(testIncidentSource) @@ -223,7 +224,7 @@ func exampleIncidentResolvedEvent(e *IncidentResolvedEvent) { e.SetSubjectDescription("Response time restored below 100ms") } -func examplePipelineRunFinishedEvent(e *PipelineRunFinishedEvent) { +func examplePipelineRunFinishedEvent(e *api.PipelineRunFinishedEventV0_1_1) { // Set example specific fields e.SetSubjectPipelineName(testPipeline) e.SetSubjectUrl(testSubjecturl) @@ -231,19 +232,19 @@ func examplePipelineRunFinishedEvent(e *PipelineRunFinishedEvent) { e.SetSubjectErrors(testPipelineErrors) } -func examplePipelineRunQueuedEvent(e *PipelineRunQueuedEvent) { +func examplePipelineRunQueuedEvent(e *api.PipelineRunQueuedEventV0_1_1) { // Set example specific fields e.SetSubjectPipelineName(testPipeline) e.SetSubjectUrl(testSubjecturl) } -func examplePipelineRunStartedEvent(e *PipelineRunStartedEvent) { +func examplePipelineRunStartedEvent(e *api.PipelineRunStartedEventV0_1_1) { // Set example specific fields e.SetSubjectPipelineName(testPipeline) e.SetSubjectUrl(testSubjecturl) } -func exampleRepositoryCreatedEvent(e *RepositoryCreatedEvent) { +func exampleRepositoryCreatedEvent(e *api.RepositoryCreatedEventV0_1_1) { // Set example specific fields e.SetSubjectName(testRepo) e.SetSubjectOwner(testOwner) @@ -251,7 +252,7 @@ func exampleRepositoryCreatedEvent(e *RepositoryCreatedEvent) { e.SetSubjectViewUrl(testViewUrl) } -func exampleRepositoryDeletedEvent(e *RepositoryDeletedEvent) { +func exampleRepositoryDeletedEvent(e *api.RepositoryDeletedEventV0_1_1) { // Set example specific fields e.SetSubjectName(testRepo) e.SetSubjectOwner(testOwner) @@ -259,7 +260,7 @@ func exampleRepositoryDeletedEvent(e *RepositoryDeletedEvent) { e.SetSubjectViewUrl(testViewUrl) } -func exampleRepositoryModifiedEvent(e *RepositoryModifiedEvent) { +func exampleRepositoryModifiedEvent(e *api.RepositoryModifiedEventV0_1_1) { // Set example specific fields e.SetSubjectName(testRepo) e.SetSubjectOwner(testOwner) @@ -267,51 +268,51 @@ func exampleRepositoryModifiedEvent(e *RepositoryModifiedEvent) { e.SetSubjectViewUrl(testViewUrl) } -func exampleServiceDeployedEvent(e *ServiceDeployedEvent) { +func exampleServiceDeployedEvent(e *api.ServiceDeployedEventV0_1_1) { // Set example specific fields - e.SetSubjectEnvironment(&Reference{Id: testEnvironmentId}) + e.SetSubjectEnvironment(&api.Reference{Id: testEnvironmentId}) e.SetSubjectArtifactId(testArtifactId) } -func exampleServicePublishedEvent(e *ServicePublishedEvent) { +func exampleServicePublishedEvent(e *api.ServicePublishedEventV0_1_1) { // Set example specific fields - e.SetSubjectEnvironment(&Reference{Id: testEnvironmentId}) + e.SetSubjectEnvironment(&api.Reference{Id: testEnvironmentId}) } -func exampleServiceRemovedEvent(e *ServiceRemovedEvent) { +func exampleServiceRemovedEvent(e *api.ServiceRemovedEventV0_1_1) { // Set example specific fields - e.SetSubjectEnvironment(&Reference{Id: testEnvironmentId}) + e.SetSubjectEnvironment(&api.Reference{Id: testEnvironmentId}) } -func exampleServiceRolledbackEvent(e *ServiceRolledbackEvent) { +func exampleServiceRolledbackEvent(e *api.ServiceRolledbackEventV0_1_1) { // Set example specific fields - e.SetSubjectEnvironment(&Reference{Id: testEnvironmentId}) + e.SetSubjectEnvironment(&api.Reference{Id: testEnvironmentId}) e.SetSubjectArtifactId(testArtifactId) } -func exampleServiceUpgradedEvent(e *ServiceUpgradedEvent) { +func exampleServiceUpgradedEvent(e *api.ServiceUpgradedEventV0_1_1) { // Set example specific fields - e.SetSubjectEnvironment(&Reference{Id: testEnvironmentId}) + e.SetSubjectEnvironment(&api.Reference{Id: testEnvironmentId}) e.SetSubjectArtifactId(testArtifactId) } -func exampleTaskRunFinishedEvent(e *TaskRunFinishedEvent) { +func exampleTaskRunFinishedEvent(e *api.TaskRunFinishedEventV0_1_1) { // Set example specific fields e.SetSubjectTaskName(testTaskName) e.SetSubjectUrl(testSubjecturl) - e.SetSubjectPipelineRun(&Reference{Id: testSubjectId}) + e.SetSubjectPipelineRun(&api.Reference{Id: testSubjectId}) e.SetSubjectOutcome(testTaskOutcome) e.SetSubjectErrors(testTaskRunErrors) } -func exampleTaskRunStartedEvent(e *TaskRunStartedEvent) { +func exampleTaskRunStartedEvent(e *api.TaskRunStartedEventV0_1_1) { // Set example specific fields e.SetSubjectTaskName(testTaskName) e.SetSubjectUrl(testSubjecturl) - e.SetSubjectPipelineRun(&Reference{Id: testSubjectId}) + e.SetSubjectPipelineRun(&api.Reference{Id: testSubjectId}) } -func exampleTestCaseRunFinishedEvent(e *TestCaseRunFinishedEvent) { +func exampleTestCaseRunFinishedEvent(e *api.TestCaseRunFinishedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testTestRunId) e.SetSubjectId(testTestRunId) @@ -320,7 +321,7 @@ func exampleTestCaseRunFinishedEvent(e *TestCaseRunFinishedEvent) { e.SetSubjectOutcome(testTestOutcome) } -func exampleTestCaseRunQueuedEvent(e *TestCaseRunQueuedEvent) { +func exampleTestCaseRunQueuedEvent(e *api.TestCaseRunQueuedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testTestRunId) e.SetSubjectId(testTestRunId) @@ -329,7 +330,7 @@ func exampleTestCaseRunQueuedEvent(e *TestCaseRunQueuedEvent) { e.SetSubjectTrigger(testTestTriggerQueued) } -func exampleTestCaseRunStartedEvent(e *TestCaseRunStartedEvent) { +func exampleTestCaseRunStartedEvent(e *api.TestCaseRunStartedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testTestRunId) e.SetSubjectEnvironment(testTestEnvironment) @@ -337,7 +338,7 @@ func exampleTestCaseRunStartedEvent(e *TestCaseRunStartedEvent) { e.SetSubjectTrigger(testTestTriggerStarted) } -func exampleTestSuiteRunFinishedEvent(e *TestSuiteRunFinishedEvent) { +func exampleTestSuiteRunFinishedEvent(e *api.TestSuiteRunFinishedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testTestSuiteRunId) e.SetSubjectEnvironment(testTestEnvironment) @@ -347,7 +348,7 @@ func exampleTestSuiteRunFinishedEvent(e *TestSuiteRunFinishedEvent) { e.SetSubjectReason(testTestSuiteReason) } -func exampleTestSuiteRunStartedEvent(e *TestSuiteRunStartedEvent) { +func exampleTestSuiteRunStartedEvent(e *api.TestSuiteRunStartedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testTestSuiteRunId) e.SetSubjectEnvironment(testTestEnvironment) @@ -355,7 +356,7 @@ func exampleTestSuiteRunStartedEvent(e *TestSuiteRunStartedEvent) { e.SetSubjectTrigger(testTestSuiteTriggerStarted) } -func exampleTestSuiteRunQueuedEvent(e *TestSuiteRunQueuedEvent) { +func exampleTestSuiteRunQueuedEvent(e *api.TestSuiteRunQueuedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testTestSuiteRunId) e.SetSubjectEnvironment(testTestEnvironment) @@ -363,7 +364,7 @@ func exampleTestSuiteRunQueuedEvent(e *TestSuiteRunQueuedEvent) { e.SetSubjectTrigger(testTestSuiteTriggerQueued) } -func exampleTestOutputPublishedEvent(e *TestOutputPublishedEvent) { +func exampleTestOutputPublishedEvent(e *api.TestOutputPublishedEventV0_1_0) { // Set example specific fields e.SetSubjectId(testTestOutputSubjectId) e.SetSubjectSource(testTestOutputSubjectSource) @@ -377,7 +378,7 @@ func init() { // Load event examples from the spec examplesConsumed = make(map[string][]byte) - for _, event := range CDEventsTypes { + for _, event := range api.CDEventsTypes { short := event.GetType().Short() examplesConsumed[short], err = os.ReadFile(examplesFolder + string(os.PathSeparator) + short + ".json") panicOnError(err) @@ -399,11 +400,11 @@ func TestExamples(t *testing.T) { t.Fatalf("missing produced event for event type: %v", name) } // Check that the produced event is valid - err := Validate(produced) + err := api.Validate(produced) if err != nil { t.Errorf("produced event failed to validate: %v", err) } - consumed, err := NewFromJsonBytes(exampleConsumed) + consumed, err := api.NewFromJsonBytes(exampleConsumed) if err != nil { t.Fatalf("didn't expected it to fail, but it did: %v", err) } diff --git a/pkg/api/factory_test.go b/pkg/api/factory_test.go index c4fb0d6..671145f 100644 --- a/pkg/api/factory_test.go +++ b/pkg/api/factory_test.go @@ -16,7 +16,7 @@ limitations under the License. SPDX-License-Identifier: Apache-2.0 */ -package api +package api_test import ( "encoding/json" @@ -24,12 +24,15 @@ import ( "testing" "time" + "github.com/cdevents/sdk-go/pkg/api" + cdevents "github.com/cdevents/sdk-go/pkg/api" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" "github.com/google/uuid" ) func init() { - // Get the time once t := time.Now() timeNow = func() time.Time { @@ -51,13 +54,17 @@ func testUUID() string { type testNewCDEventType struct { name string eventType string - expectedEvent CDEvent + expectedEvent api.CDEvent } // tests is used in TestNewCDEvents. It's content is // generated in zz_factory_tests.go -var tests []testNewCDEventType -var testContentType = "application/json" +var ( + tests []testNewCDEventType + testContentType = "application/json" + timeNow = time.Now + uuidNewRandom = uuid.NewRandom +) func TestNewCDEvent(t *testing.T) { testDataJsonBytes, err := json.Marshal(testDataJson) @@ -67,11 +74,13 @@ func TestNewCDEvent(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - event, err := NewCDEvent(tc.eventType) + event, err := cdevents.NewCDEvent(tc.eventType) if err != nil { t.Fatalf("didn't expected it to fail, but it did: %v", err) } - if d := cmp.Diff(tc.expectedEvent, event); d != "" { + if d := cmp.Diff(tc.expectedEvent, event, + cmpopts.IgnoreFields(api.Context{}, "Timestamp"), + cmpopts.IgnoreFields(api.Context{}, "Id")); d != "" { t.Errorf("args: diff(-want,+got):\n%s", d) } // Check GetType @@ -120,7 +129,7 @@ func TestNewCDEvent(t *testing.T) { func TestNewCDEventFailed(t *testing.T) { - _, err := NewCDEvent(CDEventType{Subject: "not supported"}.String()) + _, err := cdevents.NewCDEvent(api.CDEventType{Subject: "not supported"}.String()) if err == nil { t.Fatalf("expected it to fail, but it didn't") } diff --git a/pkg/api/spec b/pkg/api/spec-v0.3 similarity index 100% rename from pkg/api/spec rename to pkg/api/spec-v0.3 diff --git a/pkg/api/types_test.go b/pkg/api/types_test.go index abd8df9..2a19282 100644 --- a/pkg/api/types_test.go +++ b/pkg/api/types_test.go @@ -16,12 +16,13 @@ limitations under the License. SPDX-License-Identifier: Apache-2.0 */ -package api +package api_test import ( "encoding/json" "testing" + "github.com/cdevents/sdk-go/pkg/api" "github.com/google/go-cmp/cmp" ) @@ -32,11 +33,11 @@ const ( var ( testObject = testType{TestData: "testValue"} testJsonString []byte - eventWithNonJsonCustomData *ArtifactPackagedEvent - eventWithInterfaceJsonCustomData *ArtifactPackagedEvent - eventWithInterfaceJsonImplicitCustomData *ArtifactPackagedEvent - eventWithJsonCustomData *ArtifactPackagedEvent - eventWithJsonImplicitCustomData *ArtifactPackagedEvent + eventWithNonJsonCustomData *api.ArtifactPackagedEventV0_1_1 + eventWithInterfaceJsonCustomData *api.ArtifactPackagedEventV0_1_1 + eventWithInterfaceJsonImplicitCustomData *api.ArtifactPackagedEventV0_1_1 + eventWithJsonCustomData *api.ArtifactPackagedEventV0_1_1 + eventWithJsonImplicitCustomData *api.ArtifactPackagedEventV0_1_1 ) func init() { @@ -44,23 +45,23 @@ func init() { testJsonString, err = json.Marshal(testObject) panicOnError(err) - eventWithNonJsonCustomData, _ = NewArtifactPackagedEvent() + eventWithNonJsonCustomData, _ = api.NewArtifactPackagedEventV0_1_1() eventWithNonJsonCustomData.CustomDataContentType = "application/xml" eventWithNonJsonCustomData.CustomData = []byte(testXmlString) - eventWithJsonCustomData, _ = NewArtifactPackagedEvent() + eventWithJsonCustomData, _ = api.NewArtifactPackagedEventV0_1_1() eventWithJsonCustomData.CustomDataContentType = "application/json" eventWithJsonCustomData.CustomData = testJsonString - eventWithJsonImplicitCustomData, _ = NewArtifactPackagedEvent() + eventWithJsonImplicitCustomData, _ = api.NewArtifactPackagedEventV0_1_1() eventWithJsonImplicitCustomData.CustomDataContentType = "" eventWithJsonImplicitCustomData.CustomData = testJsonString - eventWithInterfaceJsonCustomData, _ = NewArtifactPackagedEvent() + eventWithInterfaceJsonCustomData, _ = api.NewArtifactPackagedEventV0_1_1() eventWithInterfaceJsonCustomData.CustomDataContentType = "application/json" eventWithInterfaceJsonCustomData.CustomData = testObject - eventWithInterfaceJsonImplicitCustomData, _ = NewArtifactPackagedEvent() + eventWithInterfaceJsonImplicitCustomData, _ = api.NewArtifactPackagedEventV0_1_1() eventWithInterfaceJsonImplicitCustomData.CustomDataContentType = "" eventWithInterfaceJsonImplicitCustomData.CustomData = testObject } @@ -78,7 +79,7 @@ func TestGetCustomDataAsNonJson(t *testing.T) { receiver := &testType{} expectedError := "cannot unmarshal content-type application/xml" - err := GetCustomDataAs(eventWithNonJsonCustomData, receiver) + err := api.GetCustomDataAs(eventWithNonJsonCustomData, receiver) if err == nil { t.Fatalf("expected error, got nil") } @@ -95,7 +96,7 @@ func TestGetCustomDataAsJson(t *testing.T) { tests := []struct { name string - event CDEvent + event api.CDEvent }{{ name: "json bytes", event: eventWithJsonCustomData, @@ -112,7 +113,7 @@ func TestGetCustomDataAsJson(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := GetCustomDataAs(tc.event, receiver) + err := api.GetCustomDataAs(tc.event, receiver) if err != nil { t.Fatalf("did not expect an error, got %v", err) } @@ -131,7 +132,7 @@ func TestGetCustomDataAsJsonInvalidReceiver(t *testing.T) { tests := []struct { name string - event CDEvent + event api.CDEvent }{{ name: "json bytes", event: eventWithJsonCustomData, @@ -148,7 +149,7 @@ func TestGetCustomDataAsJsonInvalidReceiver(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - err := GetCustomDataAs(tc.event, receiver) + err := api.GetCustomDataAs(tc.event, receiver) if err != nil { t.Fatalf("unmarshal failed: %v", err) } @@ -191,7 +192,7 @@ func TestSetCustomData(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - e, _ := NewArtifactPackagedEvent() + e, _ := api.NewArtifactPackagedEventV0_1_1() err := e.SetCustomData(tc.contentType, tc.data) if err != nil { t.Fatalf("expected to set the custom data, but got %v", err) @@ -205,7 +206,7 @@ func TestSetCustomData(t *testing.T) { } func TestSetCustomDataInvalid(t *testing.T) { - e, _ := NewArtifactPackagedEvent() + e, _ := api.NewArtifactPackagedEventV0_1_1() err := e.SetCustomData("application/xml", testType{TestData: "testValue"}) if err == nil { t.Fatalf("did not expect this to work, but it did") @@ -248,7 +249,7 @@ func TestGetCustomData(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - e, _ := NewArtifactPackagedEvent() + e, _ := api.NewArtifactPackagedEventV0_1_1() err := e.SetCustomData(tc.contentType, tc.data) if err != nil { t.Fatalf("expected to set the custom data, but got %v", err) @@ -266,7 +267,7 @@ func TestGetCustomData(t *testing.T) { } func TestGetCustomDataInvalidJson(t *testing.T) { - e, _ := NewArtifactPackagedEvent() + e, _ := api.NewArtifactPackagedEventV0_1_1() data := testType{TestData: "testValue"} dataBytes, err := json.Marshal(data) if err != nil { @@ -283,7 +284,7 @@ func TestGetCustomDataInvalidJson(t *testing.T) { } func TestGetCustomDataXmlNotBytes(t *testing.T) { - e, _ := NewArtifactPackagedEvent() + e, _ := api.NewArtifactPackagedEventV0_1_1() data := testType{TestData: "testValue"} // Set using "application/json", else it won't be allowed err := e.SetCustomData("application/json", data) @@ -330,7 +331,7 @@ func TestGetCustomDataRaw(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - e, _ := NewArtifactPackagedEvent() + e, _ := api.NewArtifactPackagedEventV0_1_1() err := e.SetCustomData(tc.contentType, tc.data) if err != nil { t.Fatalf("expected to set the custom data, but got %v", err) @@ -348,7 +349,7 @@ func TestGetCustomDataRaw(t *testing.T) { } func TestGetCustomDataRawXmlNotBytes(t *testing.T) { - e, _ := NewArtifactPackagedEvent() + e, _ := api.NewArtifactPackagedEventV0_1_1() data := testType{TestData: "testValue"} // Set using "application/json", else it won't be allowed err := e.SetCustomData("application/json", data) @@ -367,12 +368,12 @@ func TestCDEventTypeFromString(t *testing.T) { tests := []struct { name string eventType string - want *CDEventType + want *api.CDEventType wantError bool }{{ name: "parses", eventType: "dev.cdevents.a.b.123.a-da#@#", - want: &CDEventType{ + want: &api.CDEventType{ Subject: "a", Predicate: "b", Version: "123.a-da#@#", @@ -397,7 +398,7 @@ func TestCDEventTypeFromString(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - got, err := CDEventTypeFromString(tc.eventType) + got, err := api.CDEventTypeFromString(tc.eventType) if tc.wantError && err == nil { t.Fatalf("expected error but got none") } diff --git a/pkg/api/zz_artifactpackaged.go b/pkg/api/zz_artifactpackaged_0_1_1.go similarity index 68% rename from pkg/api/zz_artifactpackaged.go rename to pkg/api/zz_artifactpackaged_0_1_1.go index c693eb3..be3b4c5 100644 --- a/pkg/api/zz_artifactpackaged.go +++ b/pkg/api/zz_artifactpackaged_0_1_1.go @@ -28,8 +28,8 @@ import ( var artifactpackagedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/artifact-packaged-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.artifact.packaged.0.1.1"],"default":"dev.cdevents.artifact.packaged.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["artifact"],"default":"artifact"},"content":{"properties":{"change":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object","required":["change"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ArtifactPackaged event v0.1.1 - ArtifactPackagedEventV1 CDEventType = CDEventType{ + // ArtifactPackaged event type v0.1.1 + ArtifactPackagedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "artifact", Predicate: "packaged", Version: "0.1.1", @@ -49,7 +49,7 @@ func (sc ArtifactPackagedSubject) GetSubjectType() SubjectType { return "artifact" } -type ArtifactPackagedEvent struct { +type ArtifactPackagedEventV0_1_1 struct { Context Context `json:"context"` Subject ArtifactPackagedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type ArtifactPackagedEvent struct { // CDEventsReader implementation -func (e ArtifactPackagedEvent) GetType() CDEventType { - return ArtifactPackagedEventV1 +func (e ArtifactPackagedEventV0_1_1) GetType() CDEventType { + return ArtifactPackagedEventTypeV0_1_1 } -func (e ArtifactPackagedEvent) GetVersion() string { +func (e ArtifactPackagedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e ArtifactPackagedEvent) GetId() string { +func (e ArtifactPackagedEventV0_1_1) GetId() string { return e.Context.Id } -func (e ArtifactPackagedEvent) GetSource() string { +func (e ArtifactPackagedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e ArtifactPackagedEvent) GetTimestamp() time.Time { +func (e ArtifactPackagedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ArtifactPackagedEvent) GetSubjectId() string { +func (e ArtifactPackagedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e ArtifactPackagedEvent) GetSubjectSource() string { +func (e ArtifactPackagedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e ArtifactPackagedEvent) GetSubject() Subject { +func (e ArtifactPackagedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e ArtifactPackagedEvent) GetCustomData() (interface{}, error) { +func (e ArtifactPackagedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ArtifactPackagedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ArtifactPackagedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ArtifactPackagedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ArtifactPackagedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ArtifactPackagedEvent) GetCustomDataContentType() string { +func (e ArtifactPackagedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ArtifactPackagedEvent) SetId(id string) { +func (e *ArtifactPackagedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *ArtifactPackagedEvent) SetSource(source string) { +func (e *ArtifactPackagedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *ArtifactPackagedEvent) SetSource(source string) { } } -func (e *ArtifactPackagedEvent) SetTimestamp(timestamp time.Time) { +func (e *ArtifactPackagedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ArtifactPackagedEvent) SetSubjectId(subjectId string) { +func (e *ArtifactPackagedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ArtifactPackagedEvent) SetSubjectSource(subjectSource string) { +func (e *ArtifactPackagedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ArtifactPackagedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ArtifactPackagedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *ArtifactPackagedEvent) SetCustomData(contentType string, data interface return nil } -func (e ArtifactPackagedEvent) GetSchema() (string, string) { +func (e ArtifactPackagedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), artifactpackagedschema } // Set subject custom fields -func (e *ArtifactPackagedEvent) SetSubjectChange(change *Reference) { +func (e *ArtifactPackagedEventV0_1_1) SetSubjectChange(change *Reference) { e.Subject.Content.Change = change } -// New creates a new ArtifactPackagedEvent -func NewArtifactPackagedEvent() (*ArtifactPackagedEvent, error) { - e := &ArtifactPackagedEvent{ +// New creates a new ArtifactPackagedEventV0_1_1 +func NewArtifactPackagedEventV0_1_1() (*ArtifactPackagedEventV0_1_1, error) { + e := &ArtifactPackagedEventV0_1_1{ Context: Context{ - Type: ArtifactPackagedEventV1.String(), + Type: ArtifactPackagedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: ArtifactPackagedSubject{ diff --git a/pkg/api/zz_artifactpublished.go b/pkg/api/zz_artifactpublished_0_1_1.go similarity index 67% rename from pkg/api/zz_artifactpublished.go rename to pkg/api/zz_artifactpublished_0_1_1.go index e5c0e5c..551cd53 100644 --- a/pkg/api/zz_artifactpublished.go +++ b/pkg/api/zz_artifactpublished_0_1_1.go @@ -28,8 +28,8 @@ import ( var artifactpublishedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/artifact-published-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.artifact.published.0.1.1"],"default":"dev.cdevents.artifact.published.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["artifact"],"default":"artifact"},"content":{"properties":{},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ArtifactPublished event v0.1.1 - ArtifactPublishedEventV1 CDEventType = CDEventType{ + // ArtifactPublished event type v0.1.1 + ArtifactPublishedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "artifact", Predicate: "published", Version: "0.1.1", @@ -48,7 +48,7 @@ func (sc ArtifactPublishedSubject) GetSubjectType() SubjectType { return "artifact" } -type ArtifactPublishedEvent struct { +type ArtifactPublishedEventV0_1_1 struct { Context Context `json:"context"` Subject ArtifactPublishedSubject `json:"subject"` CDEventCustomData @@ -56,61 +56,61 @@ type ArtifactPublishedEvent struct { // CDEventsReader implementation -func (e ArtifactPublishedEvent) GetType() CDEventType { - return ArtifactPublishedEventV1 +func (e ArtifactPublishedEventV0_1_1) GetType() CDEventType { + return ArtifactPublishedEventTypeV0_1_1 } -func (e ArtifactPublishedEvent) GetVersion() string { +func (e ArtifactPublishedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e ArtifactPublishedEvent) GetId() string { +func (e ArtifactPublishedEventV0_1_1) GetId() string { return e.Context.Id } -func (e ArtifactPublishedEvent) GetSource() string { +func (e ArtifactPublishedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e ArtifactPublishedEvent) GetTimestamp() time.Time { +func (e ArtifactPublishedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ArtifactPublishedEvent) GetSubjectId() string { +func (e ArtifactPublishedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e ArtifactPublishedEvent) GetSubjectSource() string { +func (e ArtifactPublishedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e ArtifactPublishedEvent) GetSubject() Subject { +func (e ArtifactPublishedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e ArtifactPublishedEvent) GetCustomData() (interface{}, error) { +func (e ArtifactPublishedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ArtifactPublishedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ArtifactPublishedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ArtifactPublishedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ArtifactPublishedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ArtifactPublishedEvent) GetCustomDataContentType() string { +func (e ArtifactPublishedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ArtifactPublishedEvent) SetId(id string) { +func (e *ArtifactPublishedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *ArtifactPublishedEvent) SetSource(source string) { +func (e *ArtifactPublishedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -118,19 +118,19 @@ func (e *ArtifactPublishedEvent) SetSource(source string) { } } -func (e *ArtifactPublishedEvent) SetTimestamp(timestamp time.Time) { +func (e *ArtifactPublishedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ArtifactPublishedEvent) SetSubjectId(subjectId string) { +func (e *ArtifactPublishedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ArtifactPublishedEvent) SetSubjectSource(subjectSource string) { +func (e *ArtifactPublishedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ArtifactPublishedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ArtifactPublishedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -140,18 +140,18 @@ func (e *ArtifactPublishedEvent) SetCustomData(contentType string, data interfac return nil } -func (e ArtifactPublishedEvent) GetSchema() (string, string) { +func (e ArtifactPublishedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), artifactpublishedschema } // Set subject custom fields -// New creates a new ArtifactPublishedEvent -func NewArtifactPublishedEvent() (*ArtifactPublishedEvent, error) { - e := &ArtifactPublishedEvent{ +// New creates a new ArtifactPublishedEventV0_1_1 +func NewArtifactPublishedEventV0_1_1() (*ArtifactPublishedEventV0_1_1, error) { + e := &ArtifactPublishedEventV0_1_1{ Context: Context{ - Type: ArtifactPublishedEventV1.String(), + Type: ArtifactPublishedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: ArtifactPublishedSubject{ diff --git a/pkg/api/zz_artifactsigned.go b/pkg/api/zz_artifactsigned_0_1_0.go similarity index 68% rename from pkg/api/zz_artifactsigned.go rename to pkg/api/zz_artifactsigned_0_1_0.go index c49a09e..c2b9932 100644 --- a/pkg/api/zz_artifactsigned.go +++ b/pkg/api/zz_artifactsigned_0_1_0.go @@ -28,8 +28,8 @@ import ( var artifactsignedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/artifact-signed-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.artifact.signed.0.1.0"],"default":"dev.cdevents.artifact.signed.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["artifact"],"default":"artifact"},"content":{"properties":{"signature":{"type":"string","minLength":1}},"additionalProperties":false,"type":"object","required":["signature"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ArtifactSigned event v0.1.0 - ArtifactSignedEventV1 CDEventType = CDEventType{ + // ArtifactSigned event type v0.1.0 + ArtifactSignedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "artifact", Predicate: "signed", Version: "0.1.0", @@ -49,7 +49,7 @@ func (sc ArtifactSignedSubject) GetSubjectType() SubjectType { return "artifact" } -type ArtifactSignedEvent struct { +type ArtifactSignedEventV0_1_0 struct { Context Context `json:"context"` Subject ArtifactSignedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type ArtifactSignedEvent struct { // CDEventsReader implementation -func (e ArtifactSignedEvent) GetType() CDEventType { - return ArtifactSignedEventV1 +func (e ArtifactSignedEventV0_1_0) GetType() CDEventType { + return ArtifactSignedEventTypeV0_1_0 } -func (e ArtifactSignedEvent) GetVersion() string { +func (e ArtifactSignedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e ArtifactSignedEvent) GetId() string { +func (e ArtifactSignedEventV0_1_0) GetId() string { return e.Context.Id } -func (e ArtifactSignedEvent) GetSource() string { +func (e ArtifactSignedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e ArtifactSignedEvent) GetTimestamp() time.Time { +func (e ArtifactSignedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ArtifactSignedEvent) GetSubjectId() string { +func (e ArtifactSignedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e ArtifactSignedEvent) GetSubjectSource() string { +func (e ArtifactSignedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e ArtifactSignedEvent) GetSubject() Subject { +func (e ArtifactSignedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e ArtifactSignedEvent) GetCustomData() (interface{}, error) { +func (e ArtifactSignedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ArtifactSignedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ArtifactSignedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ArtifactSignedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ArtifactSignedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ArtifactSignedEvent) GetCustomDataContentType() string { +func (e ArtifactSignedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ArtifactSignedEvent) SetId(id string) { +func (e *ArtifactSignedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *ArtifactSignedEvent) SetSource(source string) { +func (e *ArtifactSignedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *ArtifactSignedEvent) SetSource(source string) { } } -func (e *ArtifactSignedEvent) SetTimestamp(timestamp time.Time) { +func (e *ArtifactSignedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ArtifactSignedEvent) SetSubjectId(subjectId string) { +func (e *ArtifactSignedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ArtifactSignedEvent) SetSubjectSource(subjectSource string) { +func (e *ArtifactSignedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ArtifactSignedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ArtifactSignedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *ArtifactSignedEvent) SetCustomData(contentType string, data interface{} return nil } -func (e ArtifactSignedEvent) GetSchema() (string, string) { +func (e ArtifactSignedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), artifactsignedschema } // Set subject custom fields -func (e *ArtifactSignedEvent) SetSubjectSignature(signature string) { +func (e *ArtifactSignedEventV0_1_0) SetSubjectSignature(signature string) { e.Subject.Content.Signature = signature } -// New creates a new ArtifactSignedEvent -func NewArtifactSignedEvent() (*ArtifactSignedEvent, error) { - e := &ArtifactSignedEvent{ +// New creates a new ArtifactSignedEventV0_1_0 +func NewArtifactSignedEventV0_1_0() (*ArtifactSignedEventV0_1_0, error) { + e := &ArtifactSignedEventV0_1_0{ Context: Context{ - Type: ArtifactSignedEventV1.String(), + Type: ArtifactSignedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: ArtifactSignedSubject{ diff --git a/pkg/api/zz_branchcreated.go b/pkg/api/zz_branchcreated_0_1_2.go similarity index 69% rename from pkg/api/zz_branchcreated.go rename to pkg/api/zz_branchcreated_0_1_2.go index 2fd442e..b7b63a0 100644 --- a/pkg/api/zz_branchcreated.go +++ b/pkg/api/zz_branchcreated_0_1_2.go @@ -28,8 +28,8 @@ import ( var branchcreatedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/branch-created-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.branch.created.0.1.2"],"default":"dev.cdevents.branch.created.0.1.2"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["branch"],"default":"branch"},"content":{"properties":{"repository":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // BranchCreated event v0.1.2 - BranchCreatedEventV1 CDEventType = CDEventType{ + // BranchCreated event type v0.1.2 + BranchCreatedEventTypeV0_1_2 CDEventType = CDEventType{ Subject: "branch", Predicate: "created", Version: "0.1.2", @@ -49,7 +49,7 @@ func (sc BranchCreatedSubject) GetSubjectType() SubjectType { return "branch" } -type BranchCreatedEvent struct { +type BranchCreatedEventV0_1_2 struct { Context Context `json:"context"` Subject BranchCreatedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type BranchCreatedEvent struct { // CDEventsReader implementation -func (e BranchCreatedEvent) GetType() CDEventType { - return BranchCreatedEventV1 +func (e BranchCreatedEventV0_1_2) GetType() CDEventType { + return BranchCreatedEventTypeV0_1_2 } -func (e BranchCreatedEvent) GetVersion() string { +func (e BranchCreatedEventV0_1_2) GetVersion() string { return CDEventsSpecVersion } -func (e BranchCreatedEvent) GetId() string { +func (e BranchCreatedEventV0_1_2) GetId() string { return e.Context.Id } -func (e BranchCreatedEvent) GetSource() string { +func (e BranchCreatedEventV0_1_2) GetSource() string { return e.Context.Source } -func (e BranchCreatedEvent) GetTimestamp() time.Time { +func (e BranchCreatedEventV0_1_2) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e BranchCreatedEvent) GetSubjectId() string { +func (e BranchCreatedEventV0_1_2) GetSubjectId() string { return e.Subject.Id } -func (e BranchCreatedEvent) GetSubjectSource() string { +func (e BranchCreatedEventV0_1_2) GetSubjectSource() string { return e.Subject.Source } -func (e BranchCreatedEvent) GetSubject() Subject { +func (e BranchCreatedEventV0_1_2) GetSubject() Subject { return e.Subject } -func (e BranchCreatedEvent) GetCustomData() (interface{}, error) { +func (e BranchCreatedEventV0_1_2) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e BranchCreatedEvent) GetCustomDataAs(receiver interface{}) error { +func (e BranchCreatedEventV0_1_2) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e BranchCreatedEvent) GetCustomDataRaw() ([]byte, error) { +func (e BranchCreatedEventV0_1_2) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e BranchCreatedEvent) GetCustomDataContentType() string { +func (e BranchCreatedEventV0_1_2) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *BranchCreatedEvent) SetId(id string) { +func (e *BranchCreatedEventV0_1_2) SetId(id string) { e.Context.Id = id } -func (e *BranchCreatedEvent) SetSource(source string) { +func (e *BranchCreatedEventV0_1_2) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *BranchCreatedEvent) SetSource(source string) { } } -func (e *BranchCreatedEvent) SetTimestamp(timestamp time.Time) { +func (e *BranchCreatedEventV0_1_2) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *BranchCreatedEvent) SetSubjectId(subjectId string) { +func (e *BranchCreatedEventV0_1_2) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *BranchCreatedEvent) SetSubjectSource(subjectSource string) { +func (e *BranchCreatedEventV0_1_2) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *BranchCreatedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *BranchCreatedEventV0_1_2) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *BranchCreatedEvent) SetCustomData(contentType string, data interface{}) return nil } -func (e BranchCreatedEvent) GetSchema() (string, string) { +func (e BranchCreatedEventV0_1_2) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), branchcreatedschema } // Set subject custom fields -func (e *BranchCreatedEvent) SetSubjectRepository(repository *Reference) { +func (e *BranchCreatedEventV0_1_2) SetSubjectRepository(repository *Reference) { e.Subject.Content.Repository = repository } -// New creates a new BranchCreatedEvent -func NewBranchCreatedEvent() (*BranchCreatedEvent, error) { - e := &BranchCreatedEvent{ +// New creates a new BranchCreatedEventV0_1_2 +func NewBranchCreatedEventV0_1_2() (*BranchCreatedEventV0_1_2, error) { + e := &BranchCreatedEventV0_1_2{ Context: Context{ - Type: BranchCreatedEventV1.String(), + Type: BranchCreatedEventTypeV0_1_2.String(), Version: CDEventsSpecVersion, }, Subject: BranchCreatedSubject{ diff --git a/pkg/api/zz_branchdeleted.go b/pkg/api/zz_branchdeleted_0_1_2.go similarity index 69% rename from pkg/api/zz_branchdeleted.go rename to pkg/api/zz_branchdeleted_0_1_2.go index b12ef4b..67aa527 100644 --- a/pkg/api/zz_branchdeleted.go +++ b/pkg/api/zz_branchdeleted_0_1_2.go @@ -28,8 +28,8 @@ import ( var branchdeletedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/branch-deleted-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.branch.deleted.0.1.2"],"default":"dev.cdevents.branch.deleted.0.1.2"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["branch"],"default":"branch"},"content":{"properties":{"repository":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // BranchDeleted event v0.1.2 - BranchDeletedEventV1 CDEventType = CDEventType{ + // BranchDeleted event type v0.1.2 + BranchDeletedEventTypeV0_1_2 CDEventType = CDEventType{ Subject: "branch", Predicate: "deleted", Version: "0.1.2", @@ -49,7 +49,7 @@ func (sc BranchDeletedSubject) GetSubjectType() SubjectType { return "branch" } -type BranchDeletedEvent struct { +type BranchDeletedEventV0_1_2 struct { Context Context `json:"context"` Subject BranchDeletedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type BranchDeletedEvent struct { // CDEventsReader implementation -func (e BranchDeletedEvent) GetType() CDEventType { - return BranchDeletedEventV1 +func (e BranchDeletedEventV0_1_2) GetType() CDEventType { + return BranchDeletedEventTypeV0_1_2 } -func (e BranchDeletedEvent) GetVersion() string { +func (e BranchDeletedEventV0_1_2) GetVersion() string { return CDEventsSpecVersion } -func (e BranchDeletedEvent) GetId() string { +func (e BranchDeletedEventV0_1_2) GetId() string { return e.Context.Id } -func (e BranchDeletedEvent) GetSource() string { +func (e BranchDeletedEventV0_1_2) GetSource() string { return e.Context.Source } -func (e BranchDeletedEvent) GetTimestamp() time.Time { +func (e BranchDeletedEventV0_1_2) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e BranchDeletedEvent) GetSubjectId() string { +func (e BranchDeletedEventV0_1_2) GetSubjectId() string { return e.Subject.Id } -func (e BranchDeletedEvent) GetSubjectSource() string { +func (e BranchDeletedEventV0_1_2) GetSubjectSource() string { return e.Subject.Source } -func (e BranchDeletedEvent) GetSubject() Subject { +func (e BranchDeletedEventV0_1_2) GetSubject() Subject { return e.Subject } -func (e BranchDeletedEvent) GetCustomData() (interface{}, error) { +func (e BranchDeletedEventV0_1_2) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e BranchDeletedEvent) GetCustomDataAs(receiver interface{}) error { +func (e BranchDeletedEventV0_1_2) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e BranchDeletedEvent) GetCustomDataRaw() ([]byte, error) { +func (e BranchDeletedEventV0_1_2) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e BranchDeletedEvent) GetCustomDataContentType() string { +func (e BranchDeletedEventV0_1_2) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *BranchDeletedEvent) SetId(id string) { +func (e *BranchDeletedEventV0_1_2) SetId(id string) { e.Context.Id = id } -func (e *BranchDeletedEvent) SetSource(source string) { +func (e *BranchDeletedEventV0_1_2) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *BranchDeletedEvent) SetSource(source string) { } } -func (e *BranchDeletedEvent) SetTimestamp(timestamp time.Time) { +func (e *BranchDeletedEventV0_1_2) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *BranchDeletedEvent) SetSubjectId(subjectId string) { +func (e *BranchDeletedEventV0_1_2) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *BranchDeletedEvent) SetSubjectSource(subjectSource string) { +func (e *BranchDeletedEventV0_1_2) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *BranchDeletedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *BranchDeletedEventV0_1_2) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *BranchDeletedEvent) SetCustomData(contentType string, data interface{}) return nil } -func (e BranchDeletedEvent) GetSchema() (string, string) { +func (e BranchDeletedEventV0_1_2) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), branchdeletedschema } // Set subject custom fields -func (e *BranchDeletedEvent) SetSubjectRepository(repository *Reference) { +func (e *BranchDeletedEventV0_1_2) SetSubjectRepository(repository *Reference) { e.Subject.Content.Repository = repository } -// New creates a new BranchDeletedEvent -func NewBranchDeletedEvent() (*BranchDeletedEvent, error) { - e := &BranchDeletedEvent{ +// New creates a new BranchDeletedEventV0_1_2 +func NewBranchDeletedEventV0_1_2() (*BranchDeletedEventV0_1_2, error) { + e := &BranchDeletedEventV0_1_2{ Context: Context{ - Type: BranchDeletedEventV1.String(), + Type: BranchDeletedEventTypeV0_1_2.String(), Version: CDEventsSpecVersion, }, Subject: BranchDeletedSubject{ diff --git a/pkg/api/zz_buildfinished.go b/pkg/api/zz_buildfinished_0_1_1.go similarity index 68% rename from pkg/api/zz_buildfinished.go rename to pkg/api/zz_buildfinished_0_1_1.go index 8f7f6eb..c5b9ae7 100644 --- a/pkg/api/zz_buildfinished.go +++ b/pkg/api/zz_buildfinished_0_1_1.go @@ -28,8 +28,8 @@ import ( var buildfinishedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/build-finished-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.build.finished.0.1.1"],"default":"dev.cdevents.build.finished.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["build"],"default":"build"},"content":{"properties":{"artifactId":{"type":"string"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // BuildFinished event v0.1.1 - BuildFinishedEventV1 CDEventType = CDEventType{ + // BuildFinished event type v0.1.1 + BuildFinishedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "build", Predicate: "finished", Version: "0.1.1", @@ -49,7 +49,7 @@ func (sc BuildFinishedSubject) GetSubjectType() SubjectType { return "build" } -type BuildFinishedEvent struct { +type BuildFinishedEventV0_1_1 struct { Context Context `json:"context"` Subject BuildFinishedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type BuildFinishedEvent struct { // CDEventsReader implementation -func (e BuildFinishedEvent) GetType() CDEventType { - return BuildFinishedEventV1 +func (e BuildFinishedEventV0_1_1) GetType() CDEventType { + return BuildFinishedEventTypeV0_1_1 } -func (e BuildFinishedEvent) GetVersion() string { +func (e BuildFinishedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e BuildFinishedEvent) GetId() string { +func (e BuildFinishedEventV0_1_1) GetId() string { return e.Context.Id } -func (e BuildFinishedEvent) GetSource() string { +func (e BuildFinishedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e BuildFinishedEvent) GetTimestamp() time.Time { +func (e BuildFinishedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e BuildFinishedEvent) GetSubjectId() string { +func (e BuildFinishedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e BuildFinishedEvent) GetSubjectSource() string { +func (e BuildFinishedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e BuildFinishedEvent) GetSubject() Subject { +func (e BuildFinishedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e BuildFinishedEvent) GetCustomData() (interface{}, error) { +func (e BuildFinishedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e BuildFinishedEvent) GetCustomDataAs(receiver interface{}) error { +func (e BuildFinishedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e BuildFinishedEvent) GetCustomDataRaw() ([]byte, error) { +func (e BuildFinishedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e BuildFinishedEvent) GetCustomDataContentType() string { +func (e BuildFinishedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *BuildFinishedEvent) SetId(id string) { +func (e *BuildFinishedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *BuildFinishedEvent) SetSource(source string) { +func (e *BuildFinishedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *BuildFinishedEvent) SetSource(source string) { } } -func (e *BuildFinishedEvent) SetTimestamp(timestamp time.Time) { +func (e *BuildFinishedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *BuildFinishedEvent) SetSubjectId(subjectId string) { +func (e *BuildFinishedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *BuildFinishedEvent) SetSubjectSource(subjectSource string) { +func (e *BuildFinishedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *BuildFinishedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *BuildFinishedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *BuildFinishedEvent) SetCustomData(contentType string, data interface{}) return nil } -func (e BuildFinishedEvent) GetSchema() (string, string) { +func (e BuildFinishedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), buildfinishedschema } // Set subject custom fields -func (e *BuildFinishedEvent) SetSubjectArtifactId(artifactId string) { +func (e *BuildFinishedEventV0_1_1) SetSubjectArtifactId(artifactId string) { e.Subject.Content.ArtifactId = artifactId } -// New creates a new BuildFinishedEvent -func NewBuildFinishedEvent() (*BuildFinishedEvent, error) { - e := &BuildFinishedEvent{ +// New creates a new BuildFinishedEventV0_1_1 +func NewBuildFinishedEventV0_1_1() (*BuildFinishedEventV0_1_1, error) { + e := &BuildFinishedEventV0_1_1{ Context: Context{ - Type: BuildFinishedEventV1.String(), + Type: BuildFinishedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: BuildFinishedSubject{ diff --git a/pkg/api/zz_buildqueued.go b/pkg/api/zz_buildqueued_0_1_1.go similarity index 69% rename from pkg/api/zz_buildqueued.go rename to pkg/api/zz_buildqueued_0_1_1.go index a515078..39a1312 100644 --- a/pkg/api/zz_buildqueued.go +++ b/pkg/api/zz_buildqueued_0_1_1.go @@ -28,8 +28,8 @@ import ( var buildqueuedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/build-queued-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.build.queued.0.1.1"],"default":"dev.cdevents.build.queued.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["build"],"default":"build"},"content":{"properties":{},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // BuildQueued event v0.1.1 - BuildQueuedEventV1 CDEventType = CDEventType{ + // BuildQueued event type v0.1.1 + BuildQueuedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "build", Predicate: "queued", Version: "0.1.1", @@ -48,7 +48,7 @@ func (sc BuildQueuedSubject) GetSubjectType() SubjectType { return "build" } -type BuildQueuedEvent struct { +type BuildQueuedEventV0_1_1 struct { Context Context `json:"context"` Subject BuildQueuedSubject `json:"subject"` CDEventCustomData @@ -56,61 +56,61 @@ type BuildQueuedEvent struct { // CDEventsReader implementation -func (e BuildQueuedEvent) GetType() CDEventType { - return BuildQueuedEventV1 +func (e BuildQueuedEventV0_1_1) GetType() CDEventType { + return BuildQueuedEventTypeV0_1_1 } -func (e BuildQueuedEvent) GetVersion() string { +func (e BuildQueuedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e BuildQueuedEvent) GetId() string { +func (e BuildQueuedEventV0_1_1) GetId() string { return e.Context.Id } -func (e BuildQueuedEvent) GetSource() string { +func (e BuildQueuedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e BuildQueuedEvent) GetTimestamp() time.Time { +func (e BuildQueuedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e BuildQueuedEvent) GetSubjectId() string { +func (e BuildQueuedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e BuildQueuedEvent) GetSubjectSource() string { +func (e BuildQueuedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e BuildQueuedEvent) GetSubject() Subject { +func (e BuildQueuedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e BuildQueuedEvent) GetCustomData() (interface{}, error) { +func (e BuildQueuedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e BuildQueuedEvent) GetCustomDataAs(receiver interface{}) error { +func (e BuildQueuedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e BuildQueuedEvent) GetCustomDataRaw() ([]byte, error) { +func (e BuildQueuedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e BuildQueuedEvent) GetCustomDataContentType() string { +func (e BuildQueuedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *BuildQueuedEvent) SetId(id string) { +func (e *BuildQueuedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *BuildQueuedEvent) SetSource(source string) { +func (e *BuildQueuedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -118,19 +118,19 @@ func (e *BuildQueuedEvent) SetSource(source string) { } } -func (e *BuildQueuedEvent) SetTimestamp(timestamp time.Time) { +func (e *BuildQueuedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *BuildQueuedEvent) SetSubjectId(subjectId string) { +func (e *BuildQueuedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *BuildQueuedEvent) SetSubjectSource(subjectSource string) { +func (e *BuildQueuedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *BuildQueuedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *BuildQueuedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -140,18 +140,18 @@ func (e *BuildQueuedEvent) SetCustomData(contentType string, data interface{}) e return nil } -func (e BuildQueuedEvent) GetSchema() (string, string) { +func (e BuildQueuedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), buildqueuedschema } // Set subject custom fields -// New creates a new BuildQueuedEvent -func NewBuildQueuedEvent() (*BuildQueuedEvent, error) { - e := &BuildQueuedEvent{ +// New creates a new BuildQueuedEventV0_1_1 +func NewBuildQueuedEventV0_1_1() (*BuildQueuedEventV0_1_1, error) { + e := &BuildQueuedEventV0_1_1{ Context: Context{ - Type: BuildQueuedEventV1.String(), + Type: BuildQueuedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: BuildQueuedSubject{ diff --git a/pkg/api/zz_buildstarted.go b/pkg/api/zz_buildstarted_0_1_1.go similarity index 69% rename from pkg/api/zz_buildstarted.go rename to pkg/api/zz_buildstarted_0_1_1.go index eb651c0..e350e24 100644 --- a/pkg/api/zz_buildstarted.go +++ b/pkg/api/zz_buildstarted_0_1_1.go @@ -28,8 +28,8 @@ import ( var buildstartedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/build-started-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.build.started.0.1.1"],"default":"dev.cdevents.build.started.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["build"],"default":"build"},"content":{"properties":{},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // BuildStarted event v0.1.1 - BuildStartedEventV1 CDEventType = CDEventType{ + // BuildStarted event type v0.1.1 + BuildStartedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "build", Predicate: "started", Version: "0.1.1", @@ -48,7 +48,7 @@ func (sc BuildStartedSubject) GetSubjectType() SubjectType { return "build" } -type BuildStartedEvent struct { +type BuildStartedEventV0_1_1 struct { Context Context `json:"context"` Subject BuildStartedSubject `json:"subject"` CDEventCustomData @@ -56,61 +56,61 @@ type BuildStartedEvent struct { // CDEventsReader implementation -func (e BuildStartedEvent) GetType() CDEventType { - return BuildStartedEventV1 +func (e BuildStartedEventV0_1_1) GetType() CDEventType { + return BuildStartedEventTypeV0_1_1 } -func (e BuildStartedEvent) GetVersion() string { +func (e BuildStartedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e BuildStartedEvent) GetId() string { +func (e BuildStartedEventV0_1_1) GetId() string { return e.Context.Id } -func (e BuildStartedEvent) GetSource() string { +func (e BuildStartedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e BuildStartedEvent) GetTimestamp() time.Time { +func (e BuildStartedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e BuildStartedEvent) GetSubjectId() string { +func (e BuildStartedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e BuildStartedEvent) GetSubjectSource() string { +func (e BuildStartedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e BuildStartedEvent) GetSubject() Subject { +func (e BuildStartedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e BuildStartedEvent) GetCustomData() (interface{}, error) { +func (e BuildStartedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e BuildStartedEvent) GetCustomDataAs(receiver interface{}) error { +func (e BuildStartedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e BuildStartedEvent) GetCustomDataRaw() ([]byte, error) { +func (e BuildStartedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e BuildStartedEvent) GetCustomDataContentType() string { +func (e BuildStartedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *BuildStartedEvent) SetId(id string) { +func (e *BuildStartedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *BuildStartedEvent) SetSource(source string) { +func (e *BuildStartedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -118,19 +118,19 @@ func (e *BuildStartedEvent) SetSource(source string) { } } -func (e *BuildStartedEvent) SetTimestamp(timestamp time.Time) { +func (e *BuildStartedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *BuildStartedEvent) SetSubjectId(subjectId string) { +func (e *BuildStartedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *BuildStartedEvent) SetSubjectSource(subjectSource string) { +func (e *BuildStartedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *BuildStartedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *BuildStartedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -140,18 +140,18 @@ func (e *BuildStartedEvent) SetCustomData(contentType string, data interface{}) return nil } -func (e BuildStartedEvent) GetSchema() (string, string) { +func (e BuildStartedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), buildstartedschema } // Set subject custom fields -// New creates a new BuildStartedEvent -func NewBuildStartedEvent() (*BuildStartedEvent, error) { - e := &BuildStartedEvent{ +// New creates a new BuildStartedEventV0_1_1 +func NewBuildStartedEventV0_1_1() (*BuildStartedEventV0_1_1, error) { + e := &BuildStartedEventV0_1_1{ Context: Context{ - Type: BuildStartedEventV1.String(), + Type: BuildStartedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: BuildStartedSubject{ diff --git a/pkg/api/zz_changeabandoned.go b/pkg/api/zz_changeabandoned_0_1_2.go similarity index 69% rename from pkg/api/zz_changeabandoned.go rename to pkg/api/zz_changeabandoned_0_1_2.go index 892416c..240e556 100644 --- a/pkg/api/zz_changeabandoned.go +++ b/pkg/api/zz_changeabandoned_0_1_2.go @@ -28,8 +28,8 @@ import ( var changeabandonedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/change-abandoned-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.change.abandoned.0.1.2"],"default":"dev.cdevents.change.abandoned.0.1.2"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["change"],"default":"change"},"content":{"properties":{"repository":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ChangeAbandoned event v0.1.2 - ChangeAbandonedEventV1 CDEventType = CDEventType{ + // ChangeAbandoned event type v0.1.2 + ChangeAbandonedEventTypeV0_1_2 CDEventType = CDEventType{ Subject: "change", Predicate: "abandoned", Version: "0.1.2", @@ -49,7 +49,7 @@ func (sc ChangeAbandonedSubject) GetSubjectType() SubjectType { return "change" } -type ChangeAbandonedEvent struct { +type ChangeAbandonedEventV0_1_2 struct { Context Context `json:"context"` Subject ChangeAbandonedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type ChangeAbandonedEvent struct { // CDEventsReader implementation -func (e ChangeAbandonedEvent) GetType() CDEventType { - return ChangeAbandonedEventV1 +func (e ChangeAbandonedEventV0_1_2) GetType() CDEventType { + return ChangeAbandonedEventTypeV0_1_2 } -func (e ChangeAbandonedEvent) GetVersion() string { +func (e ChangeAbandonedEventV0_1_2) GetVersion() string { return CDEventsSpecVersion } -func (e ChangeAbandonedEvent) GetId() string { +func (e ChangeAbandonedEventV0_1_2) GetId() string { return e.Context.Id } -func (e ChangeAbandonedEvent) GetSource() string { +func (e ChangeAbandonedEventV0_1_2) GetSource() string { return e.Context.Source } -func (e ChangeAbandonedEvent) GetTimestamp() time.Time { +func (e ChangeAbandonedEventV0_1_2) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ChangeAbandonedEvent) GetSubjectId() string { +func (e ChangeAbandonedEventV0_1_2) GetSubjectId() string { return e.Subject.Id } -func (e ChangeAbandonedEvent) GetSubjectSource() string { +func (e ChangeAbandonedEventV0_1_2) GetSubjectSource() string { return e.Subject.Source } -func (e ChangeAbandonedEvent) GetSubject() Subject { +func (e ChangeAbandonedEventV0_1_2) GetSubject() Subject { return e.Subject } -func (e ChangeAbandonedEvent) GetCustomData() (interface{}, error) { +func (e ChangeAbandonedEventV0_1_2) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ChangeAbandonedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ChangeAbandonedEventV0_1_2) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ChangeAbandonedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ChangeAbandonedEventV0_1_2) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ChangeAbandonedEvent) GetCustomDataContentType() string { +func (e ChangeAbandonedEventV0_1_2) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ChangeAbandonedEvent) SetId(id string) { +func (e *ChangeAbandonedEventV0_1_2) SetId(id string) { e.Context.Id = id } -func (e *ChangeAbandonedEvent) SetSource(source string) { +func (e *ChangeAbandonedEventV0_1_2) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *ChangeAbandonedEvent) SetSource(source string) { } } -func (e *ChangeAbandonedEvent) SetTimestamp(timestamp time.Time) { +func (e *ChangeAbandonedEventV0_1_2) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ChangeAbandonedEvent) SetSubjectId(subjectId string) { +func (e *ChangeAbandonedEventV0_1_2) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ChangeAbandonedEvent) SetSubjectSource(subjectSource string) { +func (e *ChangeAbandonedEventV0_1_2) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ChangeAbandonedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ChangeAbandonedEventV0_1_2) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *ChangeAbandonedEvent) SetCustomData(contentType string, data interface{ return nil } -func (e ChangeAbandonedEvent) GetSchema() (string, string) { +func (e ChangeAbandonedEventV0_1_2) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), changeabandonedschema } // Set subject custom fields -func (e *ChangeAbandonedEvent) SetSubjectRepository(repository *Reference) { +func (e *ChangeAbandonedEventV0_1_2) SetSubjectRepository(repository *Reference) { e.Subject.Content.Repository = repository } -// New creates a new ChangeAbandonedEvent -func NewChangeAbandonedEvent() (*ChangeAbandonedEvent, error) { - e := &ChangeAbandonedEvent{ +// New creates a new ChangeAbandonedEventV0_1_2 +func NewChangeAbandonedEventV0_1_2() (*ChangeAbandonedEventV0_1_2, error) { + e := &ChangeAbandonedEventV0_1_2{ Context: Context{ - Type: ChangeAbandonedEventV1.String(), + Type: ChangeAbandonedEventTypeV0_1_2.String(), Version: CDEventsSpecVersion, }, Subject: ChangeAbandonedSubject{ diff --git a/pkg/api/zz_changecreated.go b/pkg/api/zz_changecreated_0_1_2.go similarity index 69% rename from pkg/api/zz_changecreated.go rename to pkg/api/zz_changecreated_0_1_2.go index fd2c656..158a437 100644 --- a/pkg/api/zz_changecreated.go +++ b/pkg/api/zz_changecreated_0_1_2.go @@ -28,8 +28,8 @@ import ( var changecreatedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/change-created-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.change.created.0.1.2"],"default":"dev.cdevents.change.created.0.1.2"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["change"],"default":"change"},"content":{"properties":{"repository":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ChangeCreated event v0.1.2 - ChangeCreatedEventV1 CDEventType = CDEventType{ + // ChangeCreated event type v0.1.2 + ChangeCreatedEventTypeV0_1_2 CDEventType = CDEventType{ Subject: "change", Predicate: "created", Version: "0.1.2", @@ -49,7 +49,7 @@ func (sc ChangeCreatedSubject) GetSubjectType() SubjectType { return "change" } -type ChangeCreatedEvent struct { +type ChangeCreatedEventV0_1_2 struct { Context Context `json:"context"` Subject ChangeCreatedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type ChangeCreatedEvent struct { // CDEventsReader implementation -func (e ChangeCreatedEvent) GetType() CDEventType { - return ChangeCreatedEventV1 +func (e ChangeCreatedEventV0_1_2) GetType() CDEventType { + return ChangeCreatedEventTypeV0_1_2 } -func (e ChangeCreatedEvent) GetVersion() string { +func (e ChangeCreatedEventV0_1_2) GetVersion() string { return CDEventsSpecVersion } -func (e ChangeCreatedEvent) GetId() string { +func (e ChangeCreatedEventV0_1_2) GetId() string { return e.Context.Id } -func (e ChangeCreatedEvent) GetSource() string { +func (e ChangeCreatedEventV0_1_2) GetSource() string { return e.Context.Source } -func (e ChangeCreatedEvent) GetTimestamp() time.Time { +func (e ChangeCreatedEventV0_1_2) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ChangeCreatedEvent) GetSubjectId() string { +func (e ChangeCreatedEventV0_1_2) GetSubjectId() string { return e.Subject.Id } -func (e ChangeCreatedEvent) GetSubjectSource() string { +func (e ChangeCreatedEventV0_1_2) GetSubjectSource() string { return e.Subject.Source } -func (e ChangeCreatedEvent) GetSubject() Subject { +func (e ChangeCreatedEventV0_1_2) GetSubject() Subject { return e.Subject } -func (e ChangeCreatedEvent) GetCustomData() (interface{}, error) { +func (e ChangeCreatedEventV0_1_2) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ChangeCreatedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ChangeCreatedEventV0_1_2) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ChangeCreatedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ChangeCreatedEventV0_1_2) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ChangeCreatedEvent) GetCustomDataContentType() string { +func (e ChangeCreatedEventV0_1_2) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ChangeCreatedEvent) SetId(id string) { +func (e *ChangeCreatedEventV0_1_2) SetId(id string) { e.Context.Id = id } -func (e *ChangeCreatedEvent) SetSource(source string) { +func (e *ChangeCreatedEventV0_1_2) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *ChangeCreatedEvent) SetSource(source string) { } } -func (e *ChangeCreatedEvent) SetTimestamp(timestamp time.Time) { +func (e *ChangeCreatedEventV0_1_2) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ChangeCreatedEvent) SetSubjectId(subjectId string) { +func (e *ChangeCreatedEventV0_1_2) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ChangeCreatedEvent) SetSubjectSource(subjectSource string) { +func (e *ChangeCreatedEventV0_1_2) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ChangeCreatedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ChangeCreatedEventV0_1_2) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *ChangeCreatedEvent) SetCustomData(contentType string, data interface{}) return nil } -func (e ChangeCreatedEvent) GetSchema() (string, string) { +func (e ChangeCreatedEventV0_1_2) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), changecreatedschema } // Set subject custom fields -func (e *ChangeCreatedEvent) SetSubjectRepository(repository *Reference) { +func (e *ChangeCreatedEventV0_1_2) SetSubjectRepository(repository *Reference) { e.Subject.Content.Repository = repository } -// New creates a new ChangeCreatedEvent -func NewChangeCreatedEvent() (*ChangeCreatedEvent, error) { - e := &ChangeCreatedEvent{ +// New creates a new ChangeCreatedEventV0_1_2 +func NewChangeCreatedEventV0_1_2() (*ChangeCreatedEventV0_1_2, error) { + e := &ChangeCreatedEventV0_1_2{ Context: Context{ - Type: ChangeCreatedEventV1.String(), + Type: ChangeCreatedEventTypeV0_1_2.String(), Version: CDEventsSpecVersion, }, Subject: ChangeCreatedSubject{ diff --git a/pkg/api/zz_changemerged.go b/pkg/api/zz_changemerged_0_1_2.go similarity index 69% rename from pkg/api/zz_changemerged.go rename to pkg/api/zz_changemerged_0_1_2.go index f893840..b248552 100644 --- a/pkg/api/zz_changemerged.go +++ b/pkg/api/zz_changemerged_0_1_2.go @@ -28,8 +28,8 @@ import ( var changemergedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/change-merged-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.change.merged.0.1.2"],"default":"dev.cdevents.change.merged.0.1.2"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["change"],"default":"change"},"content":{"properties":{"repository":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ChangeMerged event v0.1.2 - ChangeMergedEventV1 CDEventType = CDEventType{ + // ChangeMerged event type v0.1.2 + ChangeMergedEventTypeV0_1_2 CDEventType = CDEventType{ Subject: "change", Predicate: "merged", Version: "0.1.2", @@ -49,7 +49,7 @@ func (sc ChangeMergedSubject) GetSubjectType() SubjectType { return "change" } -type ChangeMergedEvent struct { +type ChangeMergedEventV0_1_2 struct { Context Context `json:"context"` Subject ChangeMergedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type ChangeMergedEvent struct { // CDEventsReader implementation -func (e ChangeMergedEvent) GetType() CDEventType { - return ChangeMergedEventV1 +func (e ChangeMergedEventV0_1_2) GetType() CDEventType { + return ChangeMergedEventTypeV0_1_2 } -func (e ChangeMergedEvent) GetVersion() string { +func (e ChangeMergedEventV0_1_2) GetVersion() string { return CDEventsSpecVersion } -func (e ChangeMergedEvent) GetId() string { +func (e ChangeMergedEventV0_1_2) GetId() string { return e.Context.Id } -func (e ChangeMergedEvent) GetSource() string { +func (e ChangeMergedEventV0_1_2) GetSource() string { return e.Context.Source } -func (e ChangeMergedEvent) GetTimestamp() time.Time { +func (e ChangeMergedEventV0_1_2) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ChangeMergedEvent) GetSubjectId() string { +func (e ChangeMergedEventV0_1_2) GetSubjectId() string { return e.Subject.Id } -func (e ChangeMergedEvent) GetSubjectSource() string { +func (e ChangeMergedEventV0_1_2) GetSubjectSource() string { return e.Subject.Source } -func (e ChangeMergedEvent) GetSubject() Subject { +func (e ChangeMergedEventV0_1_2) GetSubject() Subject { return e.Subject } -func (e ChangeMergedEvent) GetCustomData() (interface{}, error) { +func (e ChangeMergedEventV0_1_2) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ChangeMergedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ChangeMergedEventV0_1_2) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ChangeMergedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ChangeMergedEventV0_1_2) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ChangeMergedEvent) GetCustomDataContentType() string { +func (e ChangeMergedEventV0_1_2) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ChangeMergedEvent) SetId(id string) { +func (e *ChangeMergedEventV0_1_2) SetId(id string) { e.Context.Id = id } -func (e *ChangeMergedEvent) SetSource(source string) { +func (e *ChangeMergedEventV0_1_2) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *ChangeMergedEvent) SetSource(source string) { } } -func (e *ChangeMergedEvent) SetTimestamp(timestamp time.Time) { +func (e *ChangeMergedEventV0_1_2) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ChangeMergedEvent) SetSubjectId(subjectId string) { +func (e *ChangeMergedEventV0_1_2) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ChangeMergedEvent) SetSubjectSource(subjectSource string) { +func (e *ChangeMergedEventV0_1_2) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ChangeMergedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ChangeMergedEventV0_1_2) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *ChangeMergedEvent) SetCustomData(contentType string, data interface{}) return nil } -func (e ChangeMergedEvent) GetSchema() (string, string) { +func (e ChangeMergedEventV0_1_2) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), changemergedschema } // Set subject custom fields -func (e *ChangeMergedEvent) SetSubjectRepository(repository *Reference) { +func (e *ChangeMergedEventV0_1_2) SetSubjectRepository(repository *Reference) { e.Subject.Content.Repository = repository } -// New creates a new ChangeMergedEvent -func NewChangeMergedEvent() (*ChangeMergedEvent, error) { - e := &ChangeMergedEvent{ +// New creates a new ChangeMergedEventV0_1_2 +func NewChangeMergedEventV0_1_2() (*ChangeMergedEventV0_1_2, error) { + e := &ChangeMergedEventV0_1_2{ Context: Context{ - Type: ChangeMergedEventV1.String(), + Type: ChangeMergedEventTypeV0_1_2.String(), Version: CDEventsSpecVersion, }, Subject: ChangeMergedSubject{ diff --git a/pkg/api/zz_changereviewed.go b/pkg/api/zz_changereviewed_0_1_2.go similarity index 69% rename from pkg/api/zz_changereviewed.go rename to pkg/api/zz_changereviewed_0_1_2.go index b570a7d..73bf01f 100644 --- a/pkg/api/zz_changereviewed.go +++ b/pkg/api/zz_changereviewed_0_1_2.go @@ -28,8 +28,8 @@ import ( var changereviewedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/change-reviewed-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.change.reviewed.0.1.2"],"default":"dev.cdevents.change.reviewed.0.1.2"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["change"],"default":"change"},"content":{"properties":{"repository":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ChangeReviewed event v0.1.2 - ChangeReviewedEventV1 CDEventType = CDEventType{ + // ChangeReviewed event type v0.1.2 + ChangeReviewedEventTypeV0_1_2 CDEventType = CDEventType{ Subject: "change", Predicate: "reviewed", Version: "0.1.2", @@ -49,7 +49,7 @@ func (sc ChangeReviewedSubject) GetSubjectType() SubjectType { return "change" } -type ChangeReviewedEvent struct { +type ChangeReviewedEventV0_1_2 struct { Context Context `json:"context"` Subject ChangeReviewedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type ChangeReviewedEvent struct { // CDEventsReader implementation -func (e ChangeReviewedEvent) GetType() CDEventType { - return ChangeReviewedEventV1 +func (e ChangeReviewedEventV0_1_2) GetType() CDEventType { + return ChangeReviewedEventTypeV0_1_2 } -func (e ChangeReviewedEvent) GetVersion() string { +func (e ChangeReviewedEventV0_1_2) GetVersion() string { return CDEventsSpecVersion } -func (e ChangeReviewedEvent) GetId() string { +func (e ChangeReviewedEventV0_1_2) GetId() string { return e.Context.Id } -func (e ChangeReviewedEvent) GetSource() string { +func (e ChangeReviewedEventV0_1_2) GetSource() string { return e.Context.Source } -func (e ChangeReviewedEvent) GetTimestamp() time.Time { +func (e ChangeReviewedEventV0_1_2) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ChangeReviewedEvent) GetSubjectId() string { +func (e ChangeReviewedEventV0_1_2) GetSubjectId() string { return e.Subject.Id } -func (e ChangeReviewedEvent) GetSubjectSource() string { +func (e ChangeReviewedEventV0_1_2) GetSubjectSource() string { return e.Subject.Source } -func (e ChangeReviewedEvent) GetSubject() Subject { +func (e ChangeReviewedEventV0_1_2) GetSubject() Subject { return e.Subject } -func (e ChangeReviewedEvent) GetCustomData() (interface{}, error) { +func (e ChangeReviewedEventV0_1_2) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ChangeReviewedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ChangeReviewedEventV0_1_2) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ChangeReviewedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ChangeReviewedEventV0_1_2) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ChangeReviewedEvent) GetCustomDataContentType() string { +func (e ChangeReviewedEventV0_1_2) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ChangeReviewedEvent) SetId(id string) { +func (e *ChangeReviewedEventV0_1_2) SetId(id string) { e.Context.Id = id } -func (e *ChangeReviewedEvent) SetSource(source string) { +func (e *ChangeReviewedEventV0_1_2) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *ChangeReviewedEvent) SetSource(source string) { } } -func (e *ChangeReviewedEvent) SetTimestamp(timestamp time.Time) { +func (e *ChangeReviewedEventV0_1_2) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ChangeReviewedEvent) SetSubjectId(subjectId string) { +func (e *ChangeReviewedEventV0_1_2) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ChangeReviewedEvent) SetSubjectSource(subjectSource string) { +func (e *ChangeReviewedEventV0_1_2) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ChangeReviewedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ChangeReviewedEventV0_1_2) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *ChangeReviewedEvent) SetCustomData(contentType string, data interface{} return nil } -func (e ChangeReviewedEvent) GetSchema() (string, string) { +func (e ChangeReviewedEventV0_1_2) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), changereviewedschema } // Set subject custom fields -func (e *ChangeReviewedEvent) SetSubjectRepository(repository *Reference) { +func (e *ChangeReviewedEventV0_1_2) SetSubjectRepository(repository *Reference) { e.Subject.Content.Repository = repository } -// New creates a new ChangeReviewedEvent -func NewChangeReviewedEvent() (*ChangeReviewedEvent, error) { - e := &ChangeReviewedEvent{ +// New creates a new ChangeReviewedEventV0_1_2 +func NewChangeReviewedEventV0_1_2() (*ChangeReviewedEventV0_1_2, error) { + e := &ChangeReviewedEventV0_1_2{ Context: Context{ - Type: ChangeReviewedEventV1.String(), + Type: ChangeReviewedEventTypeV0_1_2.String(), Version: CDEventsSpecVersion, }, Subject: ChangeReviewedSubject{ diff --git a/pkg/api/zz_changeupdated.go b/pkg/api/zz_changeupdated_0_1_2.go similarity index 69% rename from pkg/api/zz_changeupdated.go rename to pkg/api/zz_changeupdated_0_1_2.go index 0402fd4..04c91e7 100644 --- a/pkg/api/zz_changeupdated.go +++ b/pkg/api/zz_changeupdated_0_1_2.go @@ -28,8 +28,8 @@ import ( var changeupdatedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/change-updated-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.change.updated.0.1.2"],"default":"dev.cdevents.change.updated.0.1.2"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["change"],"default":"change"},"content":{"properties":{"repository":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ChangeUpdated event v0.1.2 - ChangeUpdatedEventV1 CDEventType = CDEventType{ + // ChangeUpdated event type v0.1.2 + ChangeUpdatedEventTypeV0_1_2 CDEventType = CDEventType{ Subject: "change", Predicate: "updated", Version: "0.1.2", @@ -49,7 +49,7 @@ func (sc ChangeUpdatedSubject) GetSubjectType() SubjectType { return "change" } -type ChangeUpdatedEvent struct { +type ChangeUpdatedEventV0_1_2 struct { Context Context `json:"context"` Subject ChangeUpdatedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type ChangeUpdatedEvent struct { // CDEventsReader implementation -func (e ChangeUpdatedEvent) GetType() CDEventType { - return ChangeUpdatedEventV1 +func (e ChangeUpdatedEventV0_1_2) GetType() CDEventType { + return ChangeUpdatedEventTypeV0_1_2 } -func (e ChangeUpdatedEvent) GetVersion() string { +func (e ChangeUpdatedEventV0_1_2) GetVersion() string { return CDEventsSpecVersion } -func (e ChangeUpdatedEvent) GetId() string { +func (e ChangeUpdatedEventV0_1_2) GetId() string { return e.Context.Id } -func (e ChangeUpdatedEvent) GetSource() string { +func (e ChangeUpdatedEventV0_1_2) GetSource() string { return e.Context.Source } -func (e ChangeUpdatedEvent) GetTimestamp() time.Time { +func (e ChangeUpdatedEventV0_1_2) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ChangeUpdatedEvent) GetSubjectId() string { +func (e ChangeUpdatedEventV0_1_2) GetSubjectId() string { return e.Subject.Id } -func (e ChangeUpdatedEvent) GetSubjectSource() string { +func (e ChangeUpdatedEventV0_1_2) GetSubjectSource() string { return e.Subject.Source } -func (e ChangeUpdatedEvent) GetSubject() Subject { +func (e ChangeUpdatedEventV0_1_2) GetSubject() Subject { return e.Subject } -func (e ChangeUpdatedEvent) GetCustomData() (interface{}, error) { +func (e ChangeUpdatedEventV0_1_2) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ChangeUpdatedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ChangeUpdatedEventV0_1_2) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ChangeUpdatedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ChangeUpdatedEventV0_1_2) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ChangeUpdatedEvent) GetCustomDataContentType() string { +func (e ChangeUpdatedEventV0_1_2) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ChangeUpdatedEvent) SetId(id string) { +func (e *ChangeUpdatedEventV0_1_2) SetId(id string) { e.Context.Id = id } -func (e *ChangeUpdatedEvent) SetSource(source string) { +func (e *ChangeUpdatedEventV0_1_2) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *ChangeUpdatedEvent) SetSource(source string) { } } -func (e *ChangeUpdatedEvent) SetTimestamp(timestamp time.Time) { +func (e *ChangeUpdatedEventV0_1_2) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ChangeUpdatedEvent) SetSubjectId(subjectId string) { +func (e *ChangeUpdatedEventV0_1_2) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ChangeUpdatedEvent) SetSubjectSource(subjectSource string) { +func (e *ChangeUpdatedEventV0_1_2) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ChangeUpdatedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ChangeUpdatedEventV0_1_2) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *ChangeUpdatedEvent) SetCustomData(contentType string, data interface{}) return nil } -func (e ChangeUpdatedEvent) GetSchema() (string, string) { +func (e ChangeUpdatedEventV0_1_2) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), changeupdatedschema } // Set subject custom fields -func (e *ChangeUpdatedEvent) SetSubjectRepository(repository *Reference) { +func (e *ChangeUpdatedEventV0_1_2) SetSubjectRepository(repository *Reference) { e.Subject.Content.Repository = repository } -// New creates a new ChangeUpdatedEvent -func NewChangeUpdatedEvent() (*ChangeUpdatedEvent, error) { - e := &ChangeUpdatedEvent{ +// New creates a new ChangeUpdatedEventV0_1_2 +func NewChangeUpdatedEventV0_1_2() (*ChangeUpdatedEventV0_1_2, error) { + e := &ChangeUpdatedEventV0_1_2{ Context: Context{ - Type: ChangeUpdatedEventV1.String(), + Type: ChangeUpdatedEventTypeV0_1_2.String(), Version: CDEventsSpecVersion, }, Subject: ChangeUpdatedSubject{ diff --git a/pkg/api/zz_environmentcreated.go b/pkg/api/zz_environmentcreated_0_1_1.go similarity index 67% rename from pkg/api/zz_environmentcreated.go rename to pkg/api/zz_environmentcreated_0_1_1.go index 33715b5..1d7218e 100644 --- a/pkg/api/zz_environmentcreated.go +++ b/pkg/api/zz_environmentcreated_0_1_1.go @@ -28,8 +28,8 @@ import ( var environmentcreatedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/environment-created-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.environment.created.0.1.1"],"default":"dev.cdevents.environment.created.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["environment"],"default":"environment"},"content":{"properties":{"name":{"type":"string"},"url":{"type":"string"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // EnvironmentCreated event v0.1.1 - EnvironmentCreatedEventV1 CDEventType = CDEventType{ + // EnvironmentCreated event type v0.1.1 + EnvironmentCreatedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "environment", Predicate: "created", Version: "0.1.1", @@ -51,7 +51,7 @@ func (sc EnvironmentCreatedSubject) GetSubjectType() SubjectType { return "environment" } -type EnvironmentCreatedEvent struct { +type EnvironmentCreatedEventV0_1_1 struct { Context Context `json:"context"` Subject EnvironmentCreatedSubject `json:"subject"` CDEventCustomData @@ -59,61 +59,61 @@ type EnvironmentCreatedEvent struct { // CDEventsReader implementation -func (e EnvironmentCreatedEvent) GetType() CDEventType { - return EnvironmentCreatedEventV1 +func (e EnvironmentCreatedEventV0_1_1) GetType() CDEventType { + return EnvironmentCreatedEventTypeV0_1_1 } -func (e EnvironmentCreatedEvent) GetVersion() string { +func (e EnvironmentCreatedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e EnvironmentCreatedEvent) GetId() string { +func (e EnvironmentCreatedEventV0_1_1) GetId() string { return e.Context.Id } -func (e EnvironmentCreatedEvent) GetSource() string { +func (e EnvironmentCreatedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e EnvironmentCreatedEvent) GetTimestamp() time.Time { +func (e EnvironmentCreatedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e EnvironmentCreatedEvent) GetSubjectId() string { +func (e EnvironmentCreatedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e EnvironmentCreatedEvent) GetSubjectSource() string { +func (e EnvironmentCreatedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e EnvironmentCreatedEvent) GetSubject() Subject { +func (e EnvironmentCreatedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e EnvironmentCreatedEvent) GetCustomData() (interface{}, error) { +func (e EnvironmentCreatedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e EnvironmentCreatedEvent) GetCustomDataAs(receiver interface{}) error { +func (e EnvironmentCreatedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e EnvironmentCreatedEvent) GetCustomDataRaw() ([]byte, error) { +func (e EnvironmentCreatedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e EnvironmentCreatedEvent) GetCustomDataContentType() string { +func (e EnvironmentCreatedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *EnvironmentCreatedEvent) SetId(id string) { +func (e *EnvironmentCreatedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *EnvironmentCreatedEvent) SetSource(source string) { +func (e *EnvironmentCreatedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -121,19 +121,19 @@ func (e *EnvironmentCreatedEvent) SetSource(source string) { } } -func (e *EnvironmentCreatedEvent) SetTimestamp(timestamp time.Time) { +func (e *EnvironmentCreatedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *EnvironmentCreatedEvent) SetSubjectId(subjectId string) { +func (e *EnvironmentCreatedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *EnvironmentCreatedEvent) SetSubjectSource(subjectSource string) { +func (e *EnvironmentCreatedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *EnvironmentCreatedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *EnvironmentCreatedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -143,26 +143,26 @@ func (e *EnvironmentCreatedEvent) SetCustomData(contentType string, data interfa return nil } -func (e EnvironmentCreatedEvent) GetSchema() (string, string) { +func (e EnvironmentCreatedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), environmentcreatedschema } // Set subject custom fields -func (e *EnvironmentCreatedEvent) SetSubjectName(name string) { +func (e *EnvironmentCreatedEventV0_1_1) SetSubjectName(name string) { e.Subject.Content.Name = name } -func (e *EnvironmentCreatedEvent) SetSubjectUrl(url string) { +func (e *EnvironmentCreatedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -// New creates a new EnvironmentCreatedEvent -func NewEnvironmentCreatedEvent() (*EnvironmentCreatedEvent, error) { - e := &EnvironmentCreatedEvent{ +// New creates a new EnvironmentCreatedEventV0_1_1 +func NewEnvironmentCreatedEventV0_1_1() (*EnvironmentCreatedEventV0_1_1, error) { + e := &EnvironmentCreatedEventV0_1_1{ Context: Context{ - Type: EnvironmentCreatedEventV1.String(), + Type: EnvironmentCreatedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: EnvironmentCreatedSubject{ diff --git a/pkg/api/zz_environmentdeleted.go b/pkg/api/zz_environmentdeleted_0_1_1.go similarity index 67% rename from pkg/api/zz_environmentdeleted.go rename to pkg/api/zz_environmentdeleted_0_1_1.go index eaeb28f..3bbbd93 100644 --- a/pkg/api/zz_environmentdeleted.go +++ b/pkg/api/zz_environmentdeleted_0_1_1.go @@ -28,8 +28,8 @@ import ( var environmentdeletedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/environment-deleted-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.environment.deleted.0.1.1"],"default":"dev.cdevents.environment.deleted.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["environment"],"default":"environment"},"content":{"properties":{"name":{"type":"string"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // EnvironmentDeleted event v0.1.1 - EnvironmentDeletedEventV1 CDEventType = CDEventType{ + // EnvironmentDeleted event type v0.1.1 + EnvironmentDeletedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "environment", Predicate: "deleted", Version: "0.1.1", @@ -49,7 +49,7 @@ func (sc EnvironmentDeletedSubject) GetSubjectType() SubjectType { return "environment" } -type EnvironmentDeletedEvent struct { +type EnvironmentDeletedEventV0_1_1 struct { Context Context `json:"context"` Subject EnvironmentDeletedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type EnvironmentDeletedEvent struct { // CDEventsReader implementation -func (e EnvironmentDeletedEvent) GetType() CDEventType { - return EnvironmentDeletedEventV1 +func (e EnvironmentDeletedEventV0_1_1) GetType() CDEventType { + return EnvironmentDeletedEventTypeV0_1_1 } -func (e EnvironmentDeletedEvent) GetVersion() string { +func (e EnvironmentDeletedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e EnvironmentDeletedEvent) GetId() string { +func (e EnvironmentDeletedEventV0_1_1) GetId() string { return e.Context.Id } -func (e EnvironmentDeletedEvent) GetSource() string { +func (e EnvironmentDeletedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e EnvironmentDeletedEvent) GetTimestamp() time.Time { +func (e EnvironmentDeletedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e EnvironmentDeletedEvent) GetSubjectId() string { +func (e EnvironmentDeletedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e EnvironmentDeletedEvent) GetSubjectSource() string { +func (e EnvironmentDeletedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e EnvironmentDeletedEvent) GetSubject() Subject { +func (e EnvironmentDeletedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e EnvironmentDeletedEvent) GetCustomData() (interface{}, error) { +func (e EnvironmentDeletedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e EnvironmentDeletedEvent) GetCustomDataAs(receiver interface{}) error { +func (e EnvironmentDeletedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e EnvironmentDeletedEvent) GetCustomDataRaw() ([]byte, error) { +func (e EnvironmentDeletedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e EnvironmentDeletedEvent) GetCustomDataContentType() string { +func (e EnvironmentDeletedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *EnvironmentDeletedEvent) SetId(id string) { +func (e *EnvironmentDeletedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *EnvironmentDeletedEvent) SetSource(source string) { +func (e *EnvironmentDeletedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *EnvironmentDeletedEvent) SetSource(source string) { } } -func (e *EnvironmentDeletedEvent) SetTimestamp(timestamp time.Time) { +func (e *EnvironmentDeletedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *EnvironmentDeletedEvent) SetSubjectId(subjectId string) { +func (e *EnvironmentDeletedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *EnvironmentDeletedEvent) SetSubjectSource(subjectSource string) { +func (e *EnvironmentDeletedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *EnvironmentDeletedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *EnvironmentDeletedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *EnvironmentDeletedEvent) SetCustomData(contentType string, data interfa return nil } -func (e EnvironmentDeletedEvent) GetSchema() (string, string) { +func (e EnvironmentDeletedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), environmentdeletedschema } // Set subject custom fields -func (e *EnvironmentDeletedEvent) SetSubjectName(name string) { +func (e *EnvironmentDeletedEventV0_1_1) SetSubjectName(name string) { e.Subject.Content.Name = name } -// New creates a new EnvironmentDeletedEvent -func NewEnvironmentDeletedEvent() (*EnvironmentDeletedEvent, error) { - e := &EnvironmentDeletedEvent{ +// New creates a new EnvironmentDeletedEventV0_1_1 +func NewEnvironmentDeletedEventV0_1_1() (*EnvironmentDeletedEventV0_1_1, error) { + e := &EnvironmentDeletedEventV0_1_1{ Context: Context{ - Type: EnvironmentDeletedEventV1.String(), + Type: EnvironmentDeletedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: EnvironmentDeletedSubject{ diff --git a/pkg/api/zz_environmentmodified.go b/pkg/api/zz_environmentmodified_0_1_1.go similarity index 66% rename from pkg/api/zz_environmentmodified.go rename to pkg/api/zz_environmentmodified_0_1_1.go index 639d997..6830351 100644 --- a/pkg/api/zz_environmentmodified.go +++ b/pkg/api/zz_environmentmodified_0_1_1.go @@ -28,8 +28,8 @@ import ( var environmentmodifiedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/environment-modified-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.environment.modified.0.1.1"],"default":"dev.cdevents.environment.modified.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["environment"],"default":"environment"},"content":{"properties":{"name":{"type":"string"},"url":{"type":"string"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // EnvironmentModified event v0.1.1 - EnvironmentModifiedEventV1 CDEventType = CDEventType{ + // EnvironmentModified event type v0.1.1 + EnvironmentModifiedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "environment", Predicate: "modified", Version: "0.1.1", @@ -51,7 +51,7 @@ func (sc EnvironmentModifiedSubject) GetSubjectType() SubjectType { return "environment" } -type EnvironmentModifiedEvent struct { +type EnvironmentModifiedEventV0_1_1 struct { Context Context `json:"context"` Subject EnvironmentModifiedSubject `json:"subject"` CDEventCustomData @@ -59,61 +59,61 @@ type EnvironmentModifiedEvent struct { // CDEventsReader implementation -func (e EnvironmentModifiedEvent) GetType() CDEventType { - return EnvironmentModifiedEventV1 +func (e EnvironmentModifiedEventV0_1_1) GetType() CDEventType { + return EnvironmentModifiedEventTypeV0_1_1 } -func (e EnvironmentModifiedEvent) GetVersion() string { +func (e EnvironmentModifiedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e EnvironmentModifiedEvent) GetId() string { +func (e EnvironmentModifiedEventV0_1_1) GetId() string { return e.Context.Id } -func (e EnvironmentModifiedEvent) GetSource() string { +func (e EnvironmentModifiedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e EnvironmentModifiedEvent) GetTimestamp() time.Time { +func (e EnvironmentModifiedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e EnvironmentModifiedEvent) GetSubjectId() string { +func (e EnvironmentModifiedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e EnvironmentModifiedEvent) GetSubjectSource() string { +func (e EnvironmentModifiedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e EnvironmentModifiedEvent) GetSubject() Subject { +func (e EnvironmentModifiedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e EnvironmentModifiedEvent) GetCustomData() (interface{}, error) { +func (e EnvironmentModifiedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e EnvironmentModifiedEvent) GetCustomDataAs(receiver interface{}) error { +func (e EnvironmentModifiedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e EnvironmentModifiedEvent) GetCustomDataRaw() ([]byte, error) { +func (e EnvironmentModifiedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e EnvironmentModifiedEvent) GetCustomDataContentType() string { +func (e EnvironmentModifiedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *EnvironmentModifiedEvent) SetId(id string) { +func (e *EnvironmentModifiedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *EnvironmentModifiedEvent) SetSource(source string) { +func (e *EnvironmentModifiedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -121,19 +121,19 @@ func (e *EnvironmentModifiedEvent) SetSource(source string) { } } -func (e *EnvironmentModifiedEvent) SetTimestamp(timestamp time.Time) { +func (e *EnvironmentModifiedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *EnvironmentModifiedEvent) SetSubjectId(subjectId string) { +func (e *EnvironmentModifiedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *EnvironmentModifiedEvent) SetSubjectSource(subjectSource string) { +func (e *EnvironmentModifiedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *EnvironmentModifiedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *EnvironmentModifiedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -143,26 +143,26 @@ func (e *EnvironmentModifiedEvent) SetCustomData(contentType string, data interf return nil } -func (e EnvironmentModifiedEvent) GetSchema() (string, string) { +func (e EnvironmentModifiedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), environmentmodifiedschema } // Set subject custom fields -func (e *EnvironmentModifiedEvent) SetSubjectName(name string) { +func (e *EnvironmentModifiedEventV0_1_1) SetSubjectName(name string) { e.Subject.Content.Name = name } -func (e *EnvironmentModifiedEvent) SetSubjectUrl(url string) { +func (e *EnvironmentModifiedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -// New creates a new EnvironmentModifiedEvent -func NewEnvironmentModifiedEvent() (*EnvironmentModifiedEvent, error) { - e := &EnvironmentModifiedEvent{ +// New creates a new EnvironmentModifiedEventV0_1_1 +func NewEnvironmentModifiedEventV0_1_1() (*EnvironmentModifiedEventV0_1_1, error) { + e := &EnvironmentModifiedEventV0_1_1{ Context: Context{ - Type: EnvironmentModifiedEventV1.String(), + Type: EnvironmentModifiedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: EnvironmentModifiedSubject{ diff --git a/pkg/api/zz_examples_test.go b/pkg/api/zz_examples_test.go index 16f42cf..1acc78e 100644 --- a/pkg/api/zz_examples_test.go +++ b/pkg/api/zz_examples_test.go @@ -18,241 +18,243 @@ limitations under the License. SPDX-License-Identifier: Apache-2.0 */ -package api +package api_test + +import "github.com/cdevents/sdk-go/pkg/api" func init() { // Create events equal to examples in the spec - examplesProduced = make(map[string]CDEvent) + examplesProduced = make(map[string]api.CDEvent) // ArtifactPackaged Event producer - newArtifactPackaged, _ := NewArtifactPackagedEvent() + newArtifactPackaged, _ := api.NewArtifactPackagedEventV0_1_1() setContext(newArtifactPackaged, testSubjectId) exampleArtifactPackagedEvent(newArtifactPackaged) examplesProduced[newArtifactPackaged.GetType().Short()] = newArtifactPackaged // ArtifactPublished Event producer - newArtifactPublished, _ := NewArtifactPublishedEvent() + newArtifactPublished, _ := api.NewArtifactPublishedEventV0_1_1() setContext(newArtifactPublished, testSubjectId) exampleArtifactPublishedEvent(newArtifactPublished) examplesProduced[newArtifactPublished.GetType().Short()] = newArtifactPublished // ArtifactSigned Event producer - newArtifactSigned, _ := NewArtifactSignedEvent() + newArtifactSigned, _ := api.NewArtifactSignedEventV0_1_0() setContext(newArtifactSigned, testSubjectId) exampleArtifactSignedEvent(newArtifactSigned) examplesProduced[newArtifactSigned.GetType().Short()] = newArtifactSigned // BranchCreated Event producer - newBranchCreated, _ := NewBranchCreatedEvent() + newBranchCreated, _ := api.NewBranchCreatedEventV0_1_2() setContext(newBranchCreated, testSubjectId) exampleBranchCreatedEvent(newBranchCreated) examplesProduced[newBranchCreated.GetType().Short()] = newBranchCreated // BranchDeleted Event producer - newBranchDeleted, _ := NewBranchDeletedEvent() + newBranchDeleted, _ := api.NewBranchDeletedEventV0_1_2() setContext(newBranchDeleted, testSubjectId) exampleBranchDeletedEvent(newBranchDeleted) examplesProduced[newBranchDeleted.GetType().Short()] = newBranchDeleted // BuildFinished Event producer - newBuildFinished, _ := NewBuildFinishedEvent() + newBuildFinished, _ := api.NewBuildFinishedEventV0_1_1() setContext(newBuildFinished, testSubjectId) exampleBuildFinishedEvent(newBuildFinished) examplesProduced[newBuildFinished.GetType().Short()] = newBuildFinished // BuildQueued Event producer - newBuildQueued, _ := NewBuildQueuedEvent() + newBuildQueued, _ := api.NewBuildQueuedEventV0_1_1() setContext(newBuildQueued, testSubjectId) exampleBuildQueuedEvent(newBuildQueued) examplesProduced[newBuildQueued.GetType().Short()] = newBuildQueued // BuildStarted Event producer - newBuildStarted, _ := NewBuildStartedEvent() + newBuildStarted, _ := api.NewBuildStartedEventV0_1_1() setContext(newBuildStarted, testSubjectId) exampleBuildStartedEvent(newBuildStarted) examplesProduced[newBuildStarted.GetType().Short()] = newBuildStarted // ChangeAbandoned Event producer - newChangeAbandoned, _ := NewChangeAbandonedEvent() + newChangeAbandoned, _ := api.NewChangeAbandonedEventV0_1_2() setContext(newChangeAbandoned, testSubjectId) exampleChangeAbandonedEvent(newChangeAbandoned) examplesProduced[newChangeAbandoned.GetType().Short()] = newChangeAbandoned // ChangeCreated Event producer - newChangeCreated, _ := NewChangeCreatedEvent() + newChangeCreated, _ := api.NewChangeCreatedEventV0_1_2() setContext(newChangeCreated, testSubjectId) exampleChangeCreatedEvent(newChangeCreated) examplesProduced[newChangeCreated.GetType().Short()] = newChangeCreated // ChangeMerged Event producer - newChangeMerged, _ := NewChangeMergedEvent() + newChangeMerged, _ := api.NewChangeMergedEventV0_1_2() setContext(newChangeMerged, testSubjectId) exampleChangeMergedEvent(newChangeMerged) examplesProduced[newChangeMerged.GetType().Short()] = newChangeMerged // ChangeReviewed Event producer - newChangeReviewed, _ := NewChangeReviewedEvent() + newChangeReviewed, _ := api.NewChangeReviewedEventV0_1_2() setContext(newChangeReviewed, testSubjectId) exampleChangeReviewedEvent(newChangeReviewed) examplesProduced[newChangeReviewed.GetType().Short()] = newChangeReviewed // ChangeUpdated Event producer - newChangeUpdated, _ := NewChangeUpdatedEvent() + newChangeUpdated, _ := api.NewChangeUpdatedEventV0_1_2() setContext(newChangeUpdated, testSubjectId) exampleChangeUpdatedEvent(newChangeUpdated) examplesProduced[newChangeUpdated.GetType().Short()] = newChangeUpdated // EnvironmentCreated Event producer - newEnvironmentCreated, _ := NewEnvironmentCreatedEvent() + newEnvironmentCreated, _ := api.NewEnvironmentCreatedEventV0_1_1() setContext(newEnvironmentCreated, testSubjectId) exampleEnvironmentCreatedEvent(newEnvironmentCreated) examplesProduced[newEnvironmentCreated.GetType().Short()] = newEnvironmentCreated // EnvironmentDeleted Event producer - newEnvironmentDeleted, _ := NewEnvironmentDeletedEvent() + newEnvironmentDeleted, _ := api.NewEnvironmentDeletedEventV0_1_1() setContext(newEnvironmentDeleted, testSubjectId) exampleEnvironmentDeletedEvent(newEnvironmentDeleted) examplesProduced[newEnvironmentDeleted.GetType().Short()] = newEnvironmentDeleted // EnvironmentModified Event producer - newEnvironmentModified, _ := NewEnvironmentModifiedEvent() + newEnvironmentModified, _ := api.NewEnvironmentModifiedEventV0_1_1() setContext(newEnvironmentModified, testSubjectId) exampleEnvironmentModifiedEvent(newEnvironmentModified) examplesProduced[newEnvironmentModified.GetType().Short()] = newEnvironmentModified // IncidentDetected Event producer - newIncidentDetected, _ := NewIncidentDetectedEvent() + newIncidentDetected, _ := api.NewIncidentDetectedEventV0_1_0() setContext(newIncidentDetected, testSubjectId) exampleIncidentDetectedEvent(newIncidentDetected) examplesProduced[newIncidentDetected.GetType().Short()] = newIncidentDetected // IncidentReported Event producer - newIncidentReported, _ := NewIncidentReportedEvent() + newIncidentReported, _ := api.NewIncidentReportedEventV0_1_0() setContext(newIncidentReported, testSubjectId) exampleIncidentReportedEvent(newIncidentReported) examplesProduced[newIncidentReported.GetType().Short()] = newIncidentReported // IncidentResolved Event producer - newIncidentResolved, _ := NewIncidentResolvedEvent() + newIncidentResolved, _ := api.NewIncidentResolvedEventV0_1_0() setContext(newIncidentResolved, testSubjectId) exampleIncidentResolvedEvent(newIncidentResolved) examplesProduced[newIncidentResolved.GetType().Short()] = newIncidentResolved // PipelineRunFinished Event producer - newPipelineRunFinished, _ := NewPipelineRunFinishedEvent() + newPipelineRunFinished, _ := api.NewPipelineRunFinishedEventV0_1_1() setContext(newPipelineRunFinished, testSubjectId) examplePipelineRunFinishedEvent(newPipelineRunFinished) examplesProduced[newPipelineRunFinished.GetType().Short()] = newPipelineRunFinished // PipelineRunQueued Event producer - newPipelineRunQueued, _ := NewPipelineRunQueuedEvent() + newPipelineRunQueued, _ := api.NewPipelineRunQueuedEventV0_1_1() setContext(newPipelineRunQueued, testSubjectId) examplePipelineRunQueuedEvent(newPipelineRunQueued) examplesProduced[newPipelineRunQueued.GetType().Short()] = newPipelineRunQueued // PipelineRunStarted Event producer - newPipelineRunStarted, _ := NewPipelineRunStartedEvent() + newPipelineRunStarted, _ := api.NewPipelineRunStartedEventV0_1_1() setContext(newPipelineRunStarted, testSubjectId) examplePipelineRunStartedEvent(newPipelineRunStarted) examplesProduced[newPipelineRunStarted.GetType().Short()] = newPipelineRunStarted // RepositoryCreated Event producer - newRepositoryCreated, _ := NewRepositoryCreatedEvent() + newRepositoryCreated, _ := api.NewRepositoryCreatedEventV0_1_1() setContext(newRepositoryCreated, testSubjectId) exampleRepositoryCreatedEvent(newRepositoryCreated) examplesProduced[newRepositoryCreated.GetType().Short()] = newRepositoryCreated // RepositoryDeleted Event producer - newRepositoryDeleted, _ := NewRepositoryDeletedEvent() + newRepositoryDeleted, _ := api.NewRepositoryDeletedEventV0_1_1() setContext(newRepositoryDeleted, testSubjectId) exampleRepositoryDeletedEvent(newRepositoryDeleted) examplesProduced[newRepositoryDeleted.GetType().Short()] = newRepositoryDeleted // RepositoryModified Event producer - newRepositoryModified, _ := NewRepositoryModifiedEvent() + newRepositoryModified, _ := api.NewRepositoryModifiedEventV0_1_1() setContext(newRepositoryModified, testSubjectId) exampleRepositoryModifiedEvent(newRepositoryModified) examplesProduced[newRepositoryModified.GetType().Short()] = newRepositoryModified // ServiceDeployed Event producer - newServiceDeployed, _ := NewServiceDeployedEvent() + newServiceDeployed, _ := api.NewServiceDeployedEventV0_1_1() setContext(newServiceDeployed, testSubjectId) exampleServiceDeployedEvent(newServiceDeployed) examplesProduced[newServiceDeployed.GetType().Short()] = newServiceDeployed // ServicePublished Event producer - newServicePublished, _ := NewServicePublishedEvent() + newServicePublished, _ := api.NewServicePublishedEventV0_1_1() setContext(newServicePublished, testSubjectId) exampleServicePublishedEvent(newServicePublished) examplesProduced[newServicePublished.GetType().Short()] = newServicePublished // ServiceRemoved Event producer - newServiceRemoved, _ := NewServiceRemovedEvent() + newServiceRemoved, _ := api.NewServiceRemovedEventV0_1_1() setContext(newServiceRemoved, testSubjectId) exampleServiceRemovedEvent(newServiceRemoved) examplesProduced[newServiceRemoved.GetType().Short()] = newServiceRemoved // ServiceRolledback Event producer - newServiceRolledback, _ := NewServiceRolledbackEvent() + newServiceRolledback, _ := api.NewServiceRolledbackEventV0_1_1() setContext(newServiceRolledback, testSubjectId) exampleServiceRolledbackEvent(newServiceRolledback) examplesProduced[newServiceRolledback.GetType().Short()] = newServiceRolledback // ServiceUpgraded Event producer - newServiceUpgraded, _ := NewServiceUpgradedEvent() + newServiceUpgraded, _ := api.NewServiceUpgradedEventV0_1_1() setContext(newServiceUpgraded, testSubjectId) exampleServiceUpgradedEvent(newServiceUpgraded) examplesProduced[newServiceUpgraded.GetType().Short()] = newServiceUpgraded // TaskRunFinished Event producer - newTaskRunFinished, _ := NewTaskRunFinishedEvent() + newTaskRunFinished, _ := api.NewTaskRunFinishedEventV0_1_1() setContext(newTaskRunFinished, testSubjectId) exampleTaskRunFinishedEvent(newTaskRunFinished) examplesProduced[newTaskRunFinished.GetType().Short()] = newTaskRunFinished // TaskRunStarted Event producer - newTaskRunStarted, _ := NewTaskRunStartedEvent() + newTaskRunStarted, _ := api.NewTaskRunStartedEventV0_1_1() setContext(newTaskRunStarted, testSubjectId) exampleTaskRunStartedEvent(newTaskRunStarted) examplesProduced[newTaskRunStarted.GetType().Short()] = newTaskRunStarted // TestCaseRunFinished Event producer - newTestCaseRunFinished, _ := NewTestCaseRunFinishedEvent() + newTestCaseRunFinished, _ := api.NewTestCaseRunFinishedEventV0_1_0() setContext(newTestCaseRunFinished, testSubjectId) exampleTestCaseRunFinishedEvent(newTestCaseRunFinished) examplesProduced[newTestCaseRunFinished.GetType().Short()] = newTestCaseRunFinished // TestCaseRunQueued Event producer - newTestCaseRunQueued, _ := NewTestCaseRunQueuedEvent() + newTestCaseRunQueued, _ := api.NewTestCaseRunQueuedEventV0_1_0() setContext(newTestCaseRunQueued, testSubjectId) exampleTestCaseRunQueuedEvent(newTestCaseRunQueued) examplesProduced[newTestCaseRunQueued.GetType().Short()] = newTestCaseRunQueued // TestCaseRunStarted Event producer - newTestCaseRunStarted, _ := NewTestCaseRunStartedEvent() + newTestCaseRunStarted, _ := api.NewTestCaseRunStartedEventV0_1_0() setContext(newTestCaseRunStarted, testSubjectId) exampleTestCaseRunStartedEvent(newTestCaseRunStarted) examplesProduced[newTestCaseRunStarted.GetType().Short()] = newTestCaseRunStarted // TestOutputPublished Event producer - newTestOutputPublished, _ := NewTestOutputPublishedEvent() + newTestOutputPublished, _ := api.NewTestOutputPublishedEventV0_1_0() setContext(newTestOutputPublished, testSubjectId) exampleTestOutputPublishedEvent(newTestOutputPublished) examplesProduced[newTestOutputPublished.GetType().Short()] = newTestOutputPublished // TestSuiteRunFinished Event producer - newTestSuiteRunFinished, _ := NewTestSuiteRunFinishedEvent() + newTestSuiteRunFinished, _ := api.NewTestSuiteRunFinishedEventV0_1_0() setContext(newTestSuiteRunFinished, testSubjectId) exampleTestSuiteRunFinishedEvent(newTestSuiteRunFinished) examplesProduced[newTestSuiteRunFinished.GetType().Short()] = newTestSuiteRunFinished // TestSuiteRunQueued Event producer - newTestSuiteRunQueued, _ := NewTestSuiteRunQueuedEvent() + newTestSuiteRunQueued, _ := api.NewTestSuiteRunQueuedEventV0_1_0() setContext(newTestSuiteRunQueued, testSubjectId) exampleTestSuiteRunQueuedEvent(newTestSuiteRunQueued) examplesProduced[newTestSuiteRunQueued.GetType().Short()] = newTestSuiteRunQueued // TestSuiteRunStarted Event producer - newTestSuiteRunStarted, _ := NewTestSuiteRunStartedEvent() + newTestSuiteRunStarted, _ := api.NewTestSuiteRunStartedEventV0_1_0() setContext(newTestSuiteRunStarted, testSubjectId) exampleTestSuiteRunStartedEvent(newTestSuiteRunStarted) examplesProduced[newTestSuiteRunStarted.GetType().Short()] = newTestSuiteRunStarted diff --git a/pkg/api/zz_factory_test.go b/pkg/api/zz_factory_test.go index f2336c1..95849cd 100644 --- a/pkg/api/zz_factory_test.go +++ b/pkg/api/zz_factory_test.go @@ -18,22 +18,24 @@ limitations under the License. SPDX-License-Identifier: Apache-2.0 */ -package api +package api_test + +import "github.com/cdevents/sdk-go/pkg/api" func init() { tests = []testNewCDEventType{} tests = append(tests, testNewCDEventType{ name: "artifact packaged", - eventType: ArtifactPackagedEventV1.String(), - expectedEvent: &ArtifactPackagedEvent{ - Context: Context{ - Type: ArtifactPackagedEventV1.String(), + eventType: api.ArtifactPackagedEventTypeV0_1_1.String(), + expectedEvent: &api.ArtifactPackagedEventV0_1_1{ + Context: api.Context{ + Type: api.ArtifactPackagedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ArtifactPackagedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ArtifactPackagedSubject{ + SubjectBase: api.SubjectBase{ Type: "artifact", }, }, @@ -41,16 +43,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "artifact published", - eventType: ArtifactPublishedEventV1.String(), - expectedEvent: &ArtifactPublishedEvent{ - Context: Context{ - Type: ArtifactPublishedEventV1.String(), + eventType: api.ArtifactPublishedEventTypeV0_1_1.String(), + expectedEvent: &api.ArtifactPublishedEventV0_1_1{ + Context: api.Context{ + Type: api.ArtifactPublishedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ArtifactPublishedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ArtifactPublishedSubject{ + SubjectBase: api.SubjectBase{ Type: "artifact", }, }, @@ -58,16 +60,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "artifact signed", - eventType: ArtifactSignedEventV1.String(), - expectedEvent: &ArtifactSignedEvent{ - Context: Context{ - Type: ArtifactSignedEventV1.String(), + eventType: api.ArtifactSignedEventTypeV0_1_0.String(), + expectedEvent: &api.ArtifactSignedEventV0_1_0{ + Context: api.Context{ + Type: api.ArtifactSignedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ArtifactSignedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ArtifactSignedSubject{ + SubjectBase: api.SubjectBase{ Type: "artifact", }, }, @@ -75,16 +77,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "branch created", - eventType: BranchCreatedEventV1.String(), - expectedEvent: &BranchCreatedEvent{ - Context: Context{ - Type: BranchCreatedEventV1.String(), + eventType: api.BranchCreatedEventTypeV0_1_2.String(), + expectedEvent: &api.BranchCreatedEventV0_1_2{ + Context: api.Context{ + Type: api.BranchCreatedEventTypeV0_1_2.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: BranchCreatedSubject{ - SubjectBase: SubjectBase{ + Subject: api.BranchCreatedSubject{ + SubjectBase: api.SubjectBase{ Type: "branch", }, }, @@ -92,16 +94,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "branch deleted", - eventType: BranchDeletedEventV1.String(), - expectedEvent: &BranchDeletedEvent{ - Context: Context{ - Type: BranchDeletedEventV1.String(), + eventType: api.BranchDeletedEventTypeV0_1_2.String(), + expectedEvent: &api.BranchDeletedEventV0_1_2{ + Context: api.Context{ + Type: api.BranchDeletedEventTypeV0_1_2.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: BranchDeletedSubject{ - SubjectBase: SubjectBase{ + Subject: api.BranchDeletedSubject{ + SubjectBase: api.SubjectBase{ Type: "branch", }, }, @@ -109,16 +111,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "build finished", - eventType: BuildFinishedEventV1.String(), - expectedEvent: &BuildFinishedEvent{ - Context: Context{ - Type: BuildFinishedEventV1.String(), + eventType: api.BuildFinishedEventTypeV0_1_1.String(), + expectedEvent: &api.BuildFinishedEventV0_1_1{ + Context: api.Context{ + Type: api.BuildFinishedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: BuildFinishedSubject{ - SubjectBase: SubjectBase{ + Subject: api.BuildFinishedSubject{ + SubjectBase: api.SubjectBase{ Type: "build", }, }, @@ -126,16 +128,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "build queued", - eventType: BuildQueuedEventV1.String(), - expectedEvent: &BuildQueuedEvent{ - Context: Context{ - Type: BuildQueuedEventV1.String(), + eventType: api.BuildQueuedEventTypeV0_1_1.String(), + expectedEvent: &api.BuildQueuedEventV0_1_1{ + Context: api.Context{ + Type: api.BuildQueuedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: BuildQueuedSubject{ - SubjectBase: SubjectBase{ + Subject: api.BuildQueuedSubject{ + SubjectBase: api.SubjectBase{ Type: "build", }, }, @@ -143,16 +145,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "build started", - eventType: BuildStartedEventV1.String(), - expectedEvent: &BuildStartedEvent{ - Context: Context{ - Type: BuildStartedEventV1.String(), + eventType: api.BuildStartedEventTypeV0_1_1.String(), + expectedEvent: &api.BuildStartedEventV0_1_1{ + Context: api.Context{ + Type: api.BuildStartedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: BuildStartedSubject{ - SubjectBase: SubjectBase{ + Subject: api.BuildStartedSubject{ + SubjectBase: api.SubjectBase{ Type: "build", }, }, @@ -160,16 +162,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "change abandoned", - eventType: ChangeAbandonedEventV1.String(), - expectedEvent: &ChangeAbandonedEvent{ - Context: Context{ - Type: ChangeAbandonedEventV1.String(), + eventType: api.ChangeAbandonedEventTypeV0_1_2.String(), + expectedEvent: &api.ChangeAbandonedEventV0_1_2{ + Context: api.Context{ + Type: api.ChangeAbandonedEventTypeV0_1_2.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ChangeAbandonedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ChangeAbandonedSubject{ + SubjectBase: api.SubjectBase{ Type: "change", }, }, @@ -177,16 +179,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "change created", - eventType: ChangeCreatedEventV1.String(), - expectedEvent: &ChangeCreatedEvent{ - Context: Context{ - Type: ChangeCreatedEventV1.String(), + eventType: api.ChangeCreatedEventTypeV0_1_2.String(), + expectedEvent: &api.ChangeCreatedEventV0_1_2{ + Context: api.Context{ + Type: api.ChangeCreatedEventTypeV0_1_2.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ChangeCreatedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ChangeCreatedSubject{ + SubjectBase: api.SubjectBase{ Type: "change", }, }, @@ -194,16 +196,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "change merged", - eventType: ChangeMergedEventV1.String(), - expectedEvent: &ChangeMergedEvent{ - Context: Context{ - Type: ChangeMergedEventV1.String(), + eventType: api.ChangeMergedEventTypeV0_1_2.String(), + expectedEvent: &api.ChangeMergedEventV0_1_2{ + Context: api.Context{ + Type: api.ChangeMergedEventTypeV0_1_2.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ChangeMergedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ChangeMergedSubject{ + SubjectBase: api.SubjectBase{ Type: "change", }, }, @@ -211,16 +213,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "change reviewed", - eventType: ChangeReviewedEventV1.String(), - expectedEvent: &ChangeReviewedEvent{ - Context: Context{ - Type: ChangeReviewedEventV1.String(), + eventType: api.ChangeReviewedEventTypeV0_1_2.String(), + expectedEvent: &api.ChangeReviewedEventV0_1_2{ + Context: api.Context{ + Type: api.ChangeReviewedEventTypeV0_1_2.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ChangeReviewedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ChangeReviewedSubject{ + SubjectBase: api.SubjectBase{ Type: "change", }, }, @@ -228,16 +230,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "change updated", - eventType: ChangeUpdatedEventV1.String(), - expectedEvent: &ChangeUpdatedEvent{ - Context: Context{ - Type: ChangeUpdatedEventV1.String(), + eventType: api.ChangeUpdatedEventTypeV0_1_2.String(), + expectedEvent: &api.ChangeUpdatedEventV0_1_2{ + Context: api.Context{ + Type: api.ChangeUpdatedEventTypeV0_1_2.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ChangeUpdatedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ChangeUpdatedSubject{ + SubjectBase: api.SubjectBase{ Type: "change", }, }, @@ -245,16 +247,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "environment created", - eventType: EnvironmentCreatedEventV1.String(), - expectedEvent: &EnvironmentCreatedEvent{ - Context: Context{ - Type: EnvironmentCreatedEventV1.String(), + eventType: api.EnvironmentCreatedEventTypeV0_1_1.String(), + expectedEvent: &api.EnvironmentCreatedEventV0_1_1{ + Context: api.Context{ + Type: api.EnvironmentCreatedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: EnvironmentCreatedSubject{ - SubjectBase: SubjectBase{ + Subject: api.EnvironmentCreatedSubject{ + SubjectBase: api.SubjectBase{ Type: "environment", }, }, @@ -262,16 +264,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "environment deleted", - eventType: EnvironmentDeletedEventV1.String(), - expectedEvent: &EnvironmentDeletedEvent{ - Context: Context{ - Type: EnvironmentDeletedEventV1.String(), + eventType: api.EnvironmentDeletedEventTypeV0_1_1.String(), + expectedEvent: &api.EnvironmentDeletedEventV0_1_1{ + Context: api.Context{ + Type: api.EnvironmentDeletedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: EnvironmentDeletedSubject{ - SubjectBase: SubjectBase{ + Subject: api.EnvironmentDeletedSubject{ + SubjectBase: api.SubjectBase{ Type: "environment", }, }, @@ -279,16 +281,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "environment modified", - eventType: EnvironmentModifiedEventV1.String(), - expectedEvent: &EnvironmentModifiedEvent{ - Context: Context{ - Type: EnvironmentModifiedEventV1.String(), + eventType: api.EnvironmentModifiedEventTypeV0_1_1.String(), + expectedEvent: &api.EnvironmentModifiedEventV0_1_1{ + Context: api.Context{ + Type: api.EnvironmentModifiedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: EnvironmentModifiedSubject{ - SubjectBase: SubjectBase{ + Subject: api.EnvironmentModifiedSubject{ + SubjectBase: api.SubjectBase{ Type: "environment", }, }, @@ -296,16 +298,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "incident detected", - eventType: IncidentDetectedEventV1.String(), - expectedEvent: &IncidentDetectedEvent{ - Context: Context{ - Type: IncidentDetectedEventV1.String(), + eventType: api.IncidentDetectedEventTypeV0_1_0.String(), + expectedEvent: &api.IncidentDetectedEventV0_1_0{ + Context: api.Context{ + Type: api.IncidentDetectedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: IncidentDetectedSubject{ - SubjectBase: SubjectBase{ + Subject: api.IncidentDetectedSubject{ + SubjectBase: api.SubjectBase{ Type: "incident", }, }, @@ -313,16 +315,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "incident reported", - eventType: IncidentReportedEventV1.String(), - expectedEvent: &IncidentReportedEvent{ - Context: Context{ - Type: IncidentReportedEventV1.String(), + eventType: api.IncidentReportedEventTypeV0_1_0.String(), + expectedEvent: &api.IncidentReportedEventV0_1_0{ + Context: api.Context{ + Type: api.IncidentReportedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: IncidentReportedSubject{ - SubjectBase: SubjectBase{ + Subject: api.IncidentReportedSubject{ + SubjectBase: api.SubjectBase{ Type: "incident", }, }, @@ -330,16 +332,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "incident resolved", - eventType: IncidentResolvedEventV1.String(), - expectedEvent: &IncidentResolvedEvent{ - Context: Context{ - Type: IncidentResolvedEventV1.String(), + eventType: api.IncidentResolvedEventTypeV0_1_0.String(), + expectedEvent: &api.IncidentResolvedEventV0_1_0{ + Context: api.Context{ + Type: api.IncidentResolvedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: IncidentResolvedSubject{ - SubjectBase: SubjectBase{ + Subject: api.IncidentResolvedSubject{ + SubjectBase: api.SubjectBase{ Type: "incident", }, }, @@ -347,16 +349,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "pipelinerun finished", - eventType: PipelineRunFinishedEventV1.String(), - expectedEvent: &PipelineRunFinishedEvent{ - Context: Context{ - Type: PipelineRunFinishedEventV1.String(), + eventType: api.PipelineRunFinishedEventTypeV0_1_1.String(), + expectedEvent: &api.PipelineRunFinishedEventV0_1_1{ + Context: api.Context{ + Type: api.PipelineRunFinishedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: PipelineRunFinishedSubject{ - SubjectBase: SubjectBase{ + Subject: api.PipelineRunFinishedSubject{ + SubjectBase: api.SubjectBase{ Type: "pipelineRun", }, }, @@ -364,16 +366,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "pipelinerun queued", - eventType: PipelineRunQueuedEventV1.String(), - expectedEvent: &PipelineRunQueuedEvent{ - Context: Context{ - Type: PipelineRunQueuedEventV1.String(), + eventType: api.PipelineRunQueuedEventTypeV0_1_1.String(), + expectedEvent: &api.PipelineRunQueuedEventV0_1_1{ + Context: api.Context{ + Type: api.PipelineRunQueuedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: PipelineRunQueuedSubject{ - SubjectBase: SubjectBase{ + Subject: api.PipelineRunQueuedSubject{ + SubjectBase: api.SubjectBase{ Type: "pipelineRun", }, }, @@ -381,16 +383,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "pipelinerun started", - eventType: PipelineRunStartedEventV1.String(), - expectedEvent: &PipelineRunStartedEvent{ - Context: Context{ - Type: PipelineRunStartedEventV1.String(), + eventType: api.PipelineRunStartedEventTypeV0_1_1.String(), + expectedEvent: &api.PipelineRunStartedEventV0_1_1{ + Context: api.Context{ + Type: api.PipelineRunStartedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: PipelineRunStartedSubject{ - SubjectBase: SubjectBase{ + Subject: api.PipelineRunStartedSubject{ + SubjectBase: api.SubjectBase{ Type: "pipelineRun", }, }, @@ -398,16 +400,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "repository created", - eventType: RepositoryCreatedEventV1.String(), - expectedEvent: &RepositoryCreatedEvent{ - Context: Context{ - Type: RepositoryCreatedEventV1.String(), + eventType: api.RepositoryCreatedEventTypeV0_1_1.String(), + expectedEvent: &api.RepositoryCreatedEventV0_1_1{ + Context: api.Context{ + Type: api.RepositoryCreatedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: RepositoryCreatedSubject{ - SubjectBase: SubjectBase{ + Subject: api.RepositoryCreatedSubject{ + SubjectBase: api.SubjectBase{ Type: "repository", }, }, @@ -415,16 +417,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "repository deleted", - eventType: RepositoryDeletedEventV1.String(), - expectedEvent: &RepositoryDeletedEvent{ - Context: Context{ - Type: RepositoryDeletedEventV1.String(), + eventType: api.RepositoryDeletedEventTypeV0_1_1.String(), + expectedEvent: &api.RepositoryDeletedEventV0_1_1{ + Context: api.Context{ + Type: api.RepositoryDeletedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: RepositoryDeletedSubject{ - SubjectBase: SubjectBase{ + Subject: api.RepositoryDeletedSubject{ + SubjectBase: api.SubjectBase{ Type: "repository", }, }, @@ -432,16 +434,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "repository modified", - eventType: RepositoryModifiedEventV1.String(), - expectedEvent: &RepositoryModifiedEvent{ - Context: Context{ - Type: RepositoryModifiedEventV1.String(), + eventType: api.RepositoryModifiedEventTypeV0_1_1.String(), + expectedEvent: &api.RepositoryModifiedEventV0_1_1{ + Context: api.Context{ + Type: api.RepositoryModifiedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: RepositoryModifiedSubject{ - SubjectBase: SubjectBase{ + Subject: api.RepositoryModifiedSubject{ + SubjectBase: api.SubjectBase{ Type: "repository", }, }, @@ -449,16 +451,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "service deployed", - eventType: ServiceDeployedEventV1.String(), - expectedEvent: &ServiceDeployedEvent{ - Context: Context{ - Type: ServiceDeployedEventV1.String(), + eventType: api.ServiceDeployedEventTypeV0_1_1.String(), + expectedEvent: &api.ServiceDeployedEventV0_1_1{ + Context: api.Context{ + Type: api.ServiceDeployedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ServiceDeployedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ServiceDeployedSubject{ + SubjectBase: api.SubjectBase{ Type: "service", }, }, @@ -466,16 +468,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "service published", - eventType: ServicePublishedEventV1.String(), - expectedEvent: &ServicePublishedEvent{ - Context: Context{ - Type: ServicePublishedEventV1.String(), + eventType: api.ServicePublishedEventTypeV0_1_1.String(), + expectedEvent: &api.ServicePublishedEventV0_1_1{ + Context: api.Context{ + Type: api.ServicePublishedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ServicePublishedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ServicePublishedSubject{ + SubjectBase: api.SubjectBase{ Type: "service", }, }, @@ -483,16 +485,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "service removed", - eventType: ServiceRemovedEventV1.String(), - expectedEvent: &ServiceRemovedEvent{ - Context: Context{ - Type: ServiceRemovedEventV1.String(), + eventType: api.ServiceRemovedEventTypeV0_1_1.String(), + expectedEvent: &api.ServiceRemovedEventV0_1_1{ + Context: api.Context{ + Type: api.ServiceRemovedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ServiceRemovedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ServiceRemovedSubject{ + SubjectBase: api.SubjectBase{ Type: "service", }, }, @@ -500,16 +502,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "service rolledback", - eventType: ServiceRolledbackEventV1.String(), - expectedEvent: &ServiceRolledbackEvent{ - Context: Context{ - Type: ServiceRolledbackEventV1.String(), + eventType: api.ServiceRolledbackEventTypeV0_1_1.String(), + expectedEvent: &api.ServiceRolledbackEventV0_1_1{ + Context: api.Context{ + Type: api.ServiceRolledbackEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ServiceRolledbackSubject{ - SubjectBase: SubjectBase{ + Subject: api.ServiceRolledbackSubject{ + SubjectBase: api.SubjectBase{ Type: "service", }, }, @@ -517,16 +519,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "service upgraded", - eventType: ServiceUpgradedEventV1.String(), - expectedEvent: &ServiceUpgradedEvent{ - Context: Context{ - Type: ServiceUpgradedEventV1.String(), + eventType: api.ServiceUpgradedEventTypeV0_1_1.String(), + expectedEvent: &api.ServiceUpgradedEventV0_1_1{ + Context: api.Context{ + Type: api.ServiceUpgradedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: ServiceUpgradedSubject{ - SubjectBase: SubjectBase{ + Subject: api.ServiceUpgradedSubject{ + SubjectBase: api.SubjectBase{ Type: "service", }, }, @@ -534,16 +536,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "taskrun finished", - eventType: TaskRunFinishedEventV1.String(), - expectedEvent: &TaskRunFinishedEvent{ - Context: Context{ - Type: TaskRunFinishedEventV1.String(), + eventType: api.TaskRunFinishedEventTypeV0_1_1.String(), + expectedEvent: &api.TaskRunFinishedEventV0_1_1{ + Context: api.Context{ + Type: api.TaskRunFinishedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: TaskRunFinishedSubject{ - SubjectBase: SubjectBase{ + Subject: api.TaskRunFinishedSubject{ + SubjectBase: api.SubjectBase{ Type: "taskRun", }, }, @@ -551,16 +553,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "taskrun started", - eventType: TaskRunStartedEventV1.String(), - expectedEvent: &TaskRunStartedEvent{ - Context: Context{ - Type: TaskRunStartedEventV1.String(), + eventType: api.TaskRunStartedEventTypeV0_1_1.String(), + expectedEvent: &api.TaskRunStartedEventV0_1_1{ + Context: api.Context{ + Type: api.TaskRunStartedEventTypeV0_1_1.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: TaskRunStartedSubject{ - SubjectBase: SubjectBase{ + Subject: api.TaskRunStartedSubject{ + SubjectBase: api.SubjectBase{ Type: "taskRun", }, }, @@ -568,16 +570,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "testcaserun finished", - eventType: TestCaseRunFinishedEventV1.String(), - expectedEvent: &TestCaseRunFinishedEvent{ - Context: Context{ - Type: TestCaseRunFinishedEventV1.String(), + eventType: api.TestCaseRunFinishedEventTypeV0_1_0.String(), + expectedEvent: &api.TestCaseRunFinishedEventV0_1_0{ + Context: api.Context{ + Type: api.TestCaseRunFinishedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: TestCaseRunFinishedSubject{ - SubjectBase: SubjectBase{ + Subject: api.TestCaseRunFinishedSubject{ + SubjectBase: api.SubjectBase{ Type: "testCaseRun", }, }, @@ -585,16 +587,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "testcaserun queued", - eventType: TestCaseRunQueuedEventV1.String(), - expectedEvent: &TestCaseRunQueuedEvent{ - Context: Context{ - Type: TestCaseRunQueuedEventV1.String(), + eventType: api.TestCaseRunQueuedEventTypeV0_1_0.String(), + expectedEvent: &api.TestCaseRunQueuedEventV0_1_0{ + Context: api.Context{ + Type: api.TestCaseRunQueuedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: TestCaseRunQueuedSubject{ - SubjectBase: SubjectBase{ + Subject: api.TestCaseRunQueuedSubject{ + SubjectBase: api.SubjectBase{ Type: "testCaseRun", }, }, @@ -602,16 +604,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "testcaserun started", - eventType: TestCaseRunStartedEventV1.String(), - expectedEvent: &TestCaseRunStartedEvent{ - Context: Context{ - Type: TestCaseRunStartedEventV1.String(), + eventType: api.TestCaseRunStartedEventTypeV0_1_0.String(), + expectedEvent: &api.TestCaseRunStartedEventV0_1_0{ + Context: api.Context{ + Type: api.TestCaseRunStartedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: TestCaseRunStartedSubject{ - SubjectBase: SubjectBase{ + Subject: api.TestCaseRunStartedSubject{ + SubjectBase: api.SubjectBase{ Type: "testCaseRun", }, }, @@ -619,16 +621,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "testoutput published", - eventType: TestOutputPublishedEventV1.String(), - expectedEvent: &TestOutputPublishedEvent{ - Context: Context{ - Type: TestOutputPublishedEventV1.String(), + eventType: api.TestOutputPublishedEventTypeV0_1_0.String(), + expectedEvent: &api.TestOutputPublishedEventV0_1_0{ + Context: api.Context{ + Type: api.TestOutputPublishedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: TestOutputPublishedSubject{ - SubjectBase: SubjectBase{ + Subject: api.TestOutputPublishedSubject{ + SubjectBase: api.SubjectBase{ Type: "testOutput", }, }, @@ -636,16 +638,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "testsuiterun finished", - eventType: TestSuiteRunFinishedEventV1.String(), - expectedEvent: &TestSuiteRunFinishedEvent{ - Context: Context{ - Type: TestSuiteRunFinishedEventV1.String(), + eventType: api.TestSuiteRunFinishedEventTypeV0_1_0.String(), + expectedEvent: &api.TestSuiteRunFinishedEventV0_1_0{ + Context: api.Context{ + Type: api.TestSuiteRunFinishedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: TestSuiteRunFinishedSubject{ - SubjectBase: SubjectBase{ + Subject: api.TestSuiteRunFinishedSubject{ + SubjectBase: api.SubjectBase{ Type: "testSuiteRun", }, }, @@ -653,16 +655,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "testsuiterun queued", - eventType: TestSuiteRunQueuedEventV1.String(), - expectedEvent: &TestSuiteRunQueuedEvent{ - Context: Context{ - Type: TestSuiteRunQueuedEventV1.String(), + eventType: api.TestSuiteRunQueuedEventTypeV0_1_0.String(), + expectedEvent: &api.TestSuiteRunQueuedEventV0_1_0{ + Context: api.Context{ + Type: api.TestSuiteRunQueuedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: TestSuiteRunQueuedSubject{ - SubjectBase: SubjectBase{ + Subject: api.TestSuiteRunQueuedSubject{ + SubjectBase: api.SubjectBase{ Type: "testSuiteRun", }, }, @@ -670,16 +672,16 @@ func init() { }) tests = append(tests, testNewCDEventType{ name: "testsuiterun started", - eventType: TestSuiteRunStartedEventV1.String(), - expectedEvent: &TestSuiteRunStartedEvent{ - Context: Context{ - Type: TestSuiteRunStartedEventV1.String(), + eventType: api.TestSuiteRunStartedEventTypeV0_1_0.String(), + expectedEvent: &api.TestSuiteRunStartedEventV0_1_0{ + Context: api.Context{ + Type: api.TestSuiteRunStartedEventTypeV0_1_0.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: TestSuiteRunStartedSubject{ - SubjectBase: SubjectBase{ + Subject: api.TestSuiteRunStartedSubject{ + SubjectBase: api.SubjectBase{ Type: "testSuiteRun", }, }, diff --git a/pkg/api/zz_incidentdetected.go b/pkg/api/zz_incidentdetected_0_1_0.go similarity index 69% rename from pkg/api/zz_incidentdetected.go rename to pkg/api/zz_incidentdetected_0_1_0.go index ec7daa6..5d30221 100644 --- a/pkg/api/zz_incidentdetected.go +++ b/pkg/api/zz_incidentdetected_0_1_0.go @@ -28,8 +28,8 @@ import ( var incidentdetectedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/incident-detected-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.incident.detected.0.1.0"],"default":"dev.cdevents.incident.detected.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["incident"],"default":"incident"},"content":{"properties":{"description":{"type":"string"},"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"service":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"artifactId":{"type":"string","minLength":1}},"additionalProperties":false,"type":"object","required":["environment"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // IncidentDetected event v0.1.0 - IncidentDetectedEventV1 CDEventType = CDEventType{ + // IncidentDetected event type v0.1.0 + IncidentDetectedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "incident", Predicate: "detected", Version: "0.1.0", @@ -55,7 +55,7 @@ func (sc IncidentDetectedSubject) GetSubjectType() SubjectType { return "incident" } -type IncidentDetectedEvent struct { +type IncidentDetectedEventV0_1_0 struct { Context Context `json:"context"` Subject IncidentDetectedSubject `json:"subject"` CDEventCustomData @@ -63,61 +63,61 @@ type IncidentDetectedEvent struct { // CDEventsReader implementation -func (e IncidentDetectedEvent) GetType() CDEventType { - return IncidentDetectedEventV1 +func (e IncidentDetectedEventV0_1_0) GetType() CDEventType { + return IncidentDetectedEventTypeV0_1_0 } -func (e IncidentDetectedEvent) GetVersion() string { +func (e IncidentDetectedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e IncidentDetectedEvent) GetId() string { +func (e IncidentDetectedEventV0_1_0) GetId() string { return e.Context.Id } -func (e IncidentDetectedEvent) GetSource() string { +func (e IncidentDetectedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e IncidentDetectedEvent) GetTimestamp() time.Time { +func (e IncidentDetectedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e IncidentDetectedEvent) GetSubjectId() string { +func (e IncidentDetectedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e IncidentDetectedEvent) GetSubjectSource() string { +func (e IncidentDetectedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e IncidentDetectedEvent) GetSubject() Subject { +func (e IncidentDetectedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e IncidentDetectedEvent) GetCustomData() (interface{}, error) { +func (e IncidentDetectedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e IncidentDetectedEvent) GetCustomDataAs(receiver interface{}) error { +func (e IncidentDetectedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e IncidentDetectedEvent) GetCustomDataRaw() ([]byte, error) { +func (e IncidentDetectedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e IncidentDetectedEvent) GetCustomDataContentType() string { +func (e IncidentDetectedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *IncidentDetectedEvent) SetId(id string) { +func (e *IncidentDetectedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *IncidentDetectedEvent) SetSource(source string) { +func (e *IncidentDetectedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -125,19 +125,19 @@ func (e *IncidentDetectedEvent) SetSource(source string) { } } -func (e *IncidentDetectedEvent) SetTimestamp(timestamp time.Time) { +func (e *IncidentDetectedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *IncidentDetectedEvent) SetSubjectId(subjectId string) { +func (e *IncidentDetectedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *IncidentDetectedEvent) SetSubjectSource(subjectSource string) { +func (e *IncidentDetectedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *IncidentDetectedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *IncidentDetectedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -147,34 +147,34 @@ func (e *IncidentDetectedEvent) SetCustomData(contentType string, data interface return nil } -func (e IncidentDetectedEvent) GetSchema() (string, string) { +func (e IncidentDetectedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), incidentdetectedschema } // Set subject custom fields -func (e *IncidentDetectedEvent) SetSubjectArtifactId(artifactId string) { +func (e *IncidentDetectedEventV0_1_0) SetSubjectArtifactId(artifactId string) { e.Subject.Content.ArtifactId = artifactId } -func (e *IncidentDetectedEvent) SetSubjectDescription(description string) { +func (e *IncidentDetectedEventV0_1_0) SetSubjectDescription(description string) { e.Subject.Content.Description = description } -func (e *IncidentDetectedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *IncidentDetectedEventV0_1_0) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -func (e *IncidentDetectedEvent) SetSubjectService(service *Reference) { +func (e *IncidentDetectedEventV0_1_0) SetSubjectService(service *Reference) { e.Subject.Content.Service = service } -// New creates a new IncidentDetectedEvent -func NewIncidentDetectedEvent() (*IncidentDetectedEvent, error) { - e := &IncidentDetectedEvent{ +// New creates a new IncidentDetectedEventV0_1_0 +func NewIncidentDetectedEventV0_1_0() (*IncidentDetectedEventV0_1_0, error) { + e := &IncidentDetectedEventV0_1_0{ Context: Context{ - Type: IncidentDetectedEventV1.String(), + Type: IncidentDetectedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: IncidentDetectedSubject{ diff --git a/pkg/api/zz_incidentreported.go b/pkg/api/zz_incidentreported_0_1_0.go similarity index 69% rename from pkg/api/zz_incidentreported.go rename to pkg/api/zz_incidentreported_0_1_0.go index 4f73d77..09d7a43 100644 --- a/pkg/api/zz_incidentreported.go +++ b/pkg/api/zz_incidentreported_0_1_0.go @@ -28,8 +28,8 @@ import ( var incidentreportedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/incident-reported-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.incident.reported.0.1.0"],"default":"dev.cdevents.incident.reported.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["incident"],"default":"incident"},"content":{"properties":{"description":{"type":"string"},"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"ticketURI":{"type":"string","format":"uri","minLength":1},"service":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"artifactId":{"type":"string","minLength":1}},"additionalProperties":false,"type":"object","required":["environment","ticketURI"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // IncidentReported event v0.1.0 - IncidentReportedEventV1 CDEventType = CDEventType{ + // IncidentReported event type v0.1.0 + IncidentReportedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "incident", Predicate: "reported", Version: "0.1.0", @@ -57,7 +57,7 @@ func (sc IncidentReportedSubject) GetSubjectType() SubjectType { return "incident" } -type IncidentReportedEvent struct { +type IncidentReportedEventV0_1_0 struct { Context Context `json:"context"` Subject IncidentReportedSubject `json:"subject"` CDEventCustomData @@ -65,61 +65,61 @@ type IncidentReportedEvent struct { // CDEventsReader implementation -func (e IncidentReportedEvent) GetType() CDEventType { - return IncidentReportedEventV1 +func (e IncidentReportedEventV0_1_0) GetType() CDEventType { + return IncidentReportedEventTypeV0_1_0 } -func (e IncidentReportedEvent) GetVersion() string { +func (e IncidentReportedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e IncidentReportedEvent) GetId() string { +func (e IncidentReportedEventV0_1_0) GetId() string { return e.Context.Id } -func (e IncidentReportedEvent) GetSource() string { +func (e IncidentReportedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e IncidentReportedEvent) GetTimestamp() time.Time { +func (e IncidentReportedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e IncidentReportedEvent) GetSubjectId() string { +func (e IncidentReportedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e IncidentReportedEvent) GetSubjectSource() string { +func (e IncidentReportedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e IncidentReportedEvent) GetSubject() Subject { +func (e IncidentReportedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e IncidentReportedEvent) GetCustomData() (interface{}, error) { +func (e IncidentReportedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e IncidentReportedEvent) GetCustomDataAs(receiver interface{}) error { +func (e IncidentReportedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e IncidentReportedEvent) GetCustomDataRaw() ([]byte, error) { +func (e IncidentReportedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e IncidentReportedEvent) GetCustomDataContentType() string { +func (e IncidentReportedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *IncidentReportedEvent) SetId(id string) { +func (e *IncidentReportedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *IncidentReportedEvent) SetSource(source string) { +func (e *IncidentReportedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -127,19 +127,19 @@ func (e *IncidentReportedEvent) SetSource(source string) { } } -func (e *IncidentReportedEvent) SetTimestamp(timestamp time.Time) { +func (e *IncidentReportedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *IncidentReportedEvent) SetSubjectId(subjectId string) { +func (e *IncidentReportedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *IncidentReportedEvent) SetSubjectSource(subjectSource string) { +func (e *IncidentReportedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *IncidentReportedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *IncidentReportedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -149,38 +149,38 @@ func (e *IncidentReportedEvent) SetCustomData(contentType string, data interface return nil } -func (e IncidentReportedEvent) GetSchema() (string, string) { +func (e IncidentReportedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), incidentreportedschema } // Set subject custom fields -func (e *IncidentReportedEvent) SetSubjectArtifactId(artifactId string) { +func (e *IncidentReportedEventV0_1_0) SetSubjectArtifactId(artifactId string) { e.Subject.Content.ArtifactId = artifactId } -func (e *IncidentReportedEvent) SetSubjectDescription(description string) { +func (e *IncidentReportedEventV0_1_0) SetSubjectDescription(description string) { e.Subject.Content.Description = description } -func (e *IncidentReportedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *IncidentReportedEventV0_1_0) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -func (e *IncidentReportedEvent) SetSubjectService(service *Reference) { +func (e *IncidentReportedEventV0_1_0) SetSubjectService(service *Reference) { e.Subject.Content.Service = service } -func (e *IncidentReportedEvent) SetSubjectTicketURI(ticketURI string) { +func (e *IncidentReportedEventV0_1_0) SetSubjectTicketURI(ticketURI string) { e.Subject.Content.TicketURI = ticketURI } -// New creates a new IncidentReportedEvent -func NewIncidentReportedEvent() (*IncidentReportedEvent, error) { - e := &IncidentReportedEvent{ +// New creates a new IncidentReportedEventV0_1_0 +func NewIncidentReportedEventV0_1_0() (*IncidentReportedEventV0_1_0, error) { + e := &IncidentReportedEventV0_1_0{ Context: Context{ - Type: IncidentReportedEventV1.String(), + Type: IncidentReportedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: IncidentReportedSubject{ diff --git a/pkg/api/zz_incidentresolved.go b/pkg/api/zz_incidentresolved_0_1_0.go similarity index 69% rename from pkg/api/zz_incidentresolved.go rename to pkg/api/zz_incidentresolved_0_1_0.go index cd8df2f..9b24907 100644 --- a/pkg/api/zz_incidentresolved.go +++ b/pkg/api/zz_incidentresolved_0_1_0.go @@ -28,8 +28,8 @@ import ( var incidentresolvedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/incident-resolved-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.incident.resolved.0.1.0"],"default":"dev.cdevents.incident.resolved.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["incident"],"default":"incident"},"content":{"properties":{"description":{"type":"string"},"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"service":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"artifactId":{"type":"string","minLength":1}},"additionalProperties":false,"type":"object","required":["environment"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // IncidentResolved event v0.1.0 - IncidentResolvedEventV1 CDEventType = CDEventType{ + // IncidentResolved event type v0.1.0 + IncidentResolvedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "incident", Predicate: "resolved", Version: "0.1.0", @@ -55,7 +55,7 @@ func (sc IncidentResolvedSubject) GetSubjectType() SubjectType { return "incident" } -type IncidentResolvedEvent struct { +type IncidentResolvedEventV0_1_0 struct { Context Context `json:"context"` Subject IncidentResolvedSubject `json:"subject"` CDEventCustomData @@ -63,61 +63,61 @@ type IncidentResolvedEvent struct { // CDEventsReader implementation -func (e IncidentResolvedEvent) GetType() CDEventType { - return IncidentResolvedEventV1 +func (e IncidentResolvedEventV0_1_0) GetType() CDEventType { + return IncidentResolvedEventTypeV0_1_0 } -func (e IncidentResolvedEvent) GetVersion() string { +func (e IncidentResolvedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e IncidentResolvedEvent) GetId() string { +func (e IncidentResolvedEventV0_1_0) GetId() string { return e.Context.Id } -func (e IncidentResolvedEvent) GetSource() string { +func (e IncidentResolvedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e IncidentResolvedEvent) GetTimestamp() time.Time { +func (e IncidentResolvedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e IncidentResolvedEvent) GetSubjectId() string { +func (e IncidentResolvedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e IncidentResolvedEvent) GetSubjectSource() string { +func (e IncidentResolvedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e IncidentResolvedEvent) GetSubject() Subject { +func (e IncidentResolvedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e IncidentResolvedEvent) GetCustomData() (interface{}, error) { +func (e IncidentResolvedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e IncidentResolvedEvent) GetCustomDataAs(receiver interface{}) error { +func (e IncidentResolvedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e IncidentResolvedEvent) GetCustomDataRaw() ([]byte, error) { +func (e IncidentResolvedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e IncidentResolvedEvent) GetCustomDataContentType() string { +func (e IncidentResolvedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *IncidentResolvedEvent) SetId(id string) { +func (e *IncidentResolvedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *IncidentResolvedEvent) SetSource(source string) { +func (e *IncidentResolvedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -125,19 +125,19 @@ func (e *IncidentResolvedEvent) SetSource(source string) { } } -func (e *IncidentResolvedEvent) SetTimestamp(timestamp time.Time) { +func (e *IncidentResolvedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *IncidentResolvedEvent) SetSubjectId(subjectId string) { +func (e *IncidentResolvedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *IncidentResolvedEvent) SetSubjectSource(subjectSource string) { +func (e *IncidentResolvedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *IncidentResolvedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *IncidentResolvedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -147,34 +147,34 @@ func (e *IncidentResolvedEvent) SetCustomData(contentType string, data interface return nil } -func (e IncidentResolvedEvent) GetSchema() (string, string) { +func (e IncidentResolvedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), incidentresolvedschema } // Set subject custom fields -func (e *IncidentResolvedEvent) SetSubjectArtifactId(artifactId string) { +func (e *IncidentResolvedEventV0_1_0) SetSubjectArtifactId(artifactId string) { e.Subject.Content.ArtifactId = artifactId } -func (e *IncidentResolvedEvent) SetSubjectDescription(description string) { +func (e *IncidentResolvedEventV0_1_0) SetSubjectDescription(description string) { e.Subject.Content.Description = description } -func (e *IncidentResolvedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *IncidentResolvedEventV0_1_0) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -func (e *IncidentResolvedEvent) SetSubjectService(service *Reference) { +func (e *IncidentResolvedEventV0_1_0) SetSubjectService(service *Reference) { e.Subject.Content.Service = service } -// New creates a new IncidentResolvedEvent -func NewIncidentResolvedEvent() (*IncidentResolvedEvent, error) { - e := &IncidentResolvedEvent{ +// New creates a new IncidentResolvedEventV0_1_0 +func NewIncidentResolvedEventV0_1_0() (*IncidentResolvedEventV0_1_0, error) { + e := &IncidentResolvedEventV0_1_0{ Context: Context{ - Type: IncidentResolvedEventV1.String(), + Type: IncidentResolvedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: IncidentResolvedSubject{ diff --git a/pkg/api/zz_pipelinerunfinished.go b/pkg/api/zz_pipelinerunfinished_0_1_1.go similarity index 66% rename from pkg/api/zz_pipelinerunfinished.go rename to pkg/api/zz_pipelinerunfinished_0_1_1.go index e7c3739..f4a5574 100644 --- a/pkg/api/zz_pipelinerunfinished.go +++ b/pkg/api/zz_pipelinerunfinished_0_1_1.go @@ -28,8 +28,8 @@ import ( var pipelinerunfinishedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/pipeline-run-finished-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.pipelinerun.finished.0.1.1"],"default":"dev.cdevents.pipelinerun.finished.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["pipelineRun"],"default":"pipelineRun"},"content":{"properties":{"pipelineName":{"type":"string"},"url":{"type":"string"},"outcome":{"type":"string"},"errors":{"type":"string"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // PipelineRunFinished event v0.1.1 - PipelineRunFinishedEventV1 CDEventType = CDEventType{ + // PipelineRunFinished event type v0.1.1 + PipelineRunFinishedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "pipelinerun", Predicate: "finished", Version: "0.1.1", @@ -55,7 +55,7 @@ func (sc PipelineRunFinishedSubject) GetSubjectType() SubjectType { return "pipelineRun" } -type PipelineRunFinishedEvent struct { +type PipelineRunFinishedEventV0_1_1 struct { Context Context `json:"context"` Subject PipelineRunFinishedSubject `json:"subject"` CDEventCustomData @@ -63,61 +63,61 @@ type PipelineRunFinishedEvent struct { // CDEventsReader implementation -func (e PipelineRunFinishedEvent) GetType() CDEventType { - return PipelineRunFinishedEventV1 +func (e PipelineRunFinishedEventV0_1_1) GetType() CDEventType { + return PipelineRunFinishedEventTypeV0_1_1 } -func (e PipelineRunFinishedEvent) GetVersion() string { +func (e PipelineRunFinishedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e PipelineRunFinishedEvent) GetId() string { +func (e PipelineRunFinishedEventV0_1_1) GetId() string { return e.Context.Id } -func (e PipelineRunFinishedEvent) GetSource() string { +func (e PipelineRunFinishedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e PipelineRunFinishedEvent) GetTimestamp() time.Time { +func (e PipelineRunFinishedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e PipelineRunFinishedEvent) GetSubjectId() string { +func (e PipelineRunFinishedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e PipelineRunFinishedEvent) GetSubjectSource() string { +func (e PipelineRunFinishedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e PipelineRunFinishedEvent) GetSubject() Subject { +func (e PipelineRunFinishedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e PipelineRunFinishedEvent) GetCustomData() (interface{}, error) { +func (e PipelineRunFinishedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e PipelineRunFinishedEvent) GetCustomDataAs(receiver interface{}) error { +func (e PipelineRunFinishedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e PipelineRunFinishedEvent) GetCustomDataRaw() ([]byte, error) { +func (e PipelineRunFinishedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e PipelineRunFinishedEvent) GetCustomDataContentType() string { +func (e PipelineRunFinishedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *PipelineRunFinishedEvent) SetId(id string) { +func (e *PipelineRunFinishedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *PipelineRunFinishedEvent) SetSource(source string) { +func (e *PipelineRunFinishedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -125,19 +125,19 @@ func (e *PipelineRunFinishedEvent) SetSource(source string) { } } -func (e *PipelineRunFinishedEvent) SetTimestamp(timestamp time.Time) { +func (e *PipelineRunFinishedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *PipelineRunFinishedEvent) SetSubjectId(subjectId string) { +func (e *PipelineRunFinishedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *PipelineRunFinishedEvent) SetSubjectSource(subjectSource string) { +func (e *PipelineRunFinishedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *PipelineRunFinishedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *PipelineRunFinishedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -147,34 +147,34 @@ func (e *PipelineRunFinishedEvent) SetCustomData(contentType string, data interf return nil } -func (e PipelineRunFinishedEvent) GetSchema() (string, string) { +func (e PipelineRunFinishedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), pipelinerunfinishedschema } // Set subject custom fields -func (e *PipelineRunFinishedEvent) SetSubjectErrors(errors string) { +func (e *PipelineRunFinishedEventV0_1_1) SetSubjectErrors(errors string) { e.Subject.Content.Errors = errors } -func (e *PipelineRunFinishedEvent) SetSubjectOutcome(outcome string) { +func (e *PipelineRunFinishedEventV0_1_1) SetSubjectOutcome(outcome string) { e.Subject.Content.Outcome = outcome } -func (e *PipelineRunFinishedEvent) SetSubjectPipelineName(pipelineName string) { +func (e *PipelineRunFinishedEventV0_1_1) SetSubjectPipelineName(pipelineName string) { e.Subject.Content.PipelineName = pipelineName } -func (e *PipelineRunFinishedEvent) SetSubjectUrl(url string) { +func (e *PipelineRunFinishedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -// New creates a new PipelineRunFinishedEvent -func NewPipelineRunFinishedEvent() (*PipelineRunFinishedEvent, error) { - e := &PipelineRunFinishedEvent{ +// New creates a new PipelineRunFinishedEventV0_1_1 +func NewPipelineRunFinishedEventV0_1_1() (*PipelineRunFinishedEventV0_1_1, error) { + e := &PipelineRunFinishedEventV0_1_1{ Context: Context{ - Type: PipelineRunFinishedEventV1.String(), + Type: PipelineRunFinishedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: PipelineRunFinishedSubject{ diff --git a/pkg/api/zz_pipelinerunqueued.go b/pkg/api/zz_pipelinerunqueued_0_1_1.go similarity index 67% rename from pkg/api/zz_pipelinerunqueued.go rename to pkg/api/zz_pipelinerunqueued_0_1_1.go index 4b8bb15..fdf4034 100644 --- a/pkg/api/zz_pipelinerunqueued.go +++ b/pkg/api/zz_pipelinerunqueued_0_1_1.go @@ -28,8 +28,8 @@ import ( var pipelinerunqueuedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/pipeline-run-queued-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.pipelinerun.queued.0.1.1"],"default":"dev.cdevents.pipelinerun.queued.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["pipelineRun"],"default":"pipelineRun"},"content":{"properties":{"pipelineName":{"type":"string"},"url":{"type":"string"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // PipelineRunQueued event v0.1.1 - PipelineRunQueuedEventV1 CDEventType = CDEventType{ + // PipelineRunQueued event type v0.1.1 + PipelineRunQueuedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "pipelinerun", Predicate: "queued", Version: "0.1.1", @@ -51,7 +51,7 @@ func (sc PipelineRunQueuedSubject) GetSubjectType() SubjectType { return "pipelineRun" } -type PipelineRunQueuedEvent struct { +type PipelineRunQueuedEventV0_1_1 struct { Context Context `json:"context"` Subject PipelineRunQueuedSubject `json:"subject"` CDEventCustomData @@ -59,61 +59,61 @@ type PipelineRunQueuedEvent struct { // CDEventsReader implementation -func (e PipelineRunQueuedEvent) GetType() CDEventType { - return PipelineRunQueuedEventV1 +func (e PipelineRunQueuedEventV0_1_1) GetType() CDEventType { + return PipelineRunQueuedEventTypeV0_1_1 } -func (e PipelineRunQueuedEvent) GetVersion() string { +func (e PipelineRunQueuedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e PipelineRunQueuedEvent) GetId() string { +func (e PipelineRunQueuedEventV0_1_1) GetId() string { return e.Context.Id } -func (e PipelineRunQueuedEvent) GetSource() string { +func (e PipelineRunQueuedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e PipelineRunQueuedEvent) GetTimestamp() time.Time { +func (e PipelineRunQueuedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e PipelineRunQueuedEvent) GetSubjectId() string { +func (e PipelineRunQueuedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e PipelineRunQueuedEvent) GetSubjectSource() string { +func (e PipelineRunQueuedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e PipelineRunQueuedEvent) GetSubject() Subject { +func (e PipelineRunQueuedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e PipelineRunQueuedEvent) GetCustomData() (interface{}, error) { +func (e PipelineRunQueuedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e PipelineRunQueuedEvent) GetCustomDataAs(receiver interface{}) error { +func (e PipelineRunQueuedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e PipelineRunQueuedEvent) GetCustomDataRaw() ([]byte, error) { +func (e PipelineRunQueuedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e PipelineRunQueuedEvent) GetCustomDataContentType() string { +func (e PipelineRunQueuedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *PipelineRunQueuedEvent) SetId(id string) { +func (e *PipelineRunQueuedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *PipelineRunQueuedEvent) SetSource(source string) { +func (e *PipelineRunQueuedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -121,19 +121,19 @@ func (e *PipelineRunQueuedEvent) SetSource(source string) { } } -func (e *PipelineRunQueuedEvent) SetTimestamp(timestamp time.Time) { +func (e *PipelineRunQueuedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *PipelineRunQueuedEvent) SetSubjectId(subjectId string) { +func (e *PipelineRunQueuedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *PipelineRunQueuedEvent) SetSubjectSource(subjectSource string) { +func (e *PipelineRunQueuedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *PipelineRunQueuedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *PipelineRunQueuedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -143,26 +143,26 @@ func (e *PipelineRunQueuedEvent) SetCustomData(contentType string, data interfac return nil } -func (e PipelineRunQueuedEvent) GetSchema() (string, string) { +func (e PipelineRunQueuedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), pipelinerunqueuedschema } // Set subject custom fields -func (e *PipelineRunQueuedEvent) SetSubjectPipelineName(pipelineName string) { +func (e *PipelineRunQueuedEventV0_1_1) SetSubjectPipelineName(pipelineName string) { e.Subject.Content.PipelineName = pipelineName } -func (e *PipelineRunQueuedEvent) SetSubjectUrl(url string) { +func (e *PipelineRunQueuedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -// New creates a new PipelineRunQueuedEvent -func NewPipelineRunQueuedEvent() (*PipelineRunQueuedEvent, error) { - e := &PipelineRunQueuedEvent{ +// New creates a new PipelineRunQueuedEventV0_1_1 +func NewPipelineRunQueuedEventV0_1_1() (*PipelineRunQueuedEventV0_1_1, error) { + e := &PipelineRunQueuedEventV0_1_1{ Context: Context{ - Type: PipelineRunQueuedEventV1.String(), + Type: PipelineRunQueuedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: PipelineRunQueuedSubject{ diff --git a/pkg/api/zz_pipelinerunstarted.go b/pkg/api/zz_pipelinerunstarted_0_1_1.go similarity index 67% rename from pkg/api/zz_pipelinerunstarted.go rename to pkg/api/zz_pipelinerunstarted_0_1_1.go index e51c13c..d0182b1 100644 --- a/pkg/api/zz_pipelinerunstarted.go +++ b/pkg/api/zz_pipelinerunstarted_0_1_1.go @@ -28,8 +28,8 @@ import ( var pipelinerunstartedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/pipeline-run-started-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.pipelinerun.started.0.1.1"],"default":"dev.cdevents.pipelinerun.started.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["pipelineRun"],"default":"pipelineRun"},"content":{"properties":{"pipelineName":{"type":"string"},"url":{"type":"string"}},"additionalProperties":false,"type":"object","required":["pipelineName","url"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // PipelineRunStarted event v0.1.1 - PipelineRunStartedEventV1 CDEventType = CDEventType{ + // PipelineRunStarted event type v0.1.1 + PipelineRunStartedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "pipelinerun", Predicate: "started", Version: "0.1.1", @@ -51,7 +51,7 @@ func (sc PipelineRunStartedSubject) GetSubjectType() SubjectType { return "pipelineRun" } -type PipelineRunStartedEvent struct { +type PipelineRunStartedEventV0_1_1 struct { Context Context `json:"context"` Subject PipelineRunStartedSubject `json:"subject"` CDEventCustomData @@ -59,61 +59,61 @@ type PipelineRunStartedEvent struct { // CDEventsReader implementation -func (e PipelineRunStartedEvent) GetType() CDEventType { - return PipelineRunStartedEventV1 +func (e PipelineRunStartedEventV0_1_1) GetType() CDEventType { + return PipelineRunStartedEventTypeV0_1_1 } -func (e PipelineRunStartedEvent) GetVersion() string { +func (e PipelineRunStartedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e PipelineRunStartedEvent) GetId() string { +func (e PipelineRunStartedEventV0_1_1) GetId() string { return e.Context.Id } -func (e PipelineRunStartedEvent) GetSource() string { +func (e PipelineRunStartedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e PipelineRunStartedEvent) GetTimestamp() time.Time { +func (e PipelineRunStartedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e PipelineRunStartedEvent) GetSubjectId() string { +func (e PipelineRunStartedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e PipelineRunStartedEvent) GetSubjectSource() string { +func (e PipelineRunStartedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e PipelineRunStartedEvent) GetSubject() Subject { +func (e PipelineRunStartedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e PipelineRunStartedEvent) GetCustomData() (interface{}, error) { +func (e PipelineRunStartedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e PipelineRunStartedEvent) GetCustomDataAs(receiver interface{}) error { +func (e PipelineRunStartedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e PipelineRunStartedEvent) GetCustomDataRaw() ([]byte, error) { +func (e PipelineRunStartedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e PipelineRunStartedEvent) GetCustomDataContentType() string { +func (e PipelineRunStartedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *PipelineRunStartedEvent) SetId(id string) { +func (e *PipelineRunStartedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *PipelineRunStartedEvent) SetSource(source string) { +func (e *PipelineRunStartedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -121,19 +121,19 @@ func (e *PipelineRunStartedEvent) SetSource(source string) { } } -func (e *PipelineRunStartedEvent) SetTimestamp(timestamp time.Time) { +func (e *PipelineRunStartedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *PipelineRunStartedEvent) SetSubjectId(subjectId string) { +func (e *PipelineRunStartedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *PipelineRunStartedEvent) SetSubjectSource(subjectSource string) { +func (e *PipelineRunStartedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *PipelineRunStartedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *PipelineRunStartedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -143,26 +143,26 @@ func (e *PipelineRunStartedEvent) SetCustomData(contentType string, data interfa return nil } -func (e PipelineRunStartedEvent) GetSchema() (string, string) { +func (e PipelineRunStartedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), pipelinerunstartedschema } // Set subject custom fields -func (e *PipelineRunStartedEvent) SetSubjectPipelineName(pipelineName string) { +func (e *PipelineRunStartedEventV0_1_1) SetSubjectPipelineName(pipelineName string) { e.Subject.Content.PipelineName = pipelineName } -func (e *PipelineRunStartedEvent) SetSubjectUrl(url string) { +func (e *PipelineRunStartedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -// New creates a new PipelineRunStartedEvent -func NewPipelineRunStartedEvent() (*PipelineRunStartedEvent, error) { - e := &PipelineRunStartedEvent{ +// New creates a new PipelineRunStartedEventV0_1_1 +func NewPipelineRunStartedEventV0_1_1() (*PipelineRunStartedEventV0_1_1, error) { + e := &PipelineRunStartedEventV0_1_1{ Context: Context{ - Type: PipelineRunStartedEventV1.String(), + Type: PipelineRunStartedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: PipelineRunStartedSubject{ diff --git a/pkg/api/zz_repositorycreated.go b/pkg/api/zz_repositorycreated_0_1_1.go similarity index 68% rename from pkg/api/zz_repositorycreated.go rename to pkg/api/zz_repositorycreated_0_1_1.go index 4a440b1..6112e15 100644 --- a/pkg/api/zz_repositorycreated.go +++ b/pkg/api/zz_repositorycreated_0_1_1.go @@ -28,8 +28,8 @@ import ( var repositorycreatedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/repository-created-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.repository.created.0.1.1"],"default":"dev.cdevents.repository.created.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["repository"],"default":"repository"},"content":{"properties":{"name":{"type":"string","minLength":1},"owner":{"type":"string"},"url":{"type":"string","minLength":1},"viewUrl":{"type":"string"}},"additionalProperties":false,"type":"object","required":["name","url"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // RepositoryCreated event v0.1.1 - RepositoryCreatedEventV1 CDEventType = CDEventType{ + // RepositoryCreated event type v0.1.1 + RepositoryCreatedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "repository", Predicate: "created", Version: "0.1.1", @@ -55,7 +55,7 @@ func (sc RepositoryCreatedSubject) GetSubjectType() SubjectType { return "repository" } -type RepositoryCreatedEvent struct { +type RepositoryCreatedEventV0_1_1 struct { Context Context `json:"context"` Subject RepositoryCreatedSubject `json:"subject"` CDEventCustomData @@ -63,61 +63,61 @@ type RepositoryCreatedEvent struct { // CDEventsReader implementation -func (e RepositoryCreatedEvent) GetType() CDEventType { - return RepositoryCreatedEventV1 +func (e RepositoryCreatedEventV0_1_1) GetType() CDEventType { + return RepositoryCreatedEventTypeV0_1_1 } -func (e RepositoryCreatedEvent) GetVersion() string { +func (e RepositoryCreatedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e RepositoryCreatedEvent) GetId() string { +func (e RepositoryCreatedEventV0_1_1) GetId() string { return e.Context.Id } -func (e RepositoryCreatedEvent) GetSource() string { +func (e RepositoryCreatedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e RepositoryCreatedEvent) GetTimestamp() time.Time { +func (e RepositoryCreatedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e RepositoryCreatedEvent) GetSubjectId() string { +func (e RepositoryCreatedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e RepositoryCreatedEvent) GetSubjectSource() string { +func (e RepositoryCreatedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e RepositoryCreatedEvent) GetSubject() Subject { +func (e RepositoryCreatedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e RepositoryCreatedEvent) GetCustomData() (interface{}, error) { +func (e RepositoryCreatedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e RepositoryCreatedEvent) GetCustomDataAs(receiver interface{}) error { +func (e RepositoryCreatedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e RepositoryCreatedEvent) GetCustomDataRaw() ([]byte, error) { +func (e RepositoryCreatedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e RepositoryCreatedEvent) GetCustomDataContentType() string { +func (e RepositoryCreatedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *RepositoryCreatedEvent) SetId(id string) { +func (e *RepositoryCreatedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *RepositoryCreatedEvent) SetSource(source string) { +func (e *RepositoryCreatedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -125,19 +125,19 @@ func (e *RepositoryCreatedEvent) SetSource(source string) { } } -func (e *RepositoryCreatedEvent) SetTimestamp(timestamp time.Time) { +func (e *RepositoryCreatedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *RepositoryCreatedEvent) SetSubjectId(subjectId string) { +func (e *RepositoryCreatedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *RepositoryCreatedEvent) SetSubjectSource(subjectSource string) { +func (e *RepositoryCreatedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *RepositoryCreatedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *RepositoryCreatedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -147,34 +147,34 @@ func (e *RepositoryCreatedEvent) SetCustomData(contentType string, data interfac return nil } -func (e RepositoryCreatedEvent) GetSchema() (string, string) { +func (e RepositoryCreatedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), repositorycreatedschema } // Set subject custom fields -func (e *RepositoryCreatedEvent) SetSubjectName(name string) { +func (e *RepositoryCreatedEventV0_1_1) SetSubjectName(name string) { e.Subject.Content.Name = name } -func (e *RepositoryCreatedEvent) SetSubjectOwner(owner string) { +func (e *RepositoryCreatedEventV0_1_1) SetSubjectOwner(owner string) { e.Subject.Content.Owner = owner } -func (e *RepositoryCreatedEvent) SetSubjectUrl(url string) { +func (e *RepositoryCreatedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -func (e *RepositoryCreatedEvent) SetSubjectViewUrl(viewUrl string) { +func (e *RepositoryCreatedEventV0_1_1) SetSubjectViewUrl(viewUrl string) { e.Subject.Content.ViewUrl = viewUrl } -// New creates a new RepositoryCreatedEvent -func NewRepositoryCreatedEvent() (*RepositoryCreatedEvent, error) { - e := &RepositoryCreatedEvent{ +// New creates a new RepositoryCreatedEventV0_1_1 +func NewRepositoryCreatedEventV0_1_1() (*RepositoryCreatedEventV0_1_1, error) { + e := &RepositoryCreatedEventV0_1_1{ Context: Context{ - Type: RepositoryCreatedEventV1.String(), + Type: RepositoryCreatedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: RepositoryCreatedSubject{ diff --git a/pkg/api/zz_repositorydeleted.go b/pkg/api/zz_repositorydeleted_0_1_1.go similarity index 67% rename from pkg/api/zz_repositorydeleted.go rename to pkg/api/zz_repositorydeleted_0_1_1.go index 9cafa1c..1fd2062 100644 --- a/pkg/api/zz_repositorydeleted.go +++ b/pkg/api/zz_repositorydeleted_0_1_1.go @@ -28,8 +28,8 @@ import ( var repositorydeletedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/repository-deleted-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.repository.deleted.0.1.1"],"default":"dev.cdevents.repository.deleted.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["repository"],"default":"repository"},"content":{"properties":{"name":{"type":"string"},"owner":{"type":"string"},"url":{"type":"string"},"viewUrl":{"type":"string"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // RepositoryDeleted event v0.1.1 - RepositoryDeletedEventV1 CDEventType = CDEventType{ + // RepositoryDeleted event type v0.1.1 + RepositoryDeletedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "repository", Predicate: "deleted", Version: "0.1.1", @@ -55,7 +55,7 @@ func (sc RepositoryDeletedSubject) GetSubjectType() SubjectType { return "repository" } -type RepositoryDeletedEvent struct { +type RepositoryDeletedEventV0_1_1 struct { Context Context `json:"context"` Subject RepositoryDeletedSubject `json:"subject"` CDEventCustomData @@ -63,61 +63,61 @@ type RepositoryDeletedEvent struct { // CDEventsReader implementation -func (e RepositoryDeletedEvent) GetType() CDEventType { - return RepositoryDeletedEventV1 +func (e RepositoryDeletedEventV0_1_1) GetType() CDEventType { + return RepositoryDeletedEventTypeV0_1_1 } -func (e RepositoryDeletedEvent) GetVersion() string { +func (e RepositoryDeletedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e RepositoryDeletedEvent) GetId() string { +func (e RepositoryDeletedEventV0_1_1) GetId() string { return e.Context.Id } -func (e RepositoryDeletedEvent) GetSource() string { +func (e RepositoryDeletedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e RepositoryDeletedEvent) GetTimestamp() time.Time { +func (e RepositoryDeletedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e RepositoryDeletedEvent) GetSubjectId() string { +func (e RepositoryDeletedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e RepositoryDeletedEvent) GetSubjectSource() string { +func (e RepositoryDeletedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e RepositoryDeletedEvent) GetSubject() Subject { +func (e RepositoryDeletedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e RepositoryDeletedEvent) GetCustomData() (interface{}, error) { +func (e RepositoryDeletedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e RepositoryDeletedEvent) GetCustomDataAs(receiver interface{}) error { +func (e RepositoryDeletedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e RepositoryDeletedEvent) GetCustomDataRaw() ([]byte, error) { +func (e RepositoryDeletedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e RepositoryDeletedEvent) GetCustomDataContentType() string { +func (e RepositoryDeletedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *RepositoryDeletedEvent) SetId(id string) { +func (e *RepositoryDeletedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *RepositoryDeletedEvent) SetSource(source string) { +func (e *RepositoryDeletedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -125,19 +125,19 @@ func (e *RepositoryDeletedEvent) SetSource(source string) { } } -func (e *RepositoryDeletedEvent) SetTimestamp(timestamp time.Time) { +func (e *RepositoryDeletedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *RepositoryDeletedEvent) SetSubjectId(subjectId string) { +func (e *RepositoryDeletedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *RepositoryDeletedEvent) SetSubjectSource(subjectSource string) { +func (e *RepositoryDeletedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *RepositoryDeletedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *RepositoryDeletedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -147,34 +147,34 @@ func (e *RepositoryDeletedEvent) SetCustomData(contentType string, data interfac return nil } -func (e RepositoryDeletedEvent) GetSchema() (string, string) { +func (e RepositoryDeletedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), repositorydeletedschema } // Set subject custom fields -func (e *RepositoryDeletedEvent) SetSubjectName(name string) { +func (e *RepositoryDeletedEventV0_1_1) SetSubjectName(name string) { e.Subject.Content.Name = name } -func (e *RepositoryDeletedEvent) SetSubjectOwner(owner string) { +func (e *RepositoryDeletedEventV0_1_1) SetSubjectOwner(owner string) { e.Subject.Content.Owner = owner } -func (e *RepositoryDeletedEvent) SetSubjectUrl(url string) { +func (e *RepositoryDeletedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -func (e *RepositoryDeletedEvent) SetSubjectViewUrl(viewUrl string) { +func (e *RepositoryDeletedEventV0_1_1) SetSubjectViewUrl(viewUrl string) { e.Subject.Content.ViewUrl = viewUrl } -// New creates a new RepositoryDeletedEvent -func NewRepositoryDeletedEvent() (*RepositoryDeletedEvent, error) { - e := &RepositoryDeletedEvent{ +// New creates a new RepositoryDeletedEventV0_1_1 +func NewRepositoryDeletedEventV0_1_1() (*RepositoryDeletedEventV0_1_1, error) { + e := &RepositoryDeletedEventV0_1_1{ Context: Context{ - Type: RepositoryDeletedEventV1.String(), + Type: RepositoryDeletedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: RepositoryDeletedSubject{ diff --git a/pkg/api/zz_repositorymodified.go b/pkg/api/zz_repositorymodified_0_1_1.go similarity index 66% rename from pkg/api/zz_repositorymodified.go rename to pkg/api/zz_repositorymodified_0_1_1.go index 6128478..24b8142 100644 --- a/pkg/api/zz_repositorymodified.go +++ b/pkg/api/zz_repositorymodified_0_1_1.go @@ -28,8 +28,8 @@ import ( var repositorymodifiedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/repository-modified-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.repository.modified.0.1.1"],"default":"dev.cdevents.repository.modified.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["repository"],"default":"repository"},"content":{"properties":{"name":{"type":"string"},"owner":{"type":"string"},"url":{"type":"string"},"viewUrl":{"type":"string"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // RepositoryModified event v0.1.1 - RepositoryModifiedEventV1 CDEventType = CDEventType{ + // RepositoryModified event type v0.1.1 + RepositoryModifiedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "repository", Predicate: "modified", Version: "0.1.1", @@ -55,7 +55,7 @@ func (sc RepositoryModifiedSubject) GetSubjectType() SubjectType { return "repository" } -type RepositoryModifiedEvent struct { +type RepositoryModifiedEventV0_1_1 struct { Context Context `json:"context"` Subject RepositoryModifiedSubject `json:"subject"` CDEventCustomData @@ -63,61 +63,61 @@ type RepositoryModifiedEvent struct { // CDEventsReader implementation -func (e RepositoryModifiedEvent) GetType() CDEventType { - return RepositoryModifiedEventV1 +func (e RepositoryModifiedEventV0_1_1) GetType() CDEventType { + return RepositoryModifiedEventTypeV0_1_1 } -func (e RepositoryModifiedEvent) GetVersion() string { +func (e RepositoryModifiedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e RepositoryModifiedEvent) GetId() string { +func (e RepositoryModifiedEventV0_1_1) GetId() string { return e.Context.Id } -func (e RepositoryModifiedEvent) GetSource() string { +func (e RepositoryModifiedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e RepositoryModifiedEvent) GetTimestamp() time.Time { +func (e RepositoryModifiedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e RepositoryModifiedEvent) GetSubjectId() string { +func (e RepositoryModifiedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e RepositoryModifiedEvent) GetSubjectSource() string { +func (e RepositoryModifiedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e RepositoryModifiedEvent) GetSubject() Subject { +func (e RepositoryModifiedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e RepositoryModifiedEvent) GetCustomData() (interface{}, error) { +func (e RepositoryModifiedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e RepositoryModifiedEvent) GetCustomDataAs(receiver interface{}) error { +func (e RepositoryModifiedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e RepositoryModifiedEvent) GetCustomDataRaw() ([]byte, error) { +func (e RepositoryModifiedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e RepositoryModifiedEvent) GetCustomDataContentType() string { +func (e RepositoryModifiedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *RepositoryModifiedEvent) SetId(id string) { +func (e *RepositoryModifiedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *RepositoryModifiedEvent) SetSource(source string) { +func (e *RepositoryModifiedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -125,19 +125,19 @@ func (e *RepositoryModifiedEvent) SetSource(source string) { } } -func (e *RepositoryModifiedEvent) SetTimestamp(timestamp time.Time) { +func (e *RepositoryModifiedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *RepositoryModifiedEvent) SetSubjectId(subjectId string) { +func (e *RepositoryModifiedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *RepositoryModifiedEvent) SetSubjectSource(subjectSource string) { +func (e *RepositoryModifiedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *RepositoryModifiedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *RepositoryModifiedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -147,34 +147,34 @@ func (e *RepositoryModifiedEvent) SetCustomData(contentType string, data interfa return nil } -func (e RepositoryModifiedEvent) GetSchema() (string, string) { +func (e RepositoryModifiedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), repositorymodifiedschema } // Set subject custom fields -func (e *RepositoryModifiedEvent) SetSubjectName(name string) { +func (e *RepositoryModifiedEventV0_1_1) SetSubjectName(name string) { e.Subject.Content.Name = name } -func (e *RepositoryModifiedEvent) SetSubjectOwner(owner string) { +func (e *RepositoryModifiedEventV0_1_1) SetSubjectOwner(owner string) { e.Subject.Content.Owner = owner } -func (e *RepositoryModifiedEvent) SetSubjectUrl(url string) { +func (e *RepositoryModifiedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -func (e *RepositoryModifiedEvent) SetSubjectViewUrl(viewUrl string) { +func (e *RepositoryModifiedEventV0_1_1) SetSubjectViewUrl(viewUrl string) { e.Subject.Content.ViewUrl = viewUrl } -// New creates a new RepositoryModifiedEvent -func NewRepositoryModifiedEvent() (*RepositoryModifiedEvent, error) { - e := &RepositoryModifiedEvent{ +// New creates a new RepositoryModifiedEventV0_1_1 +func NewRepositoryModifiedEventV0_1_1() (*RepositoryModifiedEventV0_1_1, error) { + e := &RepositoryModifiedEventV0_1_1{ Context: Context{ - Type: RepositoryModifiedEventV1.String(), + Type: RepositoryModifiedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: RepositoryModifiedSubject{ diff --git a/pkg/api/zz_servicedeployed.go b/pkg/api/zz_servicedeployed_0_1_1.go similarity index 69% rename from pkg/api/zz_servicedeployed.go rename to pkg/api/zz_servicedeployed_0_1_1.go index 78b3a2f..0496e78 100644 --- a/pkg/api/zz_servicedeployed.go +++ b/pkg/api/zz_servicedeployed_0_1_1.go @@ -28,8 +28,8 @@ import ( var servicedeployedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/service-deployed-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.service.deployed.0.1.1"],"default":"dev.cdevents.service.deployed.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["service"],"default":"service"},"content":{"properties":{"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"artifactId":{"type":"string","minLength":1}},"additionalProperties":false,"type":"object","required":["environment","artifactId"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ServiceDeployed event v0.1.1 - ServiceDeployedEventV1 CDEventType = CDEventType{ + // ServiceDeployed event type v0.1.1 + ServiceDeployedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "service", Predicate: "deployed", Version: "0.1.1", @@ -51,7 +51,7 @@ func (sc ServiceDeployedSubject) GetSubjectType() SubjectType { return "service" } -type ServiceDeployedEvent struct { +type ServiceDeployedEventV0_1_1 struct { Context Context `json:"context"` Subject ServiceDeployedSubject `json:"subject"` CDEventCustomData @@ -59,61 +59,61 @@ type ServiceDeployedEvent struct { // CDEventsReader implementation -func (e ServiceDeployedEvent) GetType() CDEventType { - return ServiceDeployedEventV1 +func (e ServiceDeployedEventV0_1_1) GetType() CDEventType { + return ServiceDeployedEventTypeV0_1_1 } -func (e ServiceDeployedEvent) GetVersion() string { +func (e ServiceDeployedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e ServiceDeployedEvent) GetId() string { +func (e ServiceDeployedEventV0_1_1) GetId() string { return e.Context.Id } -func (e ServiceDeployedEvent) GetSource() string { +func (e ServiceDeployedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e ServiceDeployedEvent) GetTimestamp() time.Time { +func (e ServiceDeployedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ServiceDeployedEvent) GetSubjectId() string { +func (e ServiceDeployedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e ServiceDeployedEvent) GetSubjectSource() string { +func (e ServiceDeployedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e ServiceDeployedEvent) GetSubject() Subject { +func (e ServiceDeployedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e ServiceDeployedEvent) GetCustomData() (interface{}, error) { +func (e ServiceDeployedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ServiceDeployedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ServiceDeployedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ServiceDeployedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ServiceDeployedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ServiceDeployedEvent) GetCustomDataContentType() string { +func (e ServiceDeployedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ServiceDeployedEvent) SetId(id string) { +func (e *ServiceDeployedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *ServiceDeployedEvent) SetSource(source string) { +func (e *ServiceDeployedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -121,19 +121,19 @@ func (e *ServiceDeployedEvent) SetSource(source string) { } } -func (e *ServiceDeployedEvent) SetTimestamp(timestamp time.Time) { +func (e *ServiceDeployedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ServiceDeployedEvent) SetSubjectId(subjectId string) { +func (e *ServiceDeployedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ServiceDeployedEvent) SetSubjectSource(subjectSource string) { +func (e *ServiceDeployedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ServiceDeployedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ServiceDeployedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -143,26 +143,26 @@ func (e *ServiceDeployedEvent) SetCustomData(contentType string, data interface{ return nil } -func (e ServiceDeployedEvent) GetSchema() (string, string) { +func (e ServiceDeployedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), servicedeployedschema } // Set subject custom fields -func (e *ServiceDeployedEvent) SetSubjectArtifactId(artifactId string) { +func (e *ServiceDeployedEventV0_1_1) SetSubjectArtifactId(artifactId string) { e.Subject.Content.ArtifactId = artifactId } -func (e *ServiceDeployedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *ServiceDeployedEventV0_1_1) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -// New creates a new ServiceDeployedEvent -func NewServiceDeployedEvent() (*ServiceDeployedEvent, error) { - e := &ServiceDeployedEvent{ +// New creates a new ServiceDeployedEventV0_1_1 +func NewServiceDeployedEventV0_1_1() (*ServiceDeployedEventV0_1_1, error) { + e := &ServiceDeployedEventV0_1_1{ Context: Context{ - Type: ServiceDeployedEventV1.String(), + Type: ServiceDeployedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: ServiceDeployedSubject{ diff --git a/pkg/api/zz_servicepublished.go b/pkg/api/zz_servicepublished_0_1_1.go similarity index 68% rename from pkg/api/zz_servicepublished.go rename to pkg/api/zz_servicepublished_0_1_1.go index a9d71c8..8073199 100644 --- a/pkg/api/zz_servicepublished.go +++ b/pkg/api/zz_servicepublished_0_1_1.go @@ -28,8 +28,8 @@ import ( var servicepublishedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/service-published-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.service.published.0.1.1"],"default":"dev.cdevents.service.published.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["service"],"default":"service"},"content":{"properties":{"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ServicePublished event v0.1.1 - ServicePublishedEventV1 CDEventType = CDEventType{ + // ServicePublished event type v0.1.1 + ServicePublishedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "service", Predicate: "published", Version: "0.1.1", @@ -49,7 +49,7 @@ func (sc ServicePublishedSubject) GetSubjectType() SubjectType { return "service" } -type ServicePublishedEvent struct { +type ServicePublishedEventV0_1_1 struct { Context Context `json:"context"` Subject ServicePublishedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type ServicePublishedEvent struct { // CDEventsReader implementation -func (e ServicePublishedEvent) GetType() CDEventType { - return ServicePublishedEventV1 +func (e ServicePublishedEventV0_1_1) GetType() CDEventType { + return ServicePublishedEventTypeV0_1_1 } -func (e ServicePublishedEvent) GetVersion() string { +func (e ServicePublishedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e ServicePublishedEvent) GetId() string { +func (e ServicePublishedEventV0_1_1) GetId() string { return e.Context.Id } -func (e ServicePublishedEvent) GetSource() string { +func (e ServicePublishedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e ServicePublishedEvent) GetTimestamp() time.Time { +func (e ServicePublishedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ServicePublishedEvent) GetSubjectId() string { +func (e ServicePublishedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e ServicePublishedEvent) GetSubjectSource() string { +func (e ServicePublishedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e ServicePublishedEvent) GetSubject() Subject { +func (e ServicePublishedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e ServicePublishedEvent) GetCustomData() (interface{}, error) { +func (e ServicePublishedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ServicePublishedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ServicePublishedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ServicePublishedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ServicePublishedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ServicePublishedEvent) GetCustomDataContentType() string { +func (e ServicePublishedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ServicePublishedEvent) SetId(id string) { +func (e *ServicePublishedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *ServicePublishedEvent) SetSource(source string) { +func (e *ServicePublishedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *ServicePublishedEvent) SetSource(source string) { } } -func (e *ServicePublishedEvent) SetTimestamp(timestamp time.Time) { +func (e *ServicePublishedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ServicePublishedEvent) SetSubjectId(subjectId string) { +func (e *ServicePublishedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ServicePublishedEvent) SetSubjectSource(subjectSource string) { +func (e *ServicePublishedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ServicePublishedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ServicePublishedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *ServicePublishedEvent) SetCustomData(contentType string, data interface return nil } -func (e ServicePublishedEvent) GetSchema() (string, string) { +func (e ServicePublishedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), servicepublishedschema } // Set subject custom fields -func (e *ServicePublishedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *ServicePublishedEventV0_1_1) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -// New creates a new ServicePublishedEvent -func NewServicePublishedEvent() (*ServicePublishedEvent, error) { - e := &ServicePublishedEvent{ +// New creates a new ServicePublishedEventV0_1_1 +func NewServicePublishedEventV0_1_1() (*ServicePublishedEventV0_1_1, error) { + e := &ServicePublishedEventV0_1_1{ Context: Context{ - Type: ServicePublishedEventV1.String(), + Type: ServicePublishedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: ServicePublishedSubject{ diff --git a/pkg/api/zz_serviceremoved.go b/pkg/api/zz_serviceremoved_0_1_1.go similarity index 69% rename from pkg/api/zz_serviceremoved.go rename to pkg/api/zz_serviceremoved_0_1_1.go index 38a3094..d03ce50 100644 --- a/pkg/api/zz_serviceremoved.go +++ b/pkg/api/zz_serviceremoved_0_1_1.go @@ -28,8 +28,8 @@ import ( var serviceremovedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/service-removed-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.service.removed.0.1.1"],"default":"dev.cdevents.service.removed.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["service"],"default":"service"},"content":{"properties":{"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ServiceRemoved event v0.1.1 - ServiceRemovedEventV1 CDEventType = CDEventType{ + // ServiceRemoved event type v0.1.1 + ServiceRemovedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "service", Predicate: "removed", Version: "0.1.1", @@ -49,7 +49,7 @@ func (sc ServiceRemovedSubject) GetSubjectType() SubjectType { return "service" } -type ServiceRemovedEvent struct { +type ServiceRemovedEventV0_1_1 struct { Context Context `json:"context"` Subject ServiceRemovedSubject `json:"subject"` CDEventCustomData @@ -57,61 +57,61 @@ type ServiceRemovedEvent struct { // CDEventsReader implementation -func (e ServiceRemovedEvent) GetType() CDEventType { - return ServiceRemovedEventV1 +func (e ServiceRemovedEventV0_1_1) GetType() CDEventType { + return ServiceRemovedEventTypeV0_1_1 } -func (e ServiceRemovedEvent) GetVersion() string { +func (e ServiceRemovedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e ServiceRemovedEvent) GetId() string { +func (e ServiceRemovedEventV0_1_1) GetId() string { return e.Context.Id } -func (e ServiceRemovedEvent) GetSource() string { +func (e ServiceRemovedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e ServiceRemovedEvent) GetTimestamp() time.Time { +func (e ServiceRemovedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ServiceRemovedEvent) GetSubjectId() string { +func (e ServiceRemovedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e ServiceRemovedEvent) GetSubjectSource() string { +func (e ServiceRemovedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e ServiceRemovedEvent) GetSubject() Subject { +func (e ServiceRemovedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e ServiceRemovedEvent) GetCustomData() (interface{}, error) { +func (e ServiceRemovedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ServiceRemovedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ServiceRemovedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ServiceRemovedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ServiceRemovedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ServiceRemovedEvent) GetCustomDataContentType() string { +func (e ServiceRemovedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ServiceRemovedEvent) SetId(id string) { +func (e *ServiceRemovedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *ServiceRemovedEvent) SetSource(source string) { +func (e *ServiceRemovedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -119,19 +119,19 @@ func (e *ServiceRemovedEvent) SetSource(source string) { } } -func (e *ServiceRemovedEvent) SetTimestamp(timestamp time.Time) { +func (e *ServiceRemovedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ServiceRemovedEvent) SetSubjectId(subjectId string) { +func (e *ServiceRemovedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ServiceRemovedEvent) SetSubjectSource(subjectSource string) { +func (e *ServiceRemovedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ServiceRemovedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ServiceRemovedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -141,22 +141,22 @@ func (e *ServiceRemovedEvent) SetCustomData(contentType string, data interface{} return nil } -func (e ServiceRemovedEvent) GetSchema() (string, string) { +func (e ServiceRemovedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), serviceremovedschema } // Set subject custom fields -func (e *ServiceRemovedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *ServiceRemovedEventV0_1_1) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -// New creates a new ServiceRemovedEvent -func NewServiceRemovedEvent() (*ServiceRemovedEvent, error) { - e := &ServiceRemovedEvent{ +// New creates a new ServiceRemovedEventV0_1_1 +func NewServiceRemovedEventV0_1_1() (*ServiceRemovedEventV0_1_1, error) { + e := &ServiceRemovedEventV0_1_1{ Context: Context{ - Type: ServiceRemovedEventV1.String(), + Type: ServiceRemovedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: ServiceRemovedSubject{ diff --git a/pkg/api/zz_servicerolledback.go b/pkg/api/zz_servicerolledback_0_1_1.go similarity index 68% rename from pkg/api/zz_servicerolledback.go rename to pkg/api/zz_servicerolledback_0_1_1.go index 723b160..79c4e29 100644 --- a/pkg/api/zz_servicerolledback.go +++ b/pkg/api/zz_servicerolledback_0_1_1.go @@ -28,8 +28,8 @@ import ( var servicerolledbackschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/service-rolledback-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.service.rolledback.0.1.1"],"default":"dev.cdevents.service.rolledback.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["service"],"default":"service"},"content":{"properties":{"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"artifactId":{"type":"string","minLength":1}},"additionalProperties":false,"type":"object","required":["environment","artifactId"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ServiceRolledback event v0.1.1 - ServiceRolledbackEventV1 CDEventType = CDEventType{ + // ServiceRolledback event type v0.1.1 + ServiceRolledbackEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "service", Predicate: "rolledback", Version: "0.1.1", @@ -51,7 +51,7 @@ func (sc ServiceRolledbackSubject) GetSubjectType() SubjectType { return "service" } -type ServiceRolledbackEvent struct { +type ServiceRolledbackEventV0_1_1 struct { Context Context `json:"context"` Subject ServiceRolledbackSubject `json:"subject"` CDEventCustomData @@ -59,61 +59,61 @@ type ServiceRolledbackEvent struct { // CDEventsReader implementation -func (e ServiceRolledbackEvent) GetType() CDEventType { - return ServiceRolledbackEventV1 +func (e ServiceRolledbackEventV0_1_1) GetType() CDEventType { + return ServiceRolledbackEventTypeV0_1_1 } -func (e ServiceRolledbackEvent) GetVersion() string { +func (e ServiceRolledbackEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e ServiceRolledbackEvent) GetId() string { +func (e ServiceRolledbackEventV0_1_1) GetId() string { return e.Context.Id } -func (e ServiceRolledbackEvent) GetSource() string { +func (e ServiceRolledbackEventV0_1_1) GetSource() string { return e.Context.Source } -func (e ServiceRolledbackEvent) GetTimestamp() time.Time { +func (e ServiceRolledbackEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ServiceRolledbackEvent) GetSubjectId() string { +func (e ServiceRolledbackEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e ServiceRolledbackEvent) GetSubjectSource() string { +func (e ServiceRolledbackEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e ServiceRolledbackEvent) GetSubject() Subject { +func (e ServiceRolledbackEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e ServiceRolledbackEvent) GetCustomData() (interface{}, error) { +func (e ServiceRolledbackEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ServiceRolledbackEvent) GetCustomDataAs(receiver interface{}) error { +func (e ServiceRolledbackEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ServiceRolledbackEvent) GetCustomDataRaw() ([]byte, error) { +func (e ServiceRolledbackEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ServiceRolledbackEvent) GetCustomDataContentType() string { +func (e ServiceRolledbackEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ServiceRolledbackEvent) SetId(id string) { +func (e *ServiceRolledbackEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *ServiceRolledbackEvent) SetSource(source string) { +func (e *ServiceRolledbackEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -121,19 +121,19 @@ func (e *ServiceRolledbackEvent) SetSource(source string) { } } -func (e *ServiceRolledbackEvent) SetTimestamp(timestamp time.Time) { +func (e *ServiceRolledbackEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ServiceRolledbackEvent) SetSubjectId(subjectId string) { +func (e *ServiceRolledbackEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ServiceRolledbackEvent) SetSubjectSource(subjectSource string) { +func (e *ServiceRolledbackEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ServiceRolledbackEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ServiceRolledbackEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -143,26 +143,26 @@ func (e *ServiceRolledbackEvent) SetCustomData(contentType string, data interfac return nil } -func (e ServiceRolledbackEvent) GetSchema() (string, string) { +func (e ServiceRolledbackEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), servicerolledbackschema } // Set subject custom fields -func (e *ServiceRolledbackEvent) SetSubjectArtifactId(artifactId string) { +func (e *ServiceRolledbackEventV0_1_1) SetSubjectArtifactId(artifactId string) { e.Subject.Content.ArtifactId = artifactId } -func (e *ServiceRolledbackEvent) SetSubjectEnvironment(environment *Reference) { +func (e *ServiceRolledbackEventV0_1_1) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -// New creates a new ServiceRolledbackEvent -func NewServiceRolledbackEvent() (*ServiceRolledbackEvent, error) { - e := &ServiceRolledbackEvent{ +// New creates a new ServiceRolledbackEventV0_1_1 +func NewServiceRolledbackEventV0_1_1() (*ServiceRolledbackEventV0_1_1, error) { + e := &ServiceRolledbackEventV0_1_1{ Context: Context{ - Type: ServiceRolledbackEventV1.String(), + Type: ServiceRolledbackEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: ServiceRolledbackSubject{ diff --git a/pkg/api/zz_serviceupgraded.go b/pkg/api/zz_serviceupgraded_0_1_1.go similarity index 69% rename from pkg/api/zz_serviceupgraded.go rename to pkg/api/zz_serviceupgraded_0_1_1.go index 0939b08..096ccfd 100644 --- a/pkg/api/zz_serviceupgraded.go +++ b/pkg/api/zz_serviceupgraded_0_1_1.go @@ -28,8 +28,8 @@ import ( var serviceupgradedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/service-upgraded-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.service.upgraded.0.1.1"],"default":"dev.cdevents.service.upgraded.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["service"],"default":"service"},"content":{"properties":{"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"artifactId":{"type":"string","minLength":1}},"additionalProperties":false,"type":"object","required":["environment","artifactId"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // ServiceUpgraded event v0.1.1 - ServiceUpgradedEventV1 CDEventType = CDEventType{ + // ServiceUpgraded event type v0.1.1 + ServiceUpgradedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "service", Predicate: "upgraded", Version: "0.1.1", @@ -51,7 +51,7 @@ func (sc ServiceUpgradedSubject) GetSubjectType() SubjectType { return "service" } -type ServiceUpgradedEvent struct { +type ServiceUpgradedEventV0_1_1 struct { Context Context `json:"context"` Subject ServiceUpgradedSubject `json:"subject"` CDEventCustomData @@ -59,61 +59,61 @@ type ServiceUpgradedEvent struct { // CDEventsReader implementation -func (e ServiceUpgradedEvent) GetType() CDEventType { - return ServiceUpgradedEventV1 +func (e ServiceUpgradedEventV0_1_1) GetType() CDEventType { + return ServiceUpgradedEventTypeV0_1_1 } -func (e ServiceUpgradedEvent) GetVersion() string { +func (e ServiceUpgradedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e ServiceUpgradedEvent) GetId() string { +func (e ServiceUpgradedEventV0_1_1) GetId() string { return e.Context.Id } -func (e ServiceUpgradedEvent) GetSource() string { +func (e ServiceUpgradedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e ServiceUpgradedEvent) GetTimestamp() time.Time { +func (e ServiceUpgradedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e ServiceUpgradedEvent) GetSubjectId() string { +func (e ServiceUpgradedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e ServiceUpgradedEvent) GetSubjectSource() string { +func (e ServiceUpgradedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e ServiceUpgradedEvent) GetSubject() Subject { +func (e ServiceUpgradedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e ServiceUpgradedEvent) GetCustomData() (interface{}, error) { +func (e ServiceUpgradedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e ServiceUpgradedEvent) GetCustomDataAs(receiver interface{}) error { +func (e ServiceUpgradedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e ServiceUpgradedEvent) GetCustomDataRaw() ([]byte, error) { +func (e ServiceUpgradedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e ServiceUpgradedEvent) GetCustomDataContentType() string { +func (e ServiceUpgradedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *ServiceUpgradedEvent) SetId(id string) { +func (e *ServiceUpgradedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *ServiceUpgradedEvent) SetSource(source string) { +func (e *ServiceUpgradedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -121,19 +121,19 @@ func (e *ServiceUpgradedEvent) SetSource(source string) { } } -func (e *ServiceUpgradedEvent) SetTimestamp(timestamp time.Time) { +func (e *ServiceUpgradedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *ServiceUpgradedEvent) SetSubjectId(subjectId string) { +func (e *ServiceUpgradedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *ServiceUpgradedEvent) SetSubjectSource(subjectSource string) { +func (e *ServiceUpgradedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *ServiceUpgradedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *ServiceUpgradedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -143,26 +143,26 @@ func (e *ServiceUpgradedEvent) SetCustomData(contentType string, data interface{ return nil } -func (e ServiceUpgradedEvent) GetSchema() (string, string) { +func (e ServiceUpgradedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), serviceupgradedschema } // Set subject custom fields -func (e *ServiceUpgradedEvent) SetSubjectArtifactId(artifactId string) { +func (e *ServiceUpgradedEventV0_1_1) SetSubjectArtifactId(artifactId string) { e.Subject.Content.ArtifactId = artifactId } -func (e *ServiceUpgradedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *ServiceUpgradedEventV0_1_1) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -// New creates a new ServiceUpgradedEvent -func NewServiceUpgradedEvent() (*ServiceUpgradedEvent, error) { - e := &ServiceUpgradedEvent{ +// New creates a new ServiceUpgradedEventV0_1_1 +func NewServiceUpgradedEventV0_1_1() (*ServiceUpgradedEventV0_1_1, error) { + e := &ServiceUpgradedEventV0_1_1{ Context: Context{ - Type: ServiceUpgradedEventV1.String(), + Type: ServiceUpgradedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: ServiceUpgradedSubject{ diff --git a/pkg/api/zz_taskrunfinished.go b/pkg/api/zz_taskrunfinished_0_1_1.go similarity index 68% rename from pkg/api/zz_taskrunfinished.go rename to pkg/api/zz_taskrunfinished_0_1_1.go index 8a0cd93..2245397 100644 --- a/pkg/api/zz_taskrunfinished.go +++ b/pkg/api/zz_taskrunfinished_0_1_1.go @@ -28,8 +28,8 @@ import ( var taskrunfinishedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/task-run-finished-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.taskrun.finished.0.1.1"],"default":"dev.cdevents.taskrun.finished.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["taskRun"],"default":"taskRun"},"content":{"properties":{"taskName":{"type":"string"},"url":{"type":"string"},"pipelineRun":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"outcome":{"type":"string"},"errors":{"type":"string"}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // TaskRunFinished event v0.1.1 - TaskRunFinishedEventV1 CDEventType = CDEventType{ + // TaskRunFinished event type v0.1.1 + TaskRunFinishedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "taskrun", Predicate: "finished", Version: "0.1.1", @@ -57,7 +57,7 @@ func (sc TaskRunFinishedSubject) GetSubjectType() SubjectType { return "taskRun" } -type TaskRunFinishedEvent struct { +type TaskRunFinishedEventV0_1_1 struct { Context Context `json:"context"` Subject TaskRunFinishedSubject `json:"subject"` CDEventCustomData @@ -65,61 +65,61 @@ type TaskRunFinishedEvent struct { // CDEventsReader implementation -func (e TaskRunFinishedEvent) GetType() CDEventType { - return TaskRunFinishedEventV1 +func (e TaskRunFinishedEventV0_1_1) GetType() CDEventType { + return TaskRunFinishedEventTypeV0_1_1 } -func (e TaskRunFinishedEvent) GetVersion() string { +func (e TaskRunFinishedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e TaskRunFinishedEvent) GetId() string { +func (e TaskRunFinishedEventV0_1_1) GetId() string { return e.Context.Id } -func (e TaskRunFinishedEvent) GetSource() string { +func (e TaskRunFinishedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e TaskRunFinishedEvent) GetTimestamp() time.Time { +func (e TaskRunFinishedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e TaskRunFinishedEvent) GetSubjectId() string { +func (e TaskRunFinishedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e TaskRunFinishedEvent) GetSubjectSource() string { +func (e TaskRunFinishedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e TaskRunFinishedEvent) GetSubject() Subject { +func (e TaskRunFinishedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e TaskRunFinishedEvent) GetCustomData() (interface{}, error) { +func (e TaskRunFinishedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e TaskRunFinishedEvent) GetCustomDataAs(receiver interface{}) error { +func (e TaskRunFinishedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e TaskRunFinishedEvent) GetCustomDataRaw() ([]byte, error) { +func (e TaskRunFinishedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e TaskRunFinishedEvent) GetCustomDataContentType() string { +func (e TaskRunFinishedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *TaskRunFinishedEvent) SetId(id string) { +func (e *TaskRunFinishedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *TaskRunFinishedEvent) SetSource(source string) { +func (e *TaskRunFinishedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -127,19 +127,19 @@ func (e *TaskRunFinishedEvent) SetSource(source string) { } } -func (e *TaskRunFinishedEvent) SetTimestamp(timestamp time.Time) { +func (e *TaskRunFinishedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *TaskRunFinishedEvent) SetSubjectId(subjectId string) { +func (e *TaskRunFinishedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *TaskRunFinishedEvent) SetSubjectSource(subjectSource string) { +func (e *TaskRunFinishedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *TaskRunFinishedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *TaskRunFinishedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -149,38 +149,38 @@ func (e *TaskRunFinishedEvent) SetCustomData(contentType string, data interface{ return nil } -func (e TaskRunFinishedEvent) GetSchema() (string, string) { +func (e TaskRunFinishedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), taskrunfinishedschema } // Set subject custom fields -func (e *TaskRunFinishedEvent) SetSubjectErrors(errors string) { +func (e *TaskRunFinishedEventV0_1_1) SetSubjectErrors(errors string) { e.Subject.Content.Errors = errors } -func (e *TaskRunFinishedEvent) SetSubjectOutcome(outcome string) { +func (e *TaskRunFinishedEventV0_1_1) SetSubjectOutcome(outcome string) { e.Subject.Content.Outcome = outcome } -func (e *TaskRunFinishedEvent) SetSubjectPipelineRun(pipelineRun *Reference) { +func (e *TaskRunFinishedEventV0_1_1) SetSubjectPipelineRun(pipelineRun *Reference) { e.Subject.Content.PipelineRun = pipelineRun } -func (e *TaskRunFinishedEvent) SetSubjectTaskName(taskName string) { +func (e *TaskRunFinishedEventV0_1_1) SetSubjectTaskName(taskName string) { e.Subject.Content.TaskName = taskName } -func (e *TaskRunFinishedEvent) SetSubjectUrl(url string) { +func (e *TaskRunFinishedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -// New creates a new TaskRunFinishedEvent -func NewTaskRunFinishedEvent() (*TaskRunFinishedEvent, error) { - e := &TaskRunFinishedEvent{ +// New creates a new TaskRunFinishedEventV0_1_1 +func NewTaskRunFinishedEventV0_1_1() (*TaskRunFinishedEventV0_1_1, error) { + e := &TaskRunFinishedEventV0_1_1{ Context: Context{ - Type: TaskRunFinishedEventV1.String(), + Type: TaskRunFinishedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: TaskRunFinishedSubject{ diff --git a/pkg/api/zz_taskrunstarted.go b/pkg/api/zz_taskrunstarted_0_1_1.go similarity index 68% rename from pkg/api/zz_taskrunstarted.go rename to pkg/api/zz_taskrunstarted_0_1_1.go index 3a6a8b3..bcd7fe9 100644 --- a/pkg/api/zz_taskrunstarted.go +++ b/pkg/api/zz_taskrunstarted_0_1_1.go @@ -28,8 +28,8 @@ import ( var taskrunstartedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/task-run-started-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","enum":["dev.cdevents.taskrun.started.0.1.1"],"default":"dev.cdevents.taskrun.started.0.1.1"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"},"type":{"type":"string","minLength":1,"enum":["taskRun"],"default":"taskRun"},"content":{"properties":{"taskName":{"type":"string"},"url":{"type":"string"},"pipelineRun":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object"}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // TaskRunStarted event v0.1.1 - TaskRunStartedEventV1 CDEventType = CDEventType{ + // TaskRunStarted event type v0.1.1 + TaskRunStartedEventTypeV0_1_1 CDEventType = CDEventType{ Subject: "taskrun", Predicate: "started", Version: "0.1.1", @@ -53,7 +53,7 @@ func (sc TaskRunStartedSubject) GetSubjectType() SubjectType { return "taskRun" } -type TaskRunStartedEvent struct { +type TaskRunStartedEventV0_1_1 struct { Context Context `json:"context"` Subject TaskRunStartedSubject `json:"subject"` CDEventCustomData @@ -61,61 +61,61 @@ type TaskRunStartedEvent struct { // CDEventsReader implementation -func (e TaskRunStartedEvent) GetType() CDEventType { - return TaskRunStartedEventV1 +func (e TaskRunStartedEventV0_1_1) GetType() CDEventType { + return TaskRunStartedEventTypeV0_1_1 } -func (e TaskRunStartedEvent) GetVersion() string { +func (e TaskRunStartedEventV0_1_1) GetVersion() string { return CDEventsSpecVersion } -func (e TaskRunStartedEvent) GetId() string { +func (e TaskRunStartedEventV0_1_1) GetId() string { return e.Context.Id } -func (e TaskRunStartedEvent) GetSource() string { +func (e TaskRunStartedEventV0_1_1) GetSource() string { return e.Context.Source } -func (e TaskRunStartedEvent) GetTimestamp() time.Time { +func (e TaskRunStartedEventV0_1_1) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e TaskRunStartedEvent) GetSubjectId() string { +func (e TaskRunStartedEventV0_1_1) GetSubjectId() string { return e.Subject.Id } -func (e TaskRunStartedEvent) GetSubjectSource() string { +func (e TaskRunStartedEventV0_1_1) GetSubjectSource() string { return e.Subject.Source } -func (e TaskRunStartedEvent) GetSubject() Subject { +func (e TaskRunStartedEventV0_1_1) GetSubject() Subject { return e.Subject } -func (e TaskRunStartedEvent) GetCustomData() (interface{}, error) { +func (e TaskRunStartedEventV0_1_1) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e TaskRunStartedEvent) GetCustomDataAs(receiver interface{}) error { +func (e TaskRunStartedEventV0_1_1) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e TaskRunStartedEvent) GetCustomDataRaw() ([]byte, error) { +func (e TaskRunStartedEventV0_1_1) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e TaskRunStartedEvent) GetCustomDataContentType() string { +func (e TaskRunStartedEventV0_1_1) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *TaskRunStartedEvent) SetId(id string) { +func (e *TaskRunStartedEventV0_1_1) SetId(id string) { e.Context.Id = id } -func (e *TaskRunStartedEvent) SetSource(source string) { +func (e *TaskRunStartedEventV0_1_1) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -123,19 +123,19 @@ func (e *TaskRunStartedEvent) SetSource(source string) { } } -func (e *TaskRunStartedEvent) SetTimestamp(timestamp time.Time) { +func (e *TaskRunStartedEventV0_1_1) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *TaskRunStartedEvent) SetSubjectId(subjectId string) { +func (e *TaskRunStartedEventV0_1_1) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *TaskRunStartedEvent) SetSubjectSource(subjectSource string) { +func (e *TaskRunStartedEventV0_1_1) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *TaskRunStartedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *TaskRunStartedEventV0_1_1) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -145,30 +145,30 @@ func (e *TaskRunStartedEvent) SetCustomData(contentType string, data interface{} return nil } -func (e TaskRunStartedEvent) GetSchema() (string, string) { +func (e TaskRunStartedEventV0_1_1) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), taskrunstartedschema } // Set subject custom fields -func (e *TaskRunStartedEvent) SetSubjectPipelineRun(pipelineRun *Reference) { +func (e *TaskRunStartedEventV0_1_1) SetSubjectPipelineRun(pipelineRun *Reference) { e.Subject.Content.PipelineRun = pipelineRun } -func (e *TaskRunStartedEvent) SetSubjectTaskName(taskName string) { +func (e *TaskRunStartedEventV0_1_1) SetSubjectTaskName(taskName string) { e.Subject.Content.TaskName = taskName } -func (e *TaskRunStartedEvent) SetSubjectUrl(url string) { +func (e *TaskRunStartedEventV0_1_1) SetSubjectUrl(url string) { e.Subject.Content.Url = url } -// New creates a new TaskRunStartedEvent -func NewTaskRunStartedEvent() (*TaskRunStartedEvent, error) { - e := &TaskRunStartedEvent{ +// New creates a new TaskRunStartedEventV0_1_1 +func NewTaskRunStartedEventV0_1_1() (*TaskRunStartedEventV0_1_1, error) { + e := &TaskRunStartedEventV0_1_1{ Context: Context{ - Type: TaskRunStartedEventV1.String(), + Type: TaskRunStartedEventTypeV0_1_1.String(), Version: CDEventsSpecVersion, }, Subject: TaskRunStartedSubject{ diff --git a/pkg/api/zz_testcaserunfinished.go b/pkg/api/zz_testcaserunfinished_0_1_0.go similarity index 70% rename from pkg/api/zz_testcaserunfinished.go rename to pkg/api/zz_testcaserunfinished_0_1_0.go index 940e0b8..a366368 100644 --- a/pkg/api/zz_testcaserunfinished.go +++ b/pkg/api/zz_testcaserunfinished_0_1_0.go @@ -28,8 +28,8 @@ import ( var testcaserunfinishedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/test-case-run-finished-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1},"type":{"type":"string","enum":["dev.cdevents.testcaserun.finished.0.1.0"],"default":"dev.cdevents.testcaserun.finished.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"},"type":{"type":"string","minLength":1,"enum":["testCaseRun"],"default":"testCaseRun"},"content":{"properties":{"outcome":{"type":"string","enum":["pass","fail","cancel","error"]},"severity":{"type":"string","enum":["low","medium","high","critical"]},"reason":{"type":"string"},"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"testSuiteRun":{"type":"object","properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"}},"additionalProperties":false,"required":["id"]},"testCase":{"type":"object","additionalProperties":false,"required":["id"],"properties":{"id":{"type":"string","minLength":1},"version":{"type":"string"},"name":{"type":"string"},"type":{"type":"string","enum":["performance","functional","unit","security","compliance","integration","e2e","other"]},"uri":{"type":"string","format":"uri"}}}},"additionalProperties":false,"type":"object","required":["outcome","environment"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // TestCaseRunFinished event v0.1.0 - TestCaseRunFinishedEventV1 CDEventType = CDEventType{ + // TestCaseRunFinished event type v0.1.0 + TestCaseRunFinishedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "testcaserun", Predicate: "finished", Version: "0.1.0", @@ -59,7 +59,7 @@ func (sc TestCaseRunFinishedSubject) GetSubjectType() SubjectType { return "testCaseRun" } -type TestCaseRunFinishedEvent struct { +type TestCaseRunFinishedEventV0_1_0 struct { Context Context `json:"context"` Subject TestCaseRunFinishedSubject `json:"subject"` CDEventCustomData @@ -67,61 +67,61 @@ type TestCaseRunFinishedEvent struct { // CDEventsReader implementation -func (e TestCaseRunFinishedEvent) GetType() CDEventType { - return TestCaseRunFinishedEventV1 +func (e TestCaseRunFinishedEventV0_1_0) GetType() CDEventType { + return TestCaseRunFinishedEventTypeV0_1_0 } -func (e TestCaseRunFinishedEvent) GetVersion() string { +func (e TestCaseRunFinishedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e TestCaseRunFinishedEvent) GetId() string { +func (e TestCaseRunFinishedEventV0_1_0) GetId() string { return e.Context.Id } -func (e TestCaseRunFinishedEvent) GetSource() string { +func (e TestCaseRunFinishedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e TestCaseRunFinishedEvent) GetTimestamp() time.Time { +func (e TestCaseRunFinishedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e TestCaseRunFinishedEvent) GetSubjectId() string { +func (e TestCaseRunFinishedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e TestCaseRunFinishedEvent) GetSubjectSource() string { +func (e TestCaseRunFinishedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e TestCaseRunFinishedEvent) GetSubject() Subject { +func (e TestCaseRunFinishedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e TestCaseRunFinishedEvent) GetCustomData() (interface{}, error) { +func (e TestCaseRunFinishedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e TestCaseRunFinishedEvent) GetCustomDataAs(receiver interface{}) error { +func (e TestCaseRunFinishedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e TestCaseRunFinishedEvent) GetCustomDataRaw() ([]byte, error) { +func (e TestCaseRunFinishedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e TestCaseRunFinishedEvent) GetCustomDataContentType() string { +func (e TestCaseRunFinishedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *TestCaseRunFinishedEvent) SetId(id string) { +func (e *TestCaseRunFinishedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *TestCaseRunFinishedEvent) SetSource(source string) { +func (e *TestCaseRunFinishedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -129,19 +129,19 @@ func (e *TestCaseRunFinishedEvent) SetSource(source string) { } } -func (e *TestCaseRunFinishedEvent) SetTimestamp(timestamp time.Time) { +func (e *TestCaseRunFinishedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *TestCaseRunFinishedEvent) SetSubjectId(subjectId string) { +func (e *TestCaseRunFinishedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *TestCaseRunFinishedEvent) SetSubjectSource(subjectSource string) { +func (e *TestCaseRunFinishedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *TestCaseRunFinishedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *TestCaseRunFinishedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -151,42 +151,42 @@ func (e *TestCaseRunFinishedEvent) SetCustomData(contentType string, data interf return nil } -func (e TestCaseRunFinishedEvent) GetSchema() (string, string) { +func (e TestCaseRunFinishedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), testcaserunfinishedschema } // Set subject custom fields -func (e *TestCaseRunFinishedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *TestCaseRunFinishedEventV0_1_0) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -func (e *TestCaseRunFinishedEvent) SetSubjectOutcome(outcome string) { +func (e *TestCaseRunFinishedEventV0_1_0) SetSubjectOutcome(outcome string) { e.Subject.Content.Outcome = outcome } -func (e *TestCaseRunFinishedEvent) SetSubjectReason(reason string) { +func (e *TestCaseRunFinishedEventV0_1_0) SetSubjectReason(reason string) { e.Subject.Content.Reason = reason } -func (e *TestCaseRunFinishedEvent) SetSubjectSeverity(severity string) { +func (e *TestCaseRunFinishedEventV0_1_0) SetSubjectSeverity(severity string) { e.Subject.Content.Severity = severity } -func (e *TestCaseRunFinishedEvent) SetSubjectTestCase(testCase *TestCaseRunFinishedSubjectContentTestCase) { +func (e *TestCaseRunFinishedEventV0_1_0) SetSubjectTestCase(testCase *TestCaseRunFinishedSubjectContentTestCase) { e.Subject.Content.TestCase = testCase } -func (e *TestCaseRunFinishedEvent) SetSubjectTestSuiteRun(testSuiteRun *Reference) { +func (e *TestCaseRunFinishedEventV0_1_0) SetSubjectTestSuiteRun(testSuiteRun *Reference) { e.Subject.Content.TestSuiteRun = testSuiteRun } -// New creates a new TestCaseRunFinishedEvent -func NewTestCaseRunFinishedEvent() (*TestCaseRunFinishedEvent, error) { - e := &TestCaseRunFinishedEvent{ +// New creates a new TestCaseRunFinishedEventV0_1_0 +func NewTestCaseRunFinishedEventV0_1_0() (*TestCaseRunFinishedEventV0_1_0, error) { + e := &TestCaseRunFinishedEventV0_1_0{ Context: Context{ - Type: TestCaseRunFinishedEventV1.String(), + Type: TestCaseRunFinishedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: TestCaseRunFinishedSubject{ diff --git a/pkg/api/zz_testcaserunqueued.go b/pkg/api/zz_testcaserunqueued_0_1_0.go similarity index 72% rename from pkg/api/zz_testcaserunqueued.go rename to pkg/api/zz_testcaserunqueued_0_1_0.go index ffacac8..c02ddeb 100644 --- a/pkg/api/zz_testcaserunqueued.go +++ b/pkg/api/zz_testcaserunqueued_0_1_0.go @@ -28,8 +28,8 @@ import ( var testcaserunqueuedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/test-case-run-queued-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1},"type":{"type":"string","enum":["dev.cdevents.testcaserun.queued.0.1.0"],"default":"dev.cdevents.testcaserun.queued.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"},"type":{"type":"string","minLength":1,"enum":["testCaseRun"],"default":"testCaseRun"},"content":{"properties":{"trigger":{"type":"object","properties":{"type":{"type":"string","enum":["manual","pipeline","event","schedule","other"]},"uri":{"type":"string","format":"uri"}}},"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"testSuiteRun":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"}},"additionalProperties":false,"type":"object","required":["id"]},"testCase":{"type":"object","additionalProperties":false,"required":["id"],"properties":{"id":{"type":"string","minLength":1},"version":{"type":"string"},"name":{"type":"string"},"type":{"type":"string","enum":["performance","functional","unit","security","compliance","integration","e2e","other"]},"uri":{"type":"string","format":"uri"}}}},"additionalProperties":false,"type":"object","required":["environment"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // TestCaseRunQueued event v0.1.0 - TestCaseRunQueuedEventV1 CDEventType = CDEventType{ + // TestCaseRunQueued event type v0.1.0 + TestCaseRunQueuedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "testcaserun", Predicate: "queued", Version: "0.1.0", @@ -55,7 +55,7 @@ func (sc TestCaseRunQueuedSubject) GetSubjectType() SubjectType { return "testCaseRun" } -type TestCaseRunQueuedEvent struct { +type TestCaseRunQueuedEventV0_1_0 struct { Context Context `json:"context"` Subject TestCaseRunQueuedSubject `json:"subject"` CDEventCustomData @@ -63,61 +63,61 @@ type TestCaseRunQueuedEvent struct { // CDEventsReader implementation -func (e TestCaseRunQueuedEvent) GetType() CDEventType { - return TestCaseRunQueuedEventV1 +func (e TestCaseRunQueuedEventV0_1_0) GetType() CDEventType { + return TestCaseRunQueuedEventTypeV0_1_0 } -func (e TestCaseRunQueuedEvent) GetVersion() string { +func (e TestCaseRunQueuedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e TestCaseRunQueuedEvent) GetId() string { +func (e TestCaseRunQueuedEventV0_1_0) GetId() string { return e.Context.Id } -func (e TestCaseRunQueuedEvent) GetSource() string { +func (e TestCaseRunQueuedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e TestCaseRunQueuedEvent) GetTimestamp() time.Time { +func (e TestCaseRunQueuedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e TestCaseRunQueuedEvent) GetSubjectId() string { +func (e TestCaseRunQueuedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e TestCaseRunQueuedEvent) GetSubjectSource() string { +func (e TestCaseRunQueuedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e TestCaseRunQueuedEvent) GetSubject() Subject { +func (e TestCaseRunQueuedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e TestCaseRunQueuedEvent) GetCustomData() (interface{}, error) { +func (e TestCaseRunQueuedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e TestCaseRunQueuedEvent) GetCustomDataAs(receiver interface{}) error { +func (e TestCaseRunQueuedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e TestCaseRunQueuedEvent) GetCustomDataRaw() ([]byte, error) { +func (e TestCaseRunQueuedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e TestCaseRunQueuedEvent) GetCustomDataContentType() string { +func (e TestCaseRunQueuedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *TestCaseRunQueuedEvent) SetId(id string) { +func (e *TestCaseRunQueuedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *TestCaseRunQueuedEvent) SetSource(source string) { +func (e *TestCaseRunQueuedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -125,19 +125,19 @@ func (e *TestCaseRunQueuedEvent) SetSource(source string) { } } -func (e *TestCaseRunQueuedEvent) SetTimestamp(timestamp time.Time) { +func (e *TestCaseRunQueuedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *TestCaseRunQueuedEvent) SetSubjectId(subjectId string) { +func (e *TestCaseRunQueuedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *TestCaseRunQueuedEvent) SetSubjectSource(subjectSource string) { +func (e *TestCaseRunQueuedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *TestCaseRunQueuedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *TestCaseRunQueuedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -147,34 +147,34 @@ func (e *TestCaseRunQueuedEvent) SetCustomData(contentType string, data interfac return nil } -func (e TestCaseRunQueuedEvent) GetSchema() (string, string) { +func (e TestCaseRunQueuedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), testcaserunqueuedschema } // Set subject custom fields -func (e *TestCaseRunQueuedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *TestCaseRunQueuedEventV0_1_0) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -func (e *TestCaseRunQueuedEvent) SetSubjectTestCase(testCase *TestCaseRunQueuedSubjectContentTestCase) { +func (e *TestCaseRunQueuedEventV0_1_0) SetSubjectTestCase(testCase *TestCaseRunQueuedSubjectContentTestCase) { e.Subject.Content.TestCase = testCase } -func (e *TestCaseRunQueuedEvent) SetSubjectTestSuiteRun(testSuiteRun *Reference) { +func (e *TestCaseRunQueuedEventV0_1_0) SetSubjectTestSuiteRun(testSuiteRun *Reference) { e.Subject.Content.TestSuiteRun = testSuiteRun } -func (e *TestCaseRunQueuedEvent) SetSubjectTrigger(trigger *TestCaseRunQueuedSubjectContentTrigger) { +func (e *TestCaseRunQueuedEventV0_1_0) SetSubjectTrigger(trigger *TestCaseRunQueuedSubjectContentTrigger) { e.Subject.Content.Trigger = trigger } -// New creates a new TestCaseRunQueuedEvent -func NewTestCaseRunQueuedEvent() (*TestCaseRunQueuedEvent, error) { - e := &TestCaseRunQueuedEvent{ +// New creates a new TestCaseRunQueuedEventV0_1_0 +func NewTestCaseRunQueuedEventV0_1_0() (*TestCaseRunQueuedEventV0_1_0, error) { + e := &TestCaseRunQueuedEventV0_1_0{ Context: Context{ - Type: TestCaseRunQueuedEventV1.String(), + Type: TestCaseRunQueuedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: TestCaseRunQueuedSubject{ diff --git a/pkg/api/zz_testcaserunstarted.go b/pkg/api/zz_testcaserunstarted_0_1_0.go similarity index 71% rename from pkg/api/zz_testcaserunstarted.go rename to pkg/api/zz_testcaserunstarted_0_1_0.go index 95114d5..4d3f56f 100644 --- a/pkg/api/zz_testcaserunstarted.go +++ b/pkg/api/zz_testcaserunstarted_0_1_0.go @@ -28,8 +28,8 @@ import ( var testcaserunstartedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/test-case-run-started-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1},"type":{"type":"string","enum":["dev.cdevents.testcaserun.started.0.1.0"],"default":"dev.cdevents.testcaserun.started.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"},"type":{"type":"string","minLength":1,"enum":["testCaseRun"],"default":"testCaseRun"},"content":{"properties":{"trigger":{"type":"object","properties":{"type":{"type":"string","enum":["manual","pipeline","event","schedule","other"]},"uri":{"type":"string","format":"uri"}}},"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"testSuiteRun":{"type":"object","properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"}},"additionalProperties":false,"required":["id"]},"testCase":{"properties":{"id":{"type":"string","minLength":1},"version":{"type":"string"},"name":{"type":"string"},"type":{"type":"string","enum":["performance","functional","unit","security","compliance","integration","e2e","other"]},"uri":{"type":"string","format":"uri"}},"additionalProperties":false,"type":"object","required":["id"]}},"additionalProperties":false,"type":"object","required":["environment"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // TestCaseRunStarted event v0.1.0 - TestCaseRunStartedEventV1 CDEventType = CDEventType{ + // TestCaseRunStarted event type v0.1.0 + TestCaseRunStartedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "testcaserun", Predicate: "started", Version: "0.1.0", @@ -55,7 +55,7 @@ func (sc TestCaseRunStartedSubject) GetSubjectType() SubjectType { return "testCaseRun" } -type TestCaseRunStartedEvent struct { +type TestCaseRunStartedEventV0_1_0 struct { Context Context `json:"context"` Subject TestCaseRunStartedSubject `json:"subject"` CDEventCustomData @@ -63,61 +63,61 @@ type TestCaseRunStartedEvent struct { // CDEventsReader implementation -func (e TestCaseRunStartedEvent) GetType() CDEventType { - return TestCaseRunStartedEventV1 +func (e TestCaseRunStartedEventV0_1_0) GetType() CDEventType { + return TestCaseRunStartedEventTypeV0_1_0 } -func (e TestCaseRunStartedEvent) GetVersion() string { +func (e TestCaseRunStartedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e TestCaseRunStartedEvent) GetId() string { +func (e TestCaseRunStartedEventV0_1_0) GetId() string { return e.Context.Id } -func (e TestCaseRunStartedEvent) GetSource() string { +func (e TestCaseRunStartedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e TestCaseRunStartedEvent) GetTimestamp() time.Time { +func (e TestCaseRunStartedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e TestCaseRunStartedEvent) GetSubjectId() string { +func (e TestCaseRunStartedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e TestCaseRunStartedEvent) GetSubjectSource() string { +func (e TestCaseRunStartedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e TestCaseRunStartedEvent) GetSubject() Subject { +func (e TestCaseRunStartedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e TestCaseRunStartedEvent) GetCustomData() (interface{}, error) { +func (e TestCaseRunStartedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e TestCaseRunStartedEvent) GetCustomDataAs(receiver interface{}) error { +func (e TestCaseRunStartedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e TestCaseRunStartedEvent) GetCustomDataRaw() ([]byte, error) { +func (e TestCaseRunStartedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e TestCaseRunStartedEvent) GetCustomDataContentType() string { +func (e TestCaseRunStartedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *TestCaseRunStartedEvent) SetId(id string) { +func (e *TestCaseRunStartedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *TestCaseRunStartedEvent) SetSource(source string) { +func (e *TestCaseRunStartedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -125,19 +125,19 @@ func (e *TestCaseRunStartedEvent) SetSource(source string) { } } -func (e *TestCaseRunStartedEvent) SetTimestamp(timestamp time.Time) { +func (e *TestCaseRunStartedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *TestCaseRunStartedEvent) SetSubjectId(subjectId string) { +func (e *TestCaseRunStartedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *TestCaseRunStartedEvent) SetSubjectSource(subjectSource string) { +func (e *TestCaseRunStartedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *TestCaseRunStartedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *TestCaseRunStartedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -147,34 +147,34 @@ func (e *TestCaseRunStartedEvent) SetCustomData(contentType string, data interfa return nil } -func (e TestCaseRunStartedEvent) GetSchema() (string, string) { +func (e TestCaseRunStartedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), testcaserunstartedschema } // Set subject custom fields -func (e *TestCaseRunStartedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *TestCaseRunStartedEventV0_1_0) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -func (e *TestCaseRunStartedEvent) SetSubjectTestCase(testCase *TestCaseRunStartedSubjectContentTestCase) { +func (e *TestCaseRunStartedEventV0_1_0) SetSubjectTestCase(testCase *TestCaseRunStartedSubjectContentTestCase) { e.Subject.Content.TestCase = testCase } -func (e *TestCaseRunStartedEvent) SetSubjectTestSuiteRun(testSuiteRun *Reference) { +func (e *TestCaseRunStartedEventV0_1_0) SetSubjectTestSuiteRun(testSuiteRun *Reference) { e.Subject.Content.TestSuiteRun = testSuiteRun } -func (e *TestCaseRunStartedEvent) SetSubjectTrigger(trigger *TestCaseRunStartedSubjectContentTrigger) { +func (e *TestCaseRunStartedEventV0_1_0) SetSubjectTrigger(trigger *TestCaseRunStartedSubjectContentTrigger) { e.Subject.Content.Trigger = trigger } -// New creates a new TestCaseRunStartedEvent -func NewTestCaseRunStartedEvent() (*TestCaseRunStartedEvent, error) { - e := &TestCaseRunStartedEvent{ +// New creates a new TestCaseRunStartedEventV0_1_0 +func NewTestCaseRunStartedEventV0_1_0() (*TestCaseRunStartedEventV0_1_0, error) { + e := &TestCaseRunStartedEventV0_1_0{ Context: Context{ - Type: TestCaseRunStartedEventV1.String(), + Type: TestCaseRunStartedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: TestCaseRunStartedSubject{ diff --git a/pkg/api/zz_testoutputpublished.go b/pkg/api/zz_testoutputpublished_0_1_0.go similarity index 67% rename from pkg/api/zz_testoutputpublished.go rename to pkg/api/zz_testoutputpublished_0_1_0.go index c265c6d..d85f5d5 100644 --- a/pkg/api/zz_testoutputpublished.go +++ b/pkg/api/zz_testoutputpublished_0_1_0.go @@ -28,8 +28,8 @@ import ( var testoutputpublishedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/test-output-published-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1},"type":{"type":"string","enum":["dev.cdevents.testoutput.published.0.1.0"],"default":"dev.cdevents.testoutput.published.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"},"type":{"type":"string","minLength":1,"enum":["testOutput"],"default":"testOutput"},"content":{"properties":{"outputType":{"type":"string","enum":["report","video","image","log","other"]},"format":{"type":"string","example":"application/pdf"},"uri":{"type":"string","format":"uri"},"testCaseRun":{"type":"object","properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"}},"additionalProperties":false,"required":["id"]}},"additionalProperties":false,"type":"object","required":["outputType","format"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // TestOutputPublished event v0.1.0 - TestOutputPublishedEventV1 CDEventType = CDEventType{ + // TestOutputPublished event type v0.1.0 + TestOutputPublishedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "testoutput", Predicate: "published", Version: "0.1.0", @@ -55,7 +55,7 @@ func (sc TestOutputPublishedSubject) GetSubjectType() SubjectType { return "testOutput" } -type TestOutputPublishedEvent struct { +type TestOutputPublishedEventV0_1_0 struct { Context Context `json:"context"` Subject TestOutputPublishedSubject `json:"subject"` CDEventCustomData @@ -63,61 +63,61 @@ type TestOutputPublishedEvent struct { // CDEventsReader implementation -func (e TestOutputPublishedEvent) GetType() CDEventType { - return TestOutputPublishedEventV1 +func (e TestOutputPublishedEventV0_1_0) GetType() CDEventType { + return TestOutputPublishedEventTypeV0_1_0 } -func (e TestOutputPublishedEvent) GetVersion() string { +func (e TestOutputPublishedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e TestOutputPublishedEvent) GetId() string { +func (e TestOutputPublishedEventV0_1_0) GetId() string { return e.Context.Id } -func (e TestOutputPublishedEvent) GetSource() string { +func (e TestOutputPublishedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e TestOutputPublishedEvent) GetTimestamp() time.Time { +func (e TestOutputPublishedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e TestOutputPublishedEvent) GetSubjectId() string { +func (e TestOutputPublishedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e TestOutputPublishedEvent) GetSubjectSource() string { +func (e TestOutputPublishedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e TestOutputPublishedEvent) GetSubject() Subject { +func (e TestOutputPublishedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e TestOutputPublishedEvent) GetCustomData() (interface{}, error) { +func (e TestOutputPublishedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e TestOutputPublishedEvent) GetCustomDataAs(receiver interface{}) error { +func (e TestOutputPublishedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e TestOutputPublishedEvent) GetCustomDataRaw() ([]byte, error) { +func (e TestOutputPublishedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e TestOutputPublishedEvent) GetCustomDataContentType() string { +func (e TestOutputPublishedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *TestOutputPublishedEvent) SetId(id string) { +func (e *TestOutputPublishedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *TestOutputPublishedEvent) SetSource(source string) { +func (e *TestOutputPublishedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -125,19 +125,19 @@ func (e *TestOutputPublishedEvent) SetSource(source string) { } } -func (e *TestOutputPublishedEvent) SetTimestamp(timestamp time.Time) { +func (e *TestOutputPublishedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *TestOutputPublishedEvent) SetSubjectId(subjectId string) { +func (e *TestOutputPublishedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *TestOutputPublishedEvent) SetSubjectSource(subjectSource string) { +func (e *TestOutputPublishedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *TestOutputPublishedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *TestOutputPublishedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -147,34 +147,34 @@ func (e *TestOutputPublishedEvent) SetCustomData(contentType string, data interf return nil } -func (e TestOutputPublishedEvent) GetSchema() (string, string) { +func (e TestOutputPublishedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), testoutputpublishedschema } // Set subject custom fields -func (e *TestOutputPublishedEvent) SetSubjectFormat(format string) { +func (e *TestOutputPublishedEventV0_1_0) SetSubjectFormat(format string) { e.Subject.Content.Format = format } -func (e *TestOutputPublishedEvent) SetSubjectOutputType(outputType string) { +func (e *TestOutputPublishedEventV0_1_0) SetSubjectOutputType(outputType string) { e.Subject.Content.OutputType = outputType } -func (e *TestOutputPublishedEvent) SetSubjectTestCaseRun(testCaseRun *Reference) { +func (e *TestOutputPublishedEventV0_1_0) SetSubjectTestCaseRun(testCaseRun *Reference) { e.Subject.Content.TestCaseRun = testCaseRun } -func (e *TestOutputPublishedEvent) SetSubjectUri(uri string) { +func (e *TestOutputPublishedEventV0_1_0) SetSubjectUri(uri string) { e.Subject.Content.Uri = uri } -// New creates a new TestOutputPublishedEvent -func NewTestOutputPublishedEvent() (*TestOutputPublishedEvent, error) { - e := &TestOutputPublishedEvent{ +// New creates a new TestOutputPublishedEventV0_1_0 +func NewTestOutputPublishedEventV0_1_0() (*TestOutputPublishedEventV0_1_0, error) { + e := &TestOutputPublishedEventV0_1_0{ Context: Context{ - Type: TestOutputPublishedEventV1.String(), + Type: TestOutputPublishedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: TestOutputPublishedSubject{ diff --git a/pkg/api/zz_testsuiterunfinished.go b/pkg/api/zz_testsuiterunfinished_0_1_0.go similarity index 69% rename from pkg/api/zz_testsuiterunfinished.go rename to pkg/api/zz_testsuiterunfinished_0_1_0.go index 73c6771..7e5cfb3 100644 --- a/pkg/api/zz_testsuiterunfinished.go +++ b/pkg/api/zz_testsuiterunfinished_0_1_0.go @@ -28,8 +28,8 @@ import ( var testsuiterunfinishedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/test-suite-finished-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1},"type":{"type":"string","enum":["dev.cdevents.testsuiterun.finished.0.1.0"],"default":"dev.cdevents.testsuiterun.finished.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"},"type":{"type":"string","minLength":1,"enum":["testSuiteRun"],"default":"testSuiteRun"},"content":{"properties":{"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"testSuite":{"type":"object","additionalProperties":false,"required":["id"],"properties":{"id":{"type":"string","minLength":1},"version":{"type":"string"},"name":{"type":"string"},"uri":{"type":"string","format":"uri"}}},"outcome":{"type":"string","enum":["pass","fail","cancel","error"]},"severity":{"type":"string","enum":["low","medium","high","critical"]},"reason":{"type":"string"}},"additionalProperties":false,"type":"object","required":["outcome","environment"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // TestSuiteRunFinished event v0.1.0 - TestSuiteRunFinishedEventV1 CDEventType = CDEventType{ + // TestSuiteRunFinished event type v0.1.0 + TestSuiteRunFinishedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "testsuiterun", Predicate: "finished", Version: "0.1.0", @@ -57,7 +57,7 @@ func (sc TestSuiteRunFinishedSubject) GetSubjectType() SubjectType { return "testSuiteRun" } -type TestSuiteRunFinishedEvent struct { +type TestSuiteRunFinishedEventV0_1_0 struct { Context Context `json:"context"` Subject TestSuiteRunFinishedSubject `json:"subject"` CDEventCustomData @@ -65,61 +65,61 @@ type TestSuiteRunFinishedEvent struct { // CDEventsReader implementation -func (e TestSuiteRunFinishedEvent) GetType() CDEventType { - return TestSuiteRunFinishedEventV1 +func (e TestSuiteRunFinishedEventV0_1_0) GetType() CDEventType { + return TestSuiteRunFinishedEventTypeV0_1_0 } -func (e TestSuiteRunFinishedEvent) GetVersion() string { +func (e TestSuiteRunFinishedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e TestSuiteRunFinishedEvent) GetId() string { +func (e TestSuiteRunFinishedEventV0_1_0) GetId() string { return e.Context.Id } -func (e TestSuiteRunFinishedEvent) GetSource() string { +func (e TestSuiteRunFinishedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e TestSuiteRunFinishedEvent) GetTimestamp() time.Time { +func (e TestSuiteRunFinishedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e TestSuiteRunFinishedEvent) GetSubjectId() string { +func (e TestSuiteRunFinishedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e TestSuiteRunFinishedEvent) GetSubjectSource() string { +func (e TestSuiteRunFinishedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e TestSuiteRunFinishedEvent) GetSubject() Subject { +func (e TestSuiteRunFinishedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e TestSuiteRunFinishedEvent) GetCustomData() (interface{}, error) { +func (e TestSuiteRunFinishedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e TestSuiteRunFinishedEvent) GetCustomDataAs(receiver interface{}) error { +func (e TestSuiteRunFinishedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e TestSuiteRunFinishedEvent) GetCustomDataRaw() ([]byte, error) { +func (e TestSuiteRunFinishedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e TestSuiteRunFinishedEvent) GetCustomDataContentType() string { +func (e TestSuiteRunFinishedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *TestSuiteRunFinishedEvent) SetId(id string) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *TestSuiteRunFinishedEvent) SetSource(source string) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -127,19 +127,19 @@ func (e *TestSuiteRunFinishedEvent) SetSource(source string) { } } -func (e *TestSuiteRunFinishedEvent) SetTimestamp(timestamp time.Time) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *TestSuiteRunFinishedEvent) SetSubjectId(subjectId string) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *TestSuiteRunFinishedEvent) SetSubjectSource(subjectSource string) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *TestSuiteRunFinishedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *TestSuiteRunFinishedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -149,38 +149,38 @@ func (e *TestSuiteRunFinishedEvent) SetCustomData(contentType string, data inter return nil } -func (e TestSuiteRunFinishedEvent) GetSchema() (string, string) { +func (e TestSuiteRunFinishedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), testsuiterunfinishedschema } // Set subject custom fields -func (e *TestSuiteRunFinishedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -func (e *TestSuiteRunFinishedEvent) SetSubjectOutcome(outcome string) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetSubjectOutcome(outcome string) { e.Subject.Content.Outcome = outcome } -func (e *TestSuiteRunFinishedEvent) SetSubjectReason(reason string) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetSubjectReason(reason string) { e.Subject.Content.Reason = reason } -func (e *TestSuiteRunFinishedEvent) SetSubjectSeverity(severity string) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetSubjectSeverity(severity string) { e.Subject.Content.Severity = severity } -func (e *TestSuiteRunFinishedEvent) SetSubjectTestSuite(testSuite *TestSuiteRunFinishedSubjectContentTestSuite) { +func (e *TestSuiteRunFinishedEventV0_1_0) SetSubjectTestSuite(testSuite *TestSuiteRunFinishedSubjectContentTestSuite) { e.Subject.Content.TestSuite = testSuite } -// New creates a new TestSuiteRunFinishedEvent -func NewTestSuiteRunFinishedEvent() (*TestSuiteRunFinishedEvent, error) { - e := &TestSuiteRunFinishedEvent{ +// New creates a new TestSuiteRunFinishedEventV0_1_0 +func NewTestSuiteRunFinishedEventV0_1_0() (*TestSuiteRunFinishedEventV0_1_0, error) { + e := &TestSuiteRunFinishedEventV0_1_0{ Context: Context{ - Type: TestSuiteRunFinishedEventV1.String(), + Type: TestSuiteRunFinishedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: TestSuiteRunFinishedSubject{ diff --git a/pkg/api/zz_testsuiterunqueued.go b/pkg/api/zz_testsuiterunqueued_0_1_0.go similarity index 71% rename from pkg/api/zz_testsuiterunqueued.go rename to pkg/api/zz_testsuiterunqueued_0_1_0.go index 0d1a585..e608ecf 100644 --- a/pkg/api/zz_testsuiterunqueued.go +++ b/pkg/api/zz_testsuiterunqueued_0_1_0.go @@ -28,8 +28,8 @@ import ( var testsuiterunqueuedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/test-suite-run-queued-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1},"type":{"type":"string","enum":["dev.cdevents.testsuiterun.queued.0.1.0"],"default":"dev.cdevents.testsuiterun.queued.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"},"type":{"type":"string","minLength":1,"enum":["testSuiteRun"],"default":"testSuiteRun"},"content":{"properties":{"trigger":{"type":"object","properties":{"type":{"type":"string","enum":["manual","pipeline","event","schedule","other"]},"uri":{"type":"string","format":"uri"}}},"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"testSuite":{"type":"object","additionalProperties":false,"required":["id"],"properties":{"id":{"type":"string","minLength":1},"version":{"type":"string"},"name":{"type":"string"},"url":{"type":"string","format":"uri"}}}},"additionalProperties":false,"type":"object","required":["environment"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // TestSuiteRunQueued event v0.1.0 - TestSuiteRunQueuedEventV1 CDEventType = CDEventType{ + // TestSuiteRunQueued event type v0.1.0 + TestSuiteRunQueuedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "testsuiterun", Predicate: "queued", Version: "0.1.0", @@ -53,7 +53,7 @@ func (sc TestSuiteRunQueuedSubject) GetSubjectType() SubjectType { return "testSuiteRun" } -type TestSuiteRunQueuedEvent struct { +type TestSuiteRunQueuedEventV0_1_0 struct { Context Context `json:"context"` Subject TestSuiteRunQueuedSubject `json:"subject"` CDEventCustomData @@ -61,61 +61,61 @@ type TestSuiteRunQueuedEvent struct { // CDEventsReader implementation -func (e TestSuiteRunQueuedEvent) GetType() CDEventType { - return TestSuiteRunQueuedEventV1 +func (e TestSuiteRunQueuedEventV0_1_0) GetType() CDEventType { + return TestSuiteRunQueuedEventTypeV0_1_0 } -func (e TestSuiteRunQueuedEvent) GetVersion() string { +func (e TestSuiteRunQueuedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e TestSuiteRunQueuedEvent) GetId() string { +func (e TestSuiteRunQueuedEventV0_1_0) GetId() string { return e.Context.Id } -func (e TestSuiteRunQueuedEvent) GetSource() string { +func (e TestSuiteRunQueuedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e TestSuiteRunQueuedEvent) GetTimestamp() time.Time { +func (e TestSuiteRunQueuedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e TestSuiteRunQueuedEvent) GetSubjectId() string { +func (e TestSuiteRunQueuedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e TestSuiteRunQueuedEvent) GetSubjectSource() string { +func (e TestSuiteRunQueuedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e TestSuiteRunQueuedEvent) GetSubject() Subject { +func (e TestSuiteRunQueuedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e TestSuiteRunQueuedEvent) GetCustomData() (interface{}, error) { +func (e TestSuiteRunQueuedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e TestSuiteRunQueuedEvent) GetCustomDataAs(receiver interface{}) error { +func (e TestSuiteRunQueuedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e TestSuiteRunQueuedEvent) GetCustomDataRaw() ([]byte, error) { +func (e TestSuiteRunQueuedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e TestSuiteRunQueuedEvent) GetCustomDataContentType() string { +func (e TestSuiteRunQueuedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *TestSuiteRunQueuedEvent) SetId(id string) { +func (e *TestSuiteRunQueuedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *TestSuiteRunQueuedEvent) SetSource(source string) { +func (e *TestSuiteRunQueuedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -123,19 +123,19 @@ func (e *TestSuiteRunQueuedEvent) SetSource(source string) { } } -func (e *TestSuiteRunQueuedEvent) SetTimestamp(timestamp time.Time) { +func (e *TestSuiteRunQueuedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *TestSuiteRunQueuedEvent) SetSubjectId(subjectId string) { +func (e *TestSuiteRunQueuedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *TestSuiteRunQueuedEvent) SetSubjectSource(subjectSource string) { +func (e *TestSuiteRunQueuedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *TestSuiteRunQueuedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *TestSuiteRunQueuedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -145,30 +145,30 @@ func (e *TestSuiteRunQueuedEvent) SetCustomData(contentType string, data interfa return nil } -func (e TestSuiteRunQueuedEvent) GetSchema() (string, string) { +func (e TestSuiteRunQueuedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), testsuiterunqueuedschema } // Set subject custom fields -func (e *TestSuiteRunQueuedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *TestSuiteRunQueuedEventV0_1_0) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -func (e *TestSuiteRunQueuedEvent) SetSubjectTestSuite(testSuite *TestSuiteRunQueuedSubjectContentTestSuite) { +func (e *TestSuiteRunQueuedEventV0_1_0) SetSubjectTestSuite(testSuite *TestSuiteRunQueuedSubjectContentTestSuite) { e.Subject.Content.TestSuite = testSuite } -func (e *TestSuiteRunQueuedEvent) SetSubjectTrigger(trigger *TestSuiteRunQueuedSubjectContentTrigger) { +func (e *TestSuiteRunQueuedEventV0_1_0) SetSubjectTrigger(trigger *TestSuiteRunQueuedSubjectContentTrigger) { e.Subject.Content.Trigger = trigger } -// New creates a new TestSuiteRunQueuedEvent -func NewTestSuiteRunQueuedEvent() (*TestSuiteRunQueuedEvent, error) { - e := &TestSuiteRunQueuedEvent{ +// New creates a new TestSuiteRunQueuedEventV0_1_0 +func NewTestSuiteRunQueuedEventV0_1_0() (*TestSuiteRunQueuedEventV0_1_0, error) { + e := &TestSuiteRunQueuedEventV0_1_0{ Context: Context{ - Type: TestSuiteRunQueuedEventV1.String(), + Type: TestSuiteRunQueuedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: TestSuiteRunQueuedSubject{ diff --git a/pkg/api/zz_testsuiterunstarted.go b/pkg/api/zz_testsuiterunstarted_0_1_0.go similarity index 70% rename from pkg/api/zz_testsuiterunstarted.go rename to pkg/api/zz_testsuiterunstarted_0_1_0.go index 646939f..41a4d11 100644 --- a/pkg/api/zz_testsuiterunstarted.go +++ b/pkg/api/zz_testsuiterunstarted_0_1_0.go @@ -28,8 +28,8 @@ import ( var testsuiterunstartedschema = `{"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://cdevents.dev/0.3.0/schema/test-suite-run-started-event","properties":{"context":{"properties":{"version":{"type":"string","minLength":1},"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1},"type":{"type":"string","enum":["dev.cdevents.testsuiterun.started.0.1.0"],"default":"dev.cdevents.testsuiterun.started.0.1.0"},"timestamp":{"type":"string","format":"date-time"}},"additionalProperties":false,"type":"object","required":["version","id","source","type","timestamp"]},"subject":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string"},"type":{"type":"string","minLength":1,"enum":["testSuiteRun"],"default":"testSuiteRun"},"content":{"properties":{"trigger":{"type":"object","properties":{"type":{"type":"string","enum":["manual","pipeline","event","schedule","other"]},"uri":{"type":"string","format":"uri"}}},"environment":{"properties":{"id":{"type":"string","minLength":1},"source":{"type":"string","minLength":1,"format":"uri-reference"}},"additionalProperties":false,"type":"object","required":["id"]},"testSuite":{"type":"object","additionalProperties":false,"required":["id"],"properties":{"id":{"type":"string","minLength":1},"version":{"type":"string"},"name":{"type":"string"},"uri":{"type":"string","format":"uri"}}}},"additionalProperties":false,"type":"object","required":["environment"]}},"additionalProperties":false,"type":"object","required":["id","type","content"]},"customData":{"oneOf":[{"type":"object"},{"type":"string","contentEncoding":"base64"}]},"customDataContentType":{"type":"string"}},"additionalProperties":false,"type":"object","required":["context","subject"]}` var ( - // TestSuiteRunStarted event v0.1.0 - TestSuiteRunStartedEventV1 CDEventType = CDEventType{ + // TestSuiteRunStarted event type v0.1.0 + TestSuiteRunStartedEventTypeV0_1_0 CDEventType = CDEventType{ Subject: "testsuiterun", Predicate: "started", Version: "0.1.0", @@ -53,7 +53,7 @@ func (sc TestSuiteRunStartedSubject) GetSubjectType() SubjectType { return "testSuiteRun" } -type TestSuiteRunStartedEvent struct { +type TestSuiteRunStartedEventV0_1_0 struct { Context Context `json:"context"` Subject TestSuiteRunStartedSubject `json:"subject"` CDEventCustomData @@ -61,61 +61,61 @@ type TestSuiteRunStartedEvent struct { // CDEventsReader implementation -func (e TestSuiteRunStartedEvent) GetType() CDEventType { - return TestSuiteRunStartedEventV1 +func (e TestSuiteRunStartedEventV0_1_0) GetType() CDEventType { + return TestSuiteRunStartedEventTypeV0_1_0 } -func (e TestSuiteRunStartedEvent) GetVersion() string { +func (e TestSuiteRunStartedEventV0_1_0) GetVersion() string { return CDEventsSpecVersion } -func (e TestSuiteRunStartedEvent) GetId() string { +func (e TestSuiteRunStartedEventV0_1_0) GetId() string { return e.Context.Id } -func (e TestSuiteRunStartedEvent) GetSource() string { +func (e TestSuiteRunStartedEventV0_1_0) GetSource() string { return e.Context.Source } -func (e TestSuiteRunStartedEvent) GetTimestamp() time.Time { +func (e TestSuiteRunStartedEventV0_1_0) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e TestSuiteRunStartedEvent) GetSubjectId() string { +func (e TestSuiteRunStartedEventV0_1_0) GetSubjectId() string { return e.Subject.Id } -func (e TestSuiteRunStartedEvent) GetSubjectSource() string { +func (e TestSuiteRunStartedEventV0_1_0) GetSubjectSource() string { return e.Subject.Source } -func (e TestSuiteRunStartedEvent) GetSubject() Subject { +func (e TestSuiteRunStartedEventV0_1_0) GetSubject() Subject { return e.Subject } -func (e TestSuiteRunStartedEvent) GetCustomData() (interface{}, error) { +func (e TestSuiteRunStartedEventV0_1_0) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e TestSuiteRunStartedEvent) GetCustomDataAs(receiver interface{}) error { +func (e TestSuiteRunStartedEventV0_1_0) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e TestSuiteRunStartedEvent) GetCustomDataRaw() ([]byte, error) { +func (e TestSuiteRunStartedEventV0_1_0) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e TestSuiteRunStartedEvent) GetCustomDataContentType() string { +func (e TestSuiteRunStartedEventV0_1_0) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *TestSuiteRunStartedEvent) SetId(id string) { +func (e *TestSuiteRunStartedEventV0_1_0) SetId(id string) { e.Context.Id = id } -func (e *TestSuiteRunStartedEvent) SetSource(source string) { +func (e *TestSuiteRunStartedEventV0_1_0) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -123,19 +123,19 @@ func (e *TestSuiteRunStartedEvent) SetSource(source string) { } } -func (e *TestSuiteRunStartedEvent) SetTimestamp(timestamp time.Time) { +func (e *TestSuiteRunStartedEventV0_1_0) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *TestSuiteRunStartedEvent) SetSubjectId(subjectId string) { +func (e *TestSuiteRunStartedEventV0_1_0) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *TestSuiteRunStartedEvent) SetSubjectSource(subjectSource string) { +func (e *TestSuiteRunStartedEventV0_1_0) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *TestSuiteRunStartedEvent) SetCustomData(contentType string, data interface{}) error { +func (e *TestSuiteRunStartedEventV0_1_0) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -145,30 +145,30 @@ func (e *TestSuiteRunStartedEvent) SetCustomData(contentType string, data interf return nil } -func (e TestSuiteRunStartedEvent) GetSchema() (string, string) { +func (e TestSuiteRunStartedEventV0_1_0) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), testsuiterunstartedschema } // Set subject custom fields -func (e *TestSuiteRunStartedEvent) SetSubjectEnvironment(environment *Reference) { +func (e *TestSuiteRunStartedEventV0_1_0) SetSubjectEnvironment(environment *Reference) { e.Subject.Content.Environment = environment } -func (e *TestSuiteRunStartedEvent) SetSubjectTestSuite(testSuite *TestSuiteRunStartedSubjectContentTestSuite) { +func (e *TestSuiteRunStartedEventV0_1_0) SetSubjectTestSuite(testSuite *TestSuiteRunStartedSubjectContentTestSuite) { e.Subject.Content.TestSuite = testSuite } -func (e *TestSuiteRunStartedEvent) SetSubjectTrigger(trigger *TestSuiteRunStartedSubjectContentTrigger) { +func (e *TestSuiteRunStartedEventV0_1_0) SetSubjectTrigger(trigger *TestSuiteRunStartedSubjectContentTrigger) { e.Subject.Content.Trigger = trigger } -// New creates a new TestSuiteRunStartedEvent -func NewTestSuiteRunStartedEvent() (*TestSuiteRunStartedEvent, error) { - e := &TestSuiteRunStartedEvent{ +// New creates a new TestSuiteRunStartedEventV0_1_0 +func NewTestSuiteRunStartedEventV0_1_0() (*TestSuiteRunStartedEventV0_1_0, error) { + e := &TestSuiteRunStartedEventV0_1_0{ Context: Context{ - Type: TestSuiteRunStartedEventV1.String(), + Type: TestSuiteRunStartedEventTypeV0_1_0.String(), Version: CDEventsSpecVersion, }, Subject: TestSuiteRunStartedSubject{ diff --git a/pkg/api/zz_types.go b/pkg/api/zz_types.go index 4030d00..092b038 100644 --- a/pkg/api/zz_types.go +++ b/pkg/api/zz_types.go @@ -23,45 +23,45 @@ package api import "fmt" var CDEventsTypes = []CDEvent{ - &ArtifactPackagedEvent{}, - &ArtifactPublishedEvent{}, - &ArtifactSignedEvent{}, - &BranchCreatedEvent{}, - &BranchDeletedEvent{}, - &BuildFinishedEvent{}, - &BuildQueuedEvent{}, - &BuildStartedEvent{}, - &ChangeAbandonedEvent{}, - &ChangeCreatedEvent{}, - &ChangeMergedEvent{}, - &ChangeReviewedEvent{}, - &ChangeUpdatedEvent{}, - &EnvironmentCreatedEvent{}, - &EnvironmentDeletedEvent{}, - &EnvironmentModifiedEvent{}, - &IncidentDetectedEvent{}, - &IncidentReportedEvent{}, - &IncidentResolvedEvent{}, - &PipelineRunFinishedEvent{}, - &PipelineRunQueuedEvent{}, - &PipelineRunStartedEvent{}, - &RepositoryCreatedEvent{}, - &RepositoryDeletedEvent{}, - &RepositoryModifiedEvent{}, - &ServiceDeployedEvent{}, - &ServicePublishedEvent{}, - &ServiceRemovedEvent{}, - &ServiceRolledbackEvent{}, - &ServiceUpgradedEvent{}, - &TaskRunFinishedEvent{}, - &TaskRunStartedEvent{}, - &TestCaseRunFinishedEvent{}, - &TestCaseRunQueuedEvent{}, - &TestCaseRunStartedEvent{}, - &TestOutputPublishedEvent{}, - &TestSuiteRunFinishedEvent{}, - &TestSuiteRunQueuedEvent{}, - &TestSuiteRunStartedEvent{}, + &ArtifactPackagedEventV0_1_1{}, + &ArtifactPublishedEventV0_1_1{}, + &ArtifactSignedEventV0_1_0{}, + &BranchCreatedEventV0_1_2{}, + &BranchDeletedEventV0_1_2{}, + &BuildFinishedEventV0_1_1{}, + &BuildQueuedEventV0_1_1{}, + &BuildStartedEventV0_1_1{}, + &ChangeAbandonedEventV0_1_2{}, + &ChangeCreatedEventV0_1_2{}, + &ChangeMergedEventV0_1_2{}, + &ChangeReviewedEventV0_1_2{}, + &ChangeUpdatedEventV0_1_2{}, + &EnvironmentCreatedEventV0_1_1{}, + &EnvironmentDeletedEventV0_1_1{}, + &EnvironmentModifiedEventV0_1_1{}, + &IncidentDetectedEventV0_1_0{}, + &IncidentReportedEventV0_1_0{}, + &IncidentResolvedEventV0_1_0{}, + &PipelineRunFinishedEventV0_1_1{}, + &PipelineRunQueuedEventV0_1_1{}, + &PipelineRunStartedEventV0_1_1{}, + &RepositoryCreatedEventV0_1_1{}, + &RepositoryDeletedEventV0_1_1{}, + &RepositoryModifiedEventV0_1_1{}, + &ServiceDeployedEventV0_1_1{}, + &ServicePublishedEventV0_1_1{}, + &ServiceRemovedEventV0_1_1{}, + &ServiceRolledbackEventV0_1_1{}, + &ServiceUpgradedEventV0_1_1{}, + &TaskRunFinishedEventV0_1_1{}, + &TaskRunStartedEventV0_1_1{}, + &TestCaseRunFinishedEventV0_1_0{}, + &TestCaseRunQueuedEventV0_1_0{}, + &TestCaseRunStartedEventV0_1_0{}, + &TestOutputPublishedEventV0_1_0{}, + &TestSuiteRunFinishedEventV0_1_0{}, + &TestSuiteRunQueuedEventV0_1_0{}, + &TestSuiteRunStartedEventV0_1_0{}, } func init() { @@ -76,84 +76,84 @@ func init() { // This function can be used by users but it's meant mainly for testing purposes func NewCDEvent(eventType string) (CDEvent, error) { switch eventType { - case ArtifactPackagedEventV1.String(): - return NewArtifactPackagedEvent() - case ArtifactPublishedEventV1.String(): - return NewArtifactPublishedEvent() - case ArtifactSignedEventV1.String(): - return NewArtifactSignedEvent() - case BranchCreatedEventV1.String(): - return NewBranchCreatedEvent() - case BranchDeletedEventV1.String(): - return NewBranchDeletedEvent() - case BuildFinishedEventV1.String(): - return NewBuildFinishedEvent() - case BuildQueuedEventV1.String(): - return NewBuildQueuedEvent() - case BuildStartedEventV1.String(): - return NewBuildStartedEvent() - case ChangeAbandonedEventV1.String(): - return NewChangeAbandonedEvent() - case ChangeCreatedEventV1.String(): - return NewChangeCreatedEvent() - case ChangeMergedEventV1.String(): - return NewChangeMergedEvent() - case ChangeReviewedEventV1.String(): - return NewChangeReviewedEvent() - case ChangeUpdatedEventV1.String(): - return NewChangeUpdatedEvent() - case EnvironmentCreatedEventV1.String(): - return NewEnvironmentCreatedEvent() - case EnvironmentDeletedEventV1.String(): - return NewEnvironmentDeletedEvent() - case EnvironmentModifiedEventV1.String(): - return NewEnvironmentModifiedEvent() - case IncidentDetectedEventV1.String(): - return NewIncidentDetectedEvent() - case IncidentReportedEventV1.String(): - return NewIncidentReportedEvent() - case IncidentResolvedEventV1.String(): - return NewIncidentResolvedEvent() - case PipelineRunFinishedEventV1.String(): - return NewPipelineRunFinishedEvent() - case PipelineRunQueuedEventV1.String(): - return NewPipelineRunQueuedEvent() - case PipelineRunStartedEventV1.String(): - return NewPipelineRunStartedEvent() - case RepositoryCreatedEventV1.String(): - return NewRepositoryCreatedEvent() - case RepositoryDeletedEventV1.String(): - return NewRepositoryDeletedEvent() - case RepositoryModifiedEventV1.String(): - return NewRepositoryModifiedEvent() - case ServiceDeployedEventV1.String(): - return NewServiceDeployedEvent() - case ServicePublishedEventV1.String(): - return NewServicePublishedEvent() - case ServiceRemovedEventV1.String(): - return NewServiceRemovedEvent() - case ServiceRolledbackEventV1.String(): - return NewServiceRolledbackEvent() - case ServiceUpgradedEventV1.String(): - return NewServiceUpgradedEvent() - case TaskRunFinishedEventV1.String(): - return NewTaskRunFinishedEvent() - case TaskRunStartedEventV1.String(): - return NewTaskRunStartedEvent() - case TestCaseRunFinishedEventV1.String(): - return NewTestCaseRunFinishedEvent() - case TestCaseRunQueuedEventV1.String(): - return NewTestCaseRunQueuedEvent() - case TestCaseRunStartedEventV1.String(): - return NewTestCaseRunStartedEvent() - case TestOutputPublishedEventV1.String(): - return NewTestOutputPublishedEvent() - case TestSuiteRunFinishedEventV1.String(): - return NewTestSuiteRunFinishedEvent() - case TestSuiteRunQueuedEventV1.String(): - return NewTestSuiteRunQueuedEvent() - case TestSuiteRunStartedEventV1.String(): - return NewTestSuiteRunStartedEvent() + case ArtifactPackagedEventTypeV0_1_1.String(): + return NewArtifactPackagedEventV0_1_1() + case ArtifactPublishedEventTypeV0_1_1.String(): + return NewArtifactPublishedEventV0_1_1() + case ArtifactSignedEventTypeV0_1_0.String(): + return NewArtifactSignedEventV0_1_0() + case BranchCreatedEventTypeV0_1_2.String(): + return NewBranchCreatedEventV0_1_2() + case BranchDeletedEventTypeV0_1_2.String(): + return NewBranchDeletedEventV0_1_2() + case BuildFinishedEventTypeV0_1_1.String(): + return NewBuildFinishedEventV0_1_1() + case BuildQueuedEventTypeV0_1_1.String(): + return NewBuildQueuedEventV0_1_1() + case BuildStartedEventTypeV0_1_1.String(): + return NewBuildStartedEventV0_1_1() + case ChangeAbandonedEventTypeV0_1_2.String(): + return NewChangeAbandonedEventV0_1_2() + case ChangeCreatedEventTypeV0_1_2.String(): + return NewChangeCreatedEventV0_1_2() + case ChangeMergedEventTypeV0_1_2.String(): + return NewChangeMergedEventV0_1_2() + case ChangeReviewedEventTypeV0_1_2.String(): + return NewChangeReviewedEventV0_1_2() + case ChangeUpdatedEventTypeV0_1_2.String(): + return NewChangeUpdatedEventV0_1_2() + case EnvironmentCreatedEventTypeV0_1_1.String(): + return NewEnvironmentCreatedEventV0_1_1() + case EnvironmentDeletedEventTypeV0_1_1.String(): + return NewEnvironmentDeletedEventV0_1_1() + case EnvironmentModifiedEventTypeV0_1_1.String(): + return NewEnvironmentModifiedEventV0_1_1() + case IncidentDetectedEventTypeV0_1_0.String(): + return NewIncidentDetectedEventV0_1_0() + case IncidentReportedEventTypeV0_1_0.String(): + return NewIncidentReportedEventV0_1_0() + case IncidentResolvedEventTypeV0_1_0.String(): + return NewIncidentResolvedEventV0_1_0() + case PipelineRunFinishedEventTypeV0_1_1.String(): + return NewPipelineRunFinishedEventV0_1_1() + case PipelineRunQueuedEventTypeV0_1_1.String(): + return NewPipelineRunQueuedEventV0_1_1() + case PipelineRunStartedEventTypeV0_1_1.String(): + return NewPipelineRunStartedEventV0_1_1() + case RepositoryCreatedEventTypeV0_1_1.String(): + return NewRepositoryCreatedEventV0_1_1() + case RepositoryDeletedEventTypeV0_1_1.String(): + return NewRepositoryDeletedEventV0_1_1() + case RepositoryModifiedEventTypeV0_1_1.String(): + return NewRepositoryModifiedEventV0_1_1() + case ServiceDeployedEventTypeV0_1_1.String(): + return NewServiceDeployedEventV0_1_1() + case ServicePublishedEventTypeV0_1_1.String(): + return NewServicePublishedEventV0_1_1() + case ServiceRemovedEventTypeV0_1_1.String(): + return NewServiceRemovedEventV0_1_1() + case ServiceRolledbackEventTypeV0_1_1.String(): + return NewServiceRolledbackEventV0_1_1() + case ServiceUpgradedEventTypeV0_1_1.String(): + return NewServiceUpgradedEventV0_1_1() + case TaskRunFinishedEventTypeV0_1_1.String(): + return NewTaskRunFinishedEventV0_1_1() + case TaskRunStartedEventTypeV0_1_1.String(): + return NewTaskRunStartedEventV0_1_1() + case TestCaseRunFinishedEventTypeV0_1_0.String(): + return NewTestCaseRunFinishedEventV0_1_0() + case TestCaseRunQueuedEventTypeV0_1_0.String(): + return NewTestCaseRunQueuedEventV0_1_0() + case TestCaseRunStartedEventTypeV0_1_0.String(): + return NewTestCaseRunStartedEventV0_1_0() + case TestOutputPublishedEventTypeV0_1_0.String(): + return NewTestOutputPublishedEventV0_1_0() + case TestSuiteRunFinishedEventTypeV0_1_0.String(): + return NewTestSuiteRunFinishedEventV0_1_0() + case TestSuiteRunQueuedEventTypeV0_1_0.String(): + return NewTestSuiteRunQueuedEventV0_1_0() + case TestSuiteRunStartedEventTypeV0_1_0.String(): + return NewTestSuiteRunStartedEventV0_1_0() default: return nil, fmt.Errorf("event %v not supported", eventType) } diff --git a/pkg/api/zz_ztest_foosubjectbarpredicate.go b/pkg/api/zz_ztest_foosubjectbarpredicate_1_2_3.go similarity index 97% rename from pkg/api/zz_ztest_foosubjectbarpredicate.go rename to pkg/api/zz_ztest_foosubjectbarpredicate_1_2_3.go index 88d64f9..1ed67a4 100644 --- a/pkg/api/zz_ztest_foosubjectbarpredicate.go +++ b/pkg/api/zz_ztest_foosubjectbarpredicate_1_2_3.go @@ -29,7 +29,7 @@ var foosubjectbarpredicateschema = `{"$schema":"https://json-schema.org/draft/20 var ( // FooSubjectBarPredicate event v1.2.3 - FooSubjectBarPredicateEventV1 CDEventType = CDEventType{ + FooSubjectBarPredicateEventV1_2_3 CDEventType = CDEventType{ Subject: "foosubject", Predicate: "barpredicate", Version: "1.2.3", @@ -52,7 +52,7 @@ type FooSubjectBarPredicateSubject struct { } func (sc FooSubjectBarPredicateSubject) GetEventType() CDEventType { - return FooSubjectBarPredicateEventV1 + return FooSubjectBarPredicateEventV1_2_3 } func (sc FooSubjectBarPredicateSubject) GetSubjectType() SubjectType { @@ -68,7 +68,7 @@ type FooSubjectBarPredicateEvent struct { // CDEventsReader implementation func (e FooSubjectBarPredicateEvent) GetType() CDEventType { - return FooSubjectBarPredicateEventV1 + return FooSubjectBarPredicateEventV1_2_3 } func (e FooSubjectBarPredicateEvent) GetVersion() string { @@ -178,7 +178,7 @@ func (e *FooSubjectBarPredicateEvent) SetSubjectReferenceField(referenceField *R func NewFooSubjectBarPredicateEvent() (*FooSubjectBarPredicateEvent, error) { e := &FooSubjectBarPredicateEvent{ Context: Context{ - Type: FooSubjectBarPredicateEventV1.String(), + Type: FooSubjectBarPredicateEventV1_2_3.String(), Version: CDEventsSpecVersion, }, Subject: FooSubjectBarPredicateSubject{ diff --git a/tools/generator.go b/tools/generator.go index 426f7b4..131a9db 100644 --- a/tools/generator.go +++ b/tools/generator.go @@ -39,10 +39,13 @@ import ( var ( TEMPLATES = "tools/templates/*.tmpl" - SCHEMA_FOLDER = "./pkg/api/spec/schemas" + PROJECT_ROOT = "./pkg/api" + SPEC_FOLDER_PREFIX = "spec-" + SPEC_VERSIONS = []string{"v0.3"} + SCHEMA_FOLDER = "schemas" GEN_CODE_FOLDER = "./pkg/api" TEST_TEMPLATES = "tools/templates_test/*.tmpl" - TEST_SCHEMA_FOLDER = "./pkg/api/tests/schemas" + TEST_SCHEMA_FOLDER = "tests" TEST_GEN_CODE_FOLDER = "./pkg/api" TEST_OUTPUT_PREFIX = "ztest_" @@ -94,6 +97,7 @@ type Data struct { Predicate string PredicateLower string Version string + VersionName string SubjectType string Contents []ContentField ContentTypes []ContentType @@ -106,7 +110,7 @@ type AllData struct { } func (d Data) OutputFile() string { - return "zz_" + d.Prefix + d.SubjectLower + d.PredicateLower + ".go" + return "zz_" + d.Prefix + d.SubjectLower + d.PredicateLower + "_" + d.VersionName + ".go" } func init() { @@ -134,15 +138,19 @@ func main() { var err error // Generate SDK files - log.Printf("Generating SDK files from templates: %s and schemas: %s into %s", TEMPLATES, SCHEMA_FOLDER, GEN_CODE_FOLDER) - err = generate(TEMPLATES, SCHEMA_FOLDER, GEN_CODE_FOLDER, "", GO_TYPES_NAMES) - if err != nil { - log.Fatalf("%s", err.Error()) + for _, version := range SPEC_VERSIONS { + versioned_schema_folder := filepath.Join(PROJECT_ROOT, SPEC_FOLDER_PREFIX+version, SCHEMA_FOLDER) + log.Printf("Generating SDK files from templates: %s and schemas: %s into %s", TEMPLATES, versioned_schema_folder, GEN_CODE_FOLDER) + err = generate(TEMPLATES, versioned_schema_folder, GEN_CODE_FOLDER, "", GO_TYPES_NAMES) + if err != nil { + log.Fatalf("%s", err.Error()) + } } // Generate SDK test files - log.Printf("Generating SDK files from templates: %s and schemas: %s into %s", TEST_TEMPLATES, TEST_SCHEMA_FOLDER, TEST_GEN_CODE_FOLDER) - err = generate(TEST_TEMPLATES, TEST_SCHEMA_FOLDER, TEST_GEN_CODE_FOLDER, TEST_OUTPUT_PREFIX, GO_TYPES_TEST_NAMES) + test_schema_folder := filepath.Join(PROJECT_ROOT, TEST_SCHEMA_FOLDER, SCHEMA_FOLDER) + log.Printf("Generating SDK files from templates: %s and schemas: %s into %s", TEST_TEMPLATES, test_schema_folder, TEST_GEN_CODE_FOLDER) + err = generate(TEST_TEMPLATES, test_schema_folder, TEST_GEN_CODE_FOLDER, TEST_OUTPUT_PREFIX, GO_TYPES_TEST_NAMES) if err != nil { log.Fatalf("%s", err.Error()) } @@ -168,7 +176,7 @@ func generate(templatesFolder, schemaFolder, genFolder, prefix string, goTypes m } // Process the types template - outputFileName := genFolder + string(os.PathSeparator) + "zz_" + prefix + strings.TrimSuffix(typesTemplateFileName, filepath.Ext(typesTemplateFileName)) + outputFileName := filepath.Join(genFolder, "zz_"+prefix+strings.TrimSuffix(typesTemplateFileName, filepath.Ext(typesTemplateFileName))) err = executeTemplate(allTemplates, typesTemplateFileName, outputFileName, allData.Slice) if err != nil { return err @@ -177,7 +185,7 @@ func generate(templatesFolder, schemaFolder, genFolder, prefix string, goTypes m // Process example test files - only for real data if prefix == "" { for _, examplesTestsTemplateFileName := range examplesTestsTemplateFileNames { - outputFileName := genFolder + string(os.PathSeparator) + "zz_" + prefix + strings.TrimSuffix(examplesTestsTemplateFileName, filepath.Ext(examplesTestsTemplateFileName)) + outputFileName := filepath.Join(genFolder, "zz_"+prefix+strings.TrimSuffix(examplesTestsTemplateFileName, filepath.Ext(examplesTestsTemplateFileName))) err = executeTemplate(allTemplates, examplesTestsTemplateFileName, outputFileName, allData.Slice) if err != nil { return err @@ -190,6 +198,7 @@ func generate(templatesFolder, schemaFolder, genFolder, prefix string, goTypes m func executeTemplate(allTemplates *template.Template, templateName, outputFileName string, data interface{}) error { // Write the template output to a buffer generated := new(bytes.Buffer) + err := allTemplates.ExecuteTemplate(generated, templateName, data) if err != nil { return err @@ -248,7 +257,7 @@ func getWalkProcessor(allTemplates *template.Template, genFolder string, goTypes allData.Slice = append(allData.Slice, *data) // Execute the template - return executeTemplate(allTemplates, eventTemplateFileName, genFolder+string(os.PathSeparator)+data.OutputFile(), data) + return executeTemplate(allTemplates, eventTemplateFileName, filepath.Join(genFolder, data.OutputFile()), data) } } @@ -351,6 +360,7 @@ func DataFromSchema(schema *jsonschema.Schema, mappings map[string]string) (*Dat SubjectLower: eventType.Subject, PredicateLower: eventType.Predicate, Version: eventType.Version, + VersionName: strings.ReplaceAll(eventType.Version, ".", "_"), SubjectType: subjectTypeString, Contents: contentFields, ContentTypes: contentTypes, diff --git a/tools/generator_test.go b/tools/generator_test.go index 9ff7078..02f571c 100644 --- a/tools/generator_test.go +++ b/tools/generator_test.go @@ -35,6 +35,7 @@ var ( testSubjectType = "fooSubject" testPredicate = "BarPredicate" testVersion = "1.2.3" + testVersionName = "1_2_3" ) func panicOnError(err error) { @@ -57,6 +58,7 @@ func TestDataFromSchema(t *testing.T) { SubjectLower: strings.ToLower(testSubject), PredicateLower: strings.ToLower(testPredicate), Version: testVersion, + VersionName: testVersionName, SubjectType: testSubjectType, Contents: []ContentField{{ Name: "ArtifactId", diff --git a/tools/templates/event.go.tmpl b/tools/templates/event.go.tmpl index 15a3948..3cca859 100644 --- a/tools/templates/event.go.tmpl +++ b/tools/templates/event.go.tmpl @@ -28,8 +28,8 @@ import ( var {{.SubjectLower}}{{.PredicateLower}}schema = `{{ .Schema }}` var ( - // {{.Subject}}{{.Predicate}} event v{{.Version}} - {{.Subject}}{{.Predicate}}EventV1 CDEventType = CDEventType{ + // {{.Subject}}{{.Predicate}} event type v{{.Version}} + {{.Subject}}{{.Predicate}}EventTypeV{{.VersionName}} CDEventType = CDEventType{ Subject: "{{.SubjectLower}}", Predicate: "{{.PredicateLower}}", Version: "{{.Version}}", @@ -51,7 +51,7 @@ func (sc {{.Subject}}{{.Predicate}}Subject) GetSubjectType() SubjectType { return "{{.SubjectType}}" } -type {{.Subject}}{{.Predicate}}Event struct { +type {{.Subject}}{{.Predicate}}EventV{{.VersionName}} struct { Context Context `json:"context"` Subject {{.Subject}}{{.Predicate}}Subject `json:"subject"` CDEventCustomData @@ -59,61 +59,61 @@ type {{.Subject}}{{.Predicate}}Event struct { // CDEventsReader implementation -func (e {{.Subject}}{{.Predicate}}Event) GetType() CDEventType { - return {{.Subject}}{{.Predicate}}EventV1 +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetType() CDEventType { + return {{.Subject}}{{.Predicate}}EventTypeV{{.VersionName}} } -func (e {{.Subject}}{{.Predicate}}Event) GetVersion() string { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetVersion() string { return CDEventsSpecVersion } -func (e {{.Subject}}{{.Predicate}}Event) GetId() string { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetId() string { return e.Context.Id } -func (e {{.Subject}}{{.Predicate}}Event) GetSource() string { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetSource() string { return e.Context.Source } -func (e {{.Subject}}{{.Predicate}}Event) GetTimestamp() time.Time { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetTimestamp() time.Time { return e.Context.Timestamp } -func (e {{.Subject}}{{.Predicate}}Event) GetSubjectId() string { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetSubjectId() string { return e.Subject.Id } -func (e {{.Subject}}{{.Predicate}}Event) GetSubjectSource() string { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetSubjectSource() string { return e.Subject.Source } -func (e {{.Subject}}{{.Predicate}}Event) GetSubject() Subject { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetSubject() Subject { return e.Subject } -func (e {{.Subject}}{{.Predicate}}Event) GetCustomData() (interface{}, error) { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetCustomData() (interface{}, error) { return GetCustomData(e.CustomDataContentType, e.CustomData) } -func (e {{.Subject}}{{.Predicate}}Event) GetCustomDataAs(receiver interface{}) error { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetCustomDataAs(receiver interface{}) error { return GetCustomDataAs(e, receiver) } -func (e {{.Subject}}{{.Predicate}}Event) GetCustomDataRaw() ([]byte, error) { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetCustomDataRaw() ([]byte, error) { return GetCustomDataRaw(e.CustomDataContentType, e.CustomData) } -func (e {{.Subject}}{{.Predicate}}Event) GetCustomDataContentType() string { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetCustomDataContentType() string { return e.CustomDataContentType } // CDEventsWriter implementation -func (e *{{.Subject}}{{.Predicate}}Event) SetId(id string) { +func (e *{{.Subject}}{{.Predicate}}EventV{{.VersionName}}) SetId(id string) { e.Context.Id = id } -func (e *{{.Subject}}{{.Predicate}}Event) SetSource(source string) { +func (e *{{.Subject}}{{.Predicate}}EventV{{.VersionName}}) SetSource(source string) { e.Context.Source = source // Default the subject source to the event source if e.Subject.Source == "" { @@ -121,19 +121,19 @@ func (e *{{.Subject}}{{.Predicate}}Event) SetSource(source string) { } } -func (e *{{.Subject}}{{.Predicate}}Event) SetTimestamp(timestamp time.Time) { +func (e *{{.Subject}}{{.Predicate}}EventV{{.VersionName}}) SetTimestamp(timestamp time.Time) { e.Context.Timestamp = timestamp } -func (e *{{.Subject}}{{.Predicate}}Event) SetSubjectId(subjectId string) { +func (e *{{.Subject}}{{.Predicate}}EventV{{.VersionName}}) SetSubjectId(subjectId string) { e.Subject.Id = subjectId } -func (e *{{.Subject}}{{.Predicate}}Event) SetSubjectSource(subjectSource string) { +func (e *{{.Subject}}{{.Predicate}}EventV{{.VersionName}}) SetSubjectSource(subjectSource string) { e.Subject.Source = subjectSource } -func (e *{{.Subject}}{{.Predicate}}Event) SetCustomData(contentType string, data interface{}) error { +func (e *{{.Subject}}{{.Predicate}}EventV{{.VersionName}}) SetCustomData(contentType string, data interface{}) error { err := CheckCustomData(contentType, data) if err != nil { return err @@ -143,23 +143,23 @@ func (e *{{.Subject}}{{.Predicate}}Event) SetCustomData(contentType string, data return nil } -func (e {{.Subject}}{{.Predicate}}Event) GetSchema() (string, string) { +func (e {{.Subject}}{{.Predicate}}EventV{{.VersionName}}) GetSchema() (string, string) { eType := e.GetType() return fmt.Sprintf(CDEventsSchemaURLTemplate, CDEventsSpecVersion, eType.Subject, eType.Predicate), {{.SubjectLower}}{{.PredicateLower}}schema } // Set subject custom fields {{ range $i, $field := .Contents }} -func (e *{{$.Subject}}{{$.Predicate}}Event) SetSubject{{ .Name }}({{ .NameLower }} {{ .Type }}) { +func (e *{{$.Subject}}{{$.Predicate}}EventV{{$.VersionName}}) SetSubject{{ .Name }}({{ .NameLower }} {{ .Type }}) { e.Subject.Content.{{ .Name }} = {{ .NameLower }} } {{ end }} -// New creates a new {{.Subject}}{{.Predicate}}Event -func New{{.Subject}}{{.Predicate}}Event() (*{{.Subject}}{{.Predicate}}Event, error) { - e := &{{.Subject}}{{.Predicate}}Event{ +// New creates a new {{.Subject}}{{.Predicate}}EventV{{.VersionName}} +func New{{.Subject}}{{.Predicate}}EventV{{.VersionName}}() (*{{.Subject}}{{.Predicate}}EventV{{.VersionName}}, error) { + e := &{{.Subject}}{{.Predicate}}EventV{{.VersionName}}{ Context: Context{ - Type: {{.Subject}}{{.Predicate}}EventV1.String(), + Type: {{.Subject}}{{.Predicate}}EventTypeV{{.VersionName}}.String(), Version: CDEventsSpecVersion, }, Subject: {{.Subject}}{{.Predicate}}Subject{ diff --git a/tools/templates/examples_test.go.tmpl b/tools/templates/examples_test.go.tmpl index a99edf0..29aadbd 100644 --- a/tools/templates/examples_test.go.tmpl +++ b/tools/templates/examples_test.go.tmpl @@ -18,15 +18,17 @@ limitations under the License. SPDX-License-Identifier: Apache-2.0 */ -package api +package api_test + +import "github.com/cdevents/sdk-go/pkg/api" func init() { // Create events equal to examples in the spec - examplesProduced = make(map[string]CDEvent) + examplesProduced = make(map[string]api.CDEvent) {{- range $i, $data := . }} // {{ .Subject }}{{ .Predicate }} Event producer - new{{ .Subject }}{{ .Predicate }}, _ := New{{ .Subject }}{{ .Predicate }}Event() + new{{ .Subject }}{{ .Predicate }}, _ := api.New{{ .Subject }}{{ .Predicate }}EventV{{ .VersionName }}() setContext(new{{ .Subject }}{{ .Predicate }}, testSubjectId) example{{ .Subject }}{{ .Predicate }}Event(new{{ .Subject }}{{ .Predicate }}) examplesProduced[new{{ .Subject }}{{ .Predicate }}.GetType().Short()] = new{{ .Subject }}{{ .Predicate }} diff --git a/tools/templates/factory_test.go.tmpl b/tools/templates/factory_test.go.tmpl index fa669bc..da885aa 100644 --- a/tools/templates/factory_test.go.tmpl +++ b/tools/templates/factory_test.go.tmpl @@ -18,7 +18,9 @@ limitations under the License. SPDX-License-Identifier: Apache-2.0 */ -package api +package api_test + +import "github.com/cdevents/sdk-go/pkg/api" func init() { tests = []testNewCDEventType{} @@ -26,16 +28,16 @@ func init() { {{- range $i, $data := . }} tests = append(tests, testNewCDEventType{ name: "{{ .SubjectLower }} {{ .PredicateLower }}", - eventType: {{ .Subject }}{{ .Predicate }}EventV1. String(), - expectedEvent: &{{ .Subject }}{{ .Predicate }}Event{ - Context: Context{ - Type: {{ .Subject }}{{ .Predicate }}EventV1.String(), + eventType: api.{{ .Subject }}{{ .Predicate }}EventTypeV{{.VersionName}}.String(), + expectedEvent: &api.{{ .Subject }}{{ .Predicate }}EventV{{.VersionName}}{ + Context: api.Context{ + Type: api.{{ .Subject }}{{ .Predicate }}EventTypeV{{.VersionName}}.String(), Timestamp: timeNow(), Id: testUUID(), - Version: CDEventsSpecVersion, + Version: api.CDEventsSpecVersion, }, - Subject: {{ .Subject }}{{ .Predicate }}Subject{ - SubjectBase: SubjectBase{ + Subject: api.{{ .Subject }}{{ .Predicate }}Subject{ + SubjectBase: api.SubjectBase{ Type: "{{ .SubjectType }}", }, }, diff --git a/tools/templates/types.go.tmpl b/tools/templates/types.go.tmpl index 9b3b11f..33af594 100644 --- a/tools/templates/types.go.tmpl +++ b/tools/templates/types.go.tmpl @@ -24,7 +24,7 @@ import "fmt" var CDEventsTypes = []CDEvent{ {{- range $i, $data := . }} - &{{ .Subject }}{{ .Predicate }}Event{}, + &{{ .Subject }}{{ .Predicate }}EventV{{ .VersionName }}{}, {{- end }} } @@ -41,8 +41,8 @@ func init() { func NewCDEvent(eventType string) (CDEvent, error) { switch eventType { {{- range $i, $data := . }} - case {{ .Subject }}{{ .Predicate }}EventV1.String(): - return New{{ .Subject }}{{ .Predicate }}Event() + case {{ .Subject }}{{ .Predicate }}EventTypeV{{.VersionName}}.String(): + return New{{ .Subject }}{{ .Predicate }}EventV{{.VersionName}}() {{- end }} default: return nil, fmt.Errorf("event %v not supported", eventType) diff --git a/tools/templates_test/event.go.tmpl b/tools/templates_test/event.go.tmpl index 188ad1b..50fcd1b 100644 --- a/tools/templates_test/event.go.tmpl +++ b/tools/templates_test/event.go.tmpl @@ -29,7 +29,7 @@ var {{.SubjectLower}}{{.PredicateLower}}schema = `{{ .Schema }}` var ( // {{.Subject}}{{.Predicate}} event v{{.Version}} - {{.Subject}}{{.Predicate}}EventV1 CDEventType = CDEventType{ + {{.Subject}}{{.Predicate}}EventV{{.VersionName}} CDEventType = CDEventType{ Subject: "{{.SubjectLower}}", Predicate: "{{.PredicateLower}}", Version: "{{.Version}}", @@ -48,7 +48,7 @@ type {{.Subject}}{{.Predicate}}Subject struct { } func (sc {{.Subject}}{{.Predicate}}Subject) GetEventType() CDEventType { - return {{.Subject}}{{.Predicate}}EventV1 + return {{.Subject}}{{.Predicate}}EventV{{.VersionName}} } func (sc {{.Subject}}{{.Predicate}}Subject) GetSubjectType() SubjectType { @@ -64,7 +64,7 @@ type {{.Subject}}{{.Predicate}}Event struct { // CDEventsReader implementation func (e {{.Subject}}{{.Predicate}}Event) GetType() CDEventType { - return {{.Subject}}{{.Predicate}}EventV1 + return {{.Subject}}{{.Predicate}}EventV{{.VersionName}} } func (e {{.Subject}}{{.Predicate}}Event) GetVersion() string { @@ -163,7 +163,7 @@ func (e *{{$.Subject}}{{$.Predicate}}Event) SetSubject{{ .Name }}({{ .NameLower func New{{.Subject}}{{.Predicate}}Event() (*{{.Subject}}{{.Predicate}}Event, error) { e := &{{.Subject}}{{.Predicate}}Event{ Context: Context{ - Type: {{.Subject}}{{.Predicate}}EventV1.String(), + Type: {{.Subject}}{{.Predicate}}EventV{{.VersionName}}.String(), Version: CDEventsSpecVersion, }, Subject: {{.Subject}}{{.Predicate}}Subject{