diff --git a/apis/executor/v1/executor_types.go b/apis/executor/v1/executor_types.go index 3f3338b9..75b64366 100644 --- a/apis/executor/v1/executor_types.go +++ b/apis/executor/v1/executor_types.go @@ -33,7 +33,7 @@ type ExecutorSpec struct { // ExecutorType one of "rest" for rest openapi based executors or "job" which will be default runners for testkube // or "container" for container executors - ExecutorType string `json:"executor_type,omitempty"` + ExecutorType ExecutorType `json:"executor_type,omitempty"` // URI for rest based executors URI string `json:"uri,omitempty"` @@ -68,6 +68,14 @@ const ( FeatureJUnitReport Feature = "junit-report" ) +// +kubebuilder:validation:Enum=job;container +type ExecutorType string + +const ( + ExecutorTypeJob ExecutorType = "job" + ExecutorTypeContainer ExecutorType = "container" +) + // +kubebuilder:validation:Enum=string;file-uri;git-file;git-dir;git type ScriptContentType string diff --git a/apis/executor/v1/webhook_types.go b/apis/executor/v1/webhook_types.go index 0f683cf1..569d6149 100644 --- a/apis/executor/v1/webhook_types.go +++ b/apis/executor/v1/webhook_types.go @@ -31,13 +31,30 @@ type WebhookSpec struct { // Uri is address where webhook should be made Uri string `json:"uri,omitempty"` // Events declare list if events on which webhook should be called - Events []string `json:"events,omitempty"` + Events []EventType `json:"events,omitempty"` // Labels to filter for tests and test suites Selector string `json:"selector,omitempty"` // will load the generated payload for notification inside the object PayloadObjectField string `json:"payloadObjectField,omitempty"` } +// +kubebuilder:validation:Enum=start-test;end-test-success;end-test-failed;end-test-aborted;end-test-timeout;start-testsuite;end-testsuite-success;end-testsuite-failed;end-testsuite-aborted;end-testsuite-timeout +type EventType string + +// List of EventType +const ( + START_TEST_EventType EventType = "start-test" + END_TEST_SUCCESS_EventType EventType = "end-test-success" + END_TEST_FAILED_EventType EventType = "end-test-failed" + END_TEST_ABORTED_EventType EventType = "end-test-aborted" + END_TEST_TIMEOUT_EventType EventType = "end-test-timeout" + START_TESTSUITE_EventType EventType = "start-testsuite" + END_TESTSUITE_SUCCESS_EventType EventType = "end-testsuite-success" + END_TESTSUITE_FAILED_EventType EventType = "end-testsuite-failed" + END_TESTSUITE_ABORTED_EventType EventType = "end-testsuite-aborted" + END_TESTSUITE_TIMEOUT_EventType EventType = "end-testsuite-timeout" +) + // WebhookStatus defines the observed state of Webhook type WebhookStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster diff --git a/apis/executor/v1/zz_generated.deepcopy.go b/apis/executor/v1/zz_generated.deepcopy.go index 42b2d98f..6e3b6c81 100644 --- a/apis/executor/v1/zz_generated.deepcopy.go +++ b/apis/executor/v1/zz_generated.deepcopy.go @@ -251,7 +251,7 @@ func (in *WebhookSpec) DeepCopyInto(out *WebhookSpec) { *out = *in if in.Events != nil { in, out := &in.Events, &out.Events - *out = make([]string, len(*in)) + *out = make([]EventType, len(*in)) copy(*out, *in) } } diff --git a/apis/tests/v3/test_conversion.go b/apis/tests/v3/test_conversion.go index 4163d6ef..76ccfa91 100644 --- a/apis/tests/v3/test_conversion.go +++ b/apis/tests/v3/test_conversion.go @@ -52,7 +52,7 @@ func (src *Test) ConvertTo(dstRaw conversion.Hub) error { if src.Spec.Content != nil { dst.Spec.Content = &testkubev2.TestContent{ Data: src.Spec.Content.Data, - Type_: src.Spec.Content.Type_, + Type_: string(src.Spec.Content.Type_), Uri: src.Spec.Content.Uri, } } @@ -112,7 +112,7 @@ func (dst *Test) ConvertFrom(srcRaw conversion.Hub) error { if src.Spec.Content != nil { dst.Spec.Content = &TestContent{ Data: src.Spec.Content.Data, - Type_: src.Spec.Content.Type_, + Type_: TestContentType(src.Spec.Content.Type_), Uri: src.Spec.Content.Uri, } } diff --git a/apis/tests/v3/test_types.go b/apis/tests/v3/test_types.go index 625d98cb..94df43d5 100644 --- a/apis/tests/v3/test_types.go +++ b/apis/tests/v3/test_types.go @@ -50,7 +50,7 @@ type Variable commonv1.Variable // TestContent defines test content type TestContent struct { // test type - Type_ string `json:"type,omitempty"` + Type_ TestContentType `json:"type,omitempty"` // repository of test content Repository *Repository `json:"repository,omitempty"` // test content body @@ -59,6 +59,19 @@ type TestContent struct { Uri string `json:"uri,omitempty"` } +// +kubebuilder:validation:Enum=string;file-uri;git-file;git-dir;git +type TestContentType string + +const ( + TestContentTypeString TestContentType = "string" + TestContentTypeFileURI TestContentType = "file-uri" + // Deprecated: use git instead + TestContentTypeGitFile TestContentType = "git-file" + // Deprecated: use git instead + TestContentTypeGitDir TestContentType = "git-dir" + TestContentTypeGit TestContentType = "git" +) + // Testkube internal reference for secret storage in Kubernetes secrets type SecretRef struct { // object kubernetes namespace @@ -80,14 +93,28 @@ type Repository struct { // commit id (sha) for checkout Commit string `json:"commit,omitempty"` // if needed we can checkout particular path (dir or file) in case of BIG/mono repositories - Path string `json:"path,omitempty"` - UsernameSecret *SecretRef `json:"usernameSecret,omitempty"` - TokenSecret *SecretRef `json:"tokenSecret,omitempty"` - CertificateSecret string `json:"certificateSecret,omitempty"` + Path string `json:"path,omitempty"` + UsernameSecret *SecretRef `json:"usernameSecret,omitempty"` + TokenSecret *SecretRef `json:"tokenSecret,omitempty"` + // git auth certificate secret for private repositories + CertificateSecret string `json:"certificateSecret,omitempty"` // if provided we checkout the whole repository and run test from this directory WorkingDir string `json:"workingDir,omitempty"` + // auth type for git requests + AuthType GitAuthType `json:"authType,omitempty"` } +// GitAuthType defines git auth type +// +kubebuilder:validation:Enum=basic;header +type GitAuthType string + +const ( + // GitAuthTypeBasic for git basic auth requests + GitAuthTypeBasic GitAuthType = "basic" + // GitAuthTypeHeader for git header auth requests + GitAuthTypeHeader GitAuthType = "header" +) + // artifact request body for container executors with test artifacts type ArtifactRequest struct { // artifact storage class name @@ -101,11 +128,22 @@ type ArtifactRequest struct { // running context for test or test suite execution type RunningContext struct { // One of possible context types - Type_ string `json:"type"` + Type_ RunningContextType `json:"type"` // Context value depending from its type Context string `json:"context,omitempty"` } +type RunningContextType string + +const ( + RunningContextTypeUserCLI RunningContextType = "user-cli" + RunningContextTypeUserUI RunningContextType = "user-ui" + RunningContextTypeTestSuite RunningContextType = "testsuite" + RunningContextTypeTestTrigger RunningContextType = "testtrigger" + RunningContextTypeScheduler RunningContextType = "scheduler" + RunningContextTypeEmpty RunningContextType = "" +) + // test execution request body type ExecutionRequest struct { // test execution custom name @@ -165,17 +203,6 @@ type ExecutionRequest struct { RunningContext *RunningContext `json:"runningContext,omitempty"` } -type RunningContextType string - -const ( - RunningContextTypeUserCLI RunningContextType = "user-cli" - RunningContextTypeUserUI RunningContextType = "user-ui" - RunningContextTypeTestSuite RunningContextType = "testsuite" - RunningContextTypeTestTrigger RunningContextType = "testtrigger" - RunningContextTypeScheduler RunningContextType = "scheduler" - RunningContextTypeEmpty RunningContextType = "" -) - // Reference to env resource type EnvReference struct { v1.LocalObjectReference `json:"reference"` @@ -187,6 +214,7 @@ type EnvReference struct { MapToVariables bool `json:"mapToVariables,omitempty"` } +// +kubebuilder:validation:Enum=queued;running;passed;failed;aborted;timeout type ExecutionStatus string // List of ExecutionStatus diff --git a/apis/testsource/v1/testsource_types.go b/apis/testsource/v1/testsource_types.go index 01ce7499..a59ea30e 100644 --- a/apis/testsource/v1/testsource_types.go +++ b/apis/testsource/v1/testsource_types.go @@ -28,7 +28,7 @@ type TestSourceSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file - Type_ string `json:"type,omitempty"` + Type_ TestSourceType `json:"type,omitempty"` // repository of test content Repository *Repository `json:"repository,omitempty"` // test content body @@ -37,6 +37,19 @@ type TestSourceSpec struct { Uri string `json:"uri,omitempty"` } +// +kubebuilder:validation:Enum=string;file-uri;git-file;git-dir;git +type TestSourceType string + +const ( + TestSourceTypeString TestSourceType = "string" + TestSourceTypeFileURI TestSourceType = "file-uri" + // Deprecated: use git instead + TestSourceTypeGitFile TestSourceType = "git-file" + // Deprecated: use git instead + TestSourceTypeGitDir TestSourceType = "git-dir" + TestSourceTypeGit TestSourceType = "git" +) + // Testkube internal reference for secret storage in Kubernetes secrets type SecretRef struct { // object kubernetes namespace @@ -58,14 +71,28 @@ type Repository struct { // commit id (sha) for checkout Commit string `json:"commit,omitempty"` // if needed we can checkout particular path (dir or file) in case of BIG/mono repositories - Path string `json:"path,omitempty"` - UsernameSecret *SecretRef `json:"usernameSecret,omitempty"` - TokenSecret *SecretRef `json:"tokenSecret,omitempty"` - CertificateSecret string `json:"certificateSecret,omitempty"` + Path string `json:"path,omitempty"` + UsernameSecret *SecretRef `json:"usernameSecret,omitempty"` + TokenSecret *SecretRef `json:"tokenSecret,omitempty"` + // git auth certificate secret for private repositories + CertificateSecret string `json:"certificateSecret,omitempty"` // if provided we checkout the whole repository and run test from this directory WorkingDir string `json:"workingDir,omitempty"` + // auth type for git requests + AuthType GitAuthType `json:"authType,omitempty"` } +// GitAuthType defines git auth type +// +kubebuilder:validation:Enum=basic;header +type GitAuthType string + +const ( + // GitAuthTypeBasic for git basic auth requests + GitAuthTypeBasic GitAuthType = "basic" + // GitAuthTypeHeader for git header auth requests + GitAuthTypeHeader GitAuthType = "header" +) + // TestSourceStatus defines the observed state of TestSource type TestSourceStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster diff --git a/apis/testsuite/v1/testsuite_types.go b/apis/testsuite/v1/testsuite_types.go index b915ff44..e68b7b58 100644 --- a/apis/testsuite/v1/testsuite_types.go +++ b/apis/testsuite/v1/testsuite_types.go @@ -56,7 +56,7 @@ type TestSuiteStepSpec struct { Delay *TestSuiteStepDelay `json:"delay,omitempty"` } -// TestSuiteStepType deines different type of test suite steps +// TestSuiteStepType defines different type of test suite steps type TestSuiteStepType string const ( diff --git a/apis/testsuite/v2/testsuite_conversion.go b/apis/testsuite/v2/testsuite_conversion.go index f3ba6f7b..d8c5c73c 100644 --- a/apis/testsuite/v2/testsuite_conversion.go +++ b/apis/testsuite/v2/testsuite_conversion.go @@ -58,7 +58,7 @@ func (src *TestSuite) ConvertTo(dstRaw conversion.Hub) error { for i := range stepType.Source { value := stepType.Source[i] step := testkubev1.TestSuiteStepSpec{ - Type: value.Type, + Type: string(value.Type), } if value.Delay != nil { @@ -132,7 +132,7 @@ func (dst *TestSuite) ConvertFrom(srcRaw conversion.Hub) error { for i := range stepType.source { value := stepType.source[i] step := TestSuiteStepSpec{ - Type: value.Type, + Type: TestSuiteStepType(value.Type), } if value.Delay != nil { diff --git a/apis/testsuite/v2/testsuite_types.go b/apis/testsuite/v2/testsuite_types.go index 0f9c5863..151540eb 100644 --- a/apis/testsuite/v2/testsuite_types.go +++ b/apis/testsuite/v2/testsuite_types.go @@ -47,12 +47,13 @@ type Variable commonv1.Variable // TestSuiteStepSpec for particular type will have config for possible step types type TestSuiteStepSpec struct { - Type string `json:"type,omitempty"` + Type TestSuiteStepType `json:"type,omitempty"` Execute *TestSuiteStepExecute `json:"execute,omitempty"` Delay *TestSuiteStepDelay `json:"delay,omitempty"` } -// TestSuiteStepType deines different type of test suite steps +// TestSuiteStepType defines different type of test suite steps +// +kubebuilder:validation:Enum=execute;delay type TestSuiteStepType string const ( @@ -76,11 +77,22 @@ type TestSuiteStepDelay struct { // running context for test or test suite execution type RunningContext struct { // One of possible context types - Type_ string `json:"type"` + Type_ RunningContextType `json:"type"` // Context value depending from its type Context string `json:"context,omitempty"` } +type RunningContextType string + +const ( + RunningContextTypeUserCLI RunningContextType = "user-cli" + RunningContextTypeUserUI RunningContextType = "user-ui" + RunningContextTypeTestSuite RunningContextType = "testsuite" + RunningContextTypeTestTrigger RunningContextType = "testtrigger" + RunningContextTypeScheduler RunningContextType = "scheduler" + RunningContextTypeEmpty RunningContextType = "" +) + // test suite execution request body type TestSuiteExecutionRequest struct { // test execution custom name @@ -105,17 +117,7 @@ type TestSuiteExecutionRequest struct { RunningContext *RunningContext `json:"runningContext,omitempty"` } -type RunningContextType string - -const ( - RunningContextTypeUserCLI RunningContextType = "user-cli" - RunningContextTypeUserUI RunningContextType = "user-ui" - RunningContextTypeTestSuite RunningContextType = "testsuite" - RunningContextTypeTestTrigger RunningContextType = "testtrigger" - RunningContextTypeScheduler RunningContextType = "scheduler" - RunningContextTypeEmpty RunningContextType = "" -) - +// +kubebuilder:validation:Enum=queued;running;passed;failed;aborting;aborted;timeout type TestSuiteExecutionStatus string // List of TestSuiteExecutionStatus diff --git a/apis/testtriggers/v1/testtrigger_types.go b/apis/testtriggers/v1/testtrigger_types.go index e7e1b807..b794a3c8 100644 --- a/apis/testtriggers/v1/testtrigger_types.go +++ b/apis/testtriggers/v1/testtrigger_types.go @@ -42,17 +42,17 @@ type TestTrigger struct { // TestTriggerSpec defines the desired state of TestTrigger type TestTriggerSpec struct { // For which Resource do we monitor Event which triggers an Action on certain conditions - Resource string `json:"resource"` + Resource TestTriggerResource `json:"resource"` // ResourceSelector identifies which Kubernetes Objects should be watched ResourceSelector TestTriggerSelector `json:"resourceSelector"` // On which Event for a Resource should an Action be triggered - Event string `json:"event"` + Event TestTriggerEvent `json:"event"` // What resource conditions should be matched ConditionSpec *TestTriggerConditionSpec `json:"conditionSpec,omitempty"` // Action represents what needs to be executed for selected Execution - Action string `json:"action"` + Action TestTriggerAction `json:"action"` // Execution identifies for which test execution should an Action be executed - Execution string `json:"execution"` + Execution TestTriggerExecution `json:"execution"` // TestSelector identifies on which Testkube Kubernetes Objects an Action should be taken TestSelector TestTriggerSelector `json:"testSelector"` // Delay is a duration string which specifies how long should the test be delayed after a trigger is matched @@ -61,6 +61,56 @@ type TestTriggerSpec struct { Delay *metav1.Duration `json:"delay,omitempty"` } +// TestTriggerResource defines resource for test triggers +// +kubebuilder:validation:Enum=pod;deployment;statefulset;daemonset;service;ingress;event;configmap +type TestTriggerResource string + +// List of TestTriggerResources +const ( + TestTriggerResourcePod TestTriggerResource = "pod" + TestTriggerResourceDeployment TestTriggerResource = "deployment" + TestTriggerResourceStatefulSet TestTriggerResource = "statefulset" + TestTriggerResourceDaemonSet TestTriggerResource = "daemonset" + TestTriggerResourceService TestTriggerResource = "service" + TestTriggerResourceIngress TestTriggerResource = "ingress" + TestTriggerResourceEvent TestTriggerResource = "event" + TestTriggerResourceConfigMap TestTriggerResource = "configmap" +) + +// TestTriggerEvent defines event for test triggers +// +kubebuilder:validation:Enum=created;modified;deleted;deployment-scale-update;deployment-image-update;deployment-env-update;deployment-containers-modified +type TestTriggerEvent string + +// List of TestTriggerEvents +const ( + TestTriggerEventCreated TestTriggerEvent = "created" + TestTriggerEventModified TestTriggerEvent = "modified" + TestTriggerEventDeleted TestTriggerEvent = "deleted" + TestTriggerCauseDeploymentScaleUpdate TestTriggerEvent = "deployment-scale-update" + TestTriggerCauseDeploymentImageUpdate TestTriggerEvent = "deployment-image-update" + TestTriggerCauseDeploymentEnvUpdate TestTriggerEvent = "deployment-env-update" + TestTriggerCauseDeploymentContainersModified TestTriggerEvent = "deployment-containers-modified" +) + +// TestTriggerAction defines action for test triggers +// +kubebuilder:validation:Enum=run +type TestTriggerAction string + +// List of TestTriggerAction +const ( + TestTriggerActionRun TestTriggerAction = "run" +) + +// TestTriggerExecution defines execution for test triggers +// +kubebuilder:validation:Enum=test;testsuite +type TestTriggerExecution string + +// List of TestTriggerExecution +const ( + TestTriggerExecutionTest TestTriggerExecution = "test" + TestTriggerExecutionTestsuite TestTriggerExecution = "testsuite" +) + // TestTriggerSelector is used for selecting Kubernetes Objects type TestTriggerSelector struct { // Name selector is used to identify a Kubernetes Object based on the metadata name @@ -78,6 +128,7 @@ type TestTriggerStatus struct { } // TestTriggerConditionStatuses defines condition statuses for test triggers +// +kubebuilder:validation:Enum=True;False;Unknown type TestTriggerConditionStatuses string // List of TestTriggerConditionStatuses diff --git a/client/executors/v1/webhooks.go b/client/executors/v1/webhooks.go index d368cece..60237fef 100644 --- a/client/executors/v1/webhooks.go +++ b/client/executors/v1/webhooks.go @@ -50,7 +50,7 @@ func (s WebhooksClient) Get(name string) (*executorsv1.Webhook, error) { } // GetByEvent gets all webhooks with given event -func (s WebhooksClient) GetByEvent(event string) (*executorsv1.WebhookList, error) { +func (s WebhooksClient) GetByEvent(event executorsv1.EventType) (*executorsv1.WebhookList, error) { list := &executorsv1.WebhookList{} err := s.Client.List(context.Background(), list, &client.ListOptions{Namespace: s.Namespace}) if err != nil { diff --git a/client/executors/v1/webhooks_test.go b/client/executors/v1/webhooks_test.go index 69b4bee7..499650dc 100644 --- a/client/executors/v1/webhooks_test.go +++ b/client/executors/v1/webhooks_test.go @@ -20,7 +20,7 @@ func TestWebhooks(t *testing.T) { Namespace: "test-ns", }, Spec: executorsv1.WebhookSpec{ - Events: []string{"test-event1"}, + Events: []executorsv1.EventType{"test-event1"}, }, Status: executorsv1.WebhookStatus{}, }, @@ -30,7 +30,7 @@ func TestWebhooks(t *testing.T) { Namespace: "test-ns", }, Spec: executorsv1.WebhookSpec{ - Events: []string{"test-event2"}, + Events: []executorsv1.EventType{"test-event2"}, }, Status: executorsv1.WebhookStatus{}, }, @@ -40,7 +40,7 @@ func TestWebhooks(t *testing.T) { Namespace: "test-ns", }, Spec: executorsv1.WebhookSpec{ - Events: []string{"test-event1"}, + Events: []executorsv1.EventType{"test-event1"}, }, Status: executorsv1.WebhookStatus{}, }, @@ -84,7 +84,7 @@ func TestWebhooks(t *testing.T) { Namespace: "wrong-ns", }, Spec: executorsv1.WebhookSpec{ - Events: []string{"test-event"}, + Events: []executorsv1.EventType{"test-event"}, }, Status: executorsv1.WebhookStatus{}, } diff --git a/config/crd/bases/executor.testkube.io_executors.yaml b/config/crd/bases/executor.testkube.io_executors.yaml index 7db92560..37e9fabe 100644 --- a/config/crd/bases/executor.testkube.io_executors.yaml +++ b/config/crd/bases/executor.testkube.io_executors.yaml @@ -62,6 +62,9 @@ spec: description: ExecutorType one of "rest" for rest openapi based executors or "job" which will be default runners for testkube or "container" for container executors + enum: + - job + - container type: string features: description: Features list of possible features which executor handles diff --git a/config/crd/bases/executor.testkube.io_webhooks.yaml b/config/crd/bases/executor.testkube.io_webhooks.yaml index d0c47d9a..4166b997 100644 --- a/config/crd/bases/executor.testkube.io_webhooks.yaml +++ b/config/crd/bases/executor.testkube.io_webhooks.yaml @@ -39,6 +39,17 @@ spec: description: Events declare list if events on which webhook should be called items: + enum: + - start-test + - end-test-success + - end-test-failed + - end-test-aborted + - end-test-timeout + - start-testsuite + - end-testsuite-success + - end-testsuite-failed + - end-testsuite-aborted + - end-testsuite-timeout type: string type: array payloadObjectField: diff --git a/config/crd/bases/tests.testkube.io_tests.yaml b/config/crd/bases/tests.testkube.io_tests.yaml index 9dd86e27..7966021e 100644 --- a/config/crd/bases/tests.testkube.io_tests.yaml +++ b/config/crd/bases/tests.testkube.io_tests.yaml @@ -359,6 +359,12 @@ spec: repository: description: repository of test content properties: + authType: + description: auth type for git requests + enum: + - basic + - header + type: string branch: description: branch/tag name for checkout type: string @@ -419,6 +425,12 @@ spec: type: object type: description: test type + enum: + - string + - file-uri + - git-file + - git-dir + - git type: string uri: description: uri of test content @@ -562,7 +574,8 @@ spec: set) type: string negativeTest: - description: negative test will fail the execution if it is a success and it will succeed if it is a failure + description: negative test will fail the execution if it is a + success and it will succeed if it is a failure type: boolean number: description: test execution number @@ -737,6 +750,13 @@ spec: format: date-time type: string status: + enum: + - queued + - running + - passed + - failed + - aborted + - timeout type: string type: object type: object diff --git a/config/crd/bases/tests.testkube.io_testsources.yaml b/config/crd/bases/tests.testkube.io_testsources.yaml index 4c9fae68..378a50f2 100644 --- a/config/crd/bases/tests.testkube.io_testsources.yaml +++ b/config/crd/bases/tests.testkube.io_testsources.yaml @@ -41,9 +41,18 @@ spec: repository: description: repository of test content properties: + authType: + description: auth type for git requests + enum: + - basic + - header + type: string branch: description: branch/tag name for checkout type: string + certificateSecret: + description: git auth certificate secret for private repositories + type: string commit: description: commit id (sha) for checkout type: string @@ -95,14 +104,17 @@ spec: description: if provided we checkout the whole repository and run test from this directory type: string - certificateSecret: - description: git auth certificate secret for private repositories - type: string required: - type - uri type: object type: + enum: + - string + - file-uri + - git-file + - git-dir + - git type: string uri: description: uri of test content diff --git a/config/crd/bases/tests.testkube.io_testsuites.yaml b/config/crd/bases/tests.testkube.io_testsuites.yaml index b7ce6177..187e2b52 100644 --- a/config/crd/bases/tests.testkube.io_testsuites.yaml +++ b/config/crd/bases/tests.testkube.io_testsuites.yaml @@ -283,6 +283,11 @@ spec: type: boolean type: object type: + description: TestSuiteStepType defines different type of test + suite steps + enum: + - execute + - delay type: string type: object type: array @@ -312,6 +317,11 @@ spec: type: boolean type: object type: + description: TestSuiteStepType defines different type of test + suite steps + enum: + - execute + - delay type: string type: object type: array @@ -482,6 +492,11 @@ spec: type: boolean type: object type: + description: TestSuiteStepType defines different type of test + suite steps + enum: + - execute + - delay type: string type: object type: array @@ -504,6 +519,14 @@ spec: format: date-time type: string status: + enum: + - queued + - running + - passed + - failed + - aborting + - aborted + - timeout type: string type: object type: object diff --git a/config/crd/bases/tests.testkube.io_testtriggers.yaml b/config/crd/bases/tests.testkube.io_testtriggers.yaml index fcf7c593..26ffb39e 100644 --- a/config/crd/bases/tests.testkube.io_testtriggers.yaml +++ b/config/crd/bases/tests.testkube.io_testtriggers.yaml @@ -51,6 +51,8 @@ spec: action: description: Action represents what needs to be executed for selected Execution + enum: + - run type: string conditionSpec: description: What resource conditions should be matched @@ -67,6 +69,10 @@ spec: status: description: TestTriggerConditionStatuses defines condition statuses for test triggers + enum: + - "True" + - "False" + - Unknown type: string type: description: test trigger condition @@ -89,14 +95,34 @@ spec: type: string event: description: On which Event for a Resource should an Action be triggered + enum: + - created + - modified + - deleted + - deployment-scale-update + - deployment-image-update + - deployment-env-update + - deployment-containers-modified type: string execution: description: Execution identifies for which test execution should an Action be executed + enum: + - test + - testsuite type: string resource: description: For which Resource do we monitor Event which triggers an Action on certain conditions + enum: + - pod + - deployment + - statefulset + - daemonset + - service + - ingress + - event + - configmap type: string resourceSelector: description: ResourceSelector identifies which Kubernetes Objects diff --git a/controllers/tests/test_controller.go b/controllers/tests/test_controller.go index 6182322c..3d6f48f7 100644 --- a/controllers/tests/test_controller.go +++ b/controllers/tests/test_controller.go @@ -81,7 +81,7 @@ func (r *TestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl. data, err := json.Marshal(testsv3.ExecutionRequest{ RunningContext: &testsv3.RunningContext{ - Type_: string(testsv3.RunningContextTypeScheduler), + Type_: testsv3.RunningContextTypeScheduler, Context: test.Spec.Schedule, }, }) diff --git a/controllers/testsuite/testsuite_controller.go b/controllers/testsuite/testsuite_controller.go index 92e91665..c05835a8 100644 --- a/controllers/testsuite/testsuite_controller.go +++ b/controllers/testsuite/testsuite_controller.go @@ -81,7 +81,7 @@ func (r *TestSuiteReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( data, err := json.Marshal(testsuitev2.TestSuiteExecutionRequest{ RunningContext: &testsuitev2.RunningContext{ - Type_: string(testsuitev2.RunningContextTypeScheduler), + Type_: testsuitev2.RunningContextTypeScheduler, Context: testSuite.Spec.Schedule, }, }) diff --git a/controllers/testtriggers/testtrigger_validator.go b/controllers/testtriggers/testtrigger_validator.go index 7c0b6689..e147ed15 100644 --- a/controllers/testtriggers/testtrigger_validator.go +++ b/controllers/testtriggers/testtrigger_validator.go @@ -176,24 +176,24 @@ func validateLabelSelector(labelSelector *v1.LabelSelector, fld *field.Path) (em return s.Empty(), nil } -func (v *Validator) validateResource(resource string) *field.Error { - if !utils.In(resource, testtrigger.GetSupportedResources()) { +func (v *Validator) validateResource(resource testtriggerv1.TestTriggerResource) *field.Error { + if !utils.In(string(resource), testtrigger.GetSupportedResources()) { fld := field.NewPath("spec").Child("resource") return field.NotSupported(fld, resource, testtrigger.GetSupportedResources()) } return nil } -func (v *Validator) validateAction(action string) *field.Error { - if !utils.In(action, testtrigger.GetSupportedActions()) { +func (v *Validator) validateAction(action testtriggerv1.TestTriggerAction) *field.Error { + if !utils.In(string(action), testtrigger.GetSupportedActions()) { fld := field.NewPath("spec").Child("action") return field.NotSupported(fld, action, testtrigger.GetSupportedActions()) } return nil } -func (v *Validator) validateExecution(execution string) *field.Error { - if !utils.In(execution, testtrigger.GetSupportedExecutions()) { +func (v *Validator) validateExecution(execution testtriggerv1.TestTriggerExecution) *field.Error { + if !utils.In(string(execution), testtrigger.GetSupportedExecutions()) { fld := field.NewPath("spec").Child("execution") return field.NotSupported(fld, execution, testtrigger.GetSupportedExecutions()) }