Skip to content

Commit 0ef8ad5

Browse files
committed
fix: add enums
1 parent 11cfe5d commit 0ef8ad5

11 files changed

+163
-31
lines changed

apis/executor/v1/webhook_types.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,30 @@ type WebhookSpec struct {
3131
// Uri is address where webhook should be made
3232
Uri string `json:"uri,omitempty"`
3333
// Events declare list if events on which webhook should be called
34-
Events []string `json:"events,omitempty"`
34+
Events []EventType `json:"events,omitempty"`
3535
// Labels to filter for tests and test suites
3636
Selector string `json:"selector,omitempty"`
3737
// will load the generated payload for notification inside the object
3838
PayloadObjectField string `json:"payloadObjectField,omitempty"`
3939
}
4040

41+
// +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
42+
type EventType string
43+
44+
// List of EventType
45+
const (
46+
START_TEST_EventType EventType = "start-test"
47+
END_TEST_SUCCESS_EventType EventType = "end-test-success"
48+
END_TEST_FAILED_EventType EventType = "end-test-failed"
49+
END_TEST_ABORTED_EventType EventType = "end-test-aborted"
50+
END_TEST_TIMEOUT_EventType EventType = "end-test-timeout"
51+
START_TESTSUITE_EventType EventType = "start-testsuite"
52+
END_TESTSUITE_SUCCESS_EventType EventType = "end-testsuite-success"
53+
END_TESTSUITE_FAILED_EventType EventType = "end-testsuite-failed"
54+
END_TESTSUITE_ABORTED_EventType EventType = "end-testsuite-aborted"
55+
END_TESTSUITE_TIMEOUT_EventType EventType = "end-testsuite-timeout"
56+
)
57+
4158
// WebhookStatus defines the observed state of Webhook
4259
type WebhookStatus struct {
4360
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster

apis/executor/v1/zz_generated.deepcopy.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/tests/v3/test_types.go

+39-14
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type Variable commonv1.Variable
5050
// TestContent defines test content
5151
type TestContent struct {
5252
// test type
53-
Type_ string `json:"type,omitempty"`
53+
Type_ TestContentType `json:"type,omitempty"`
5454
// repository of test content
5555
Repository *Repository `json:"repository,omitempty"`
5656
// test content body
@@ -59,6 +59,19 @@ type TestContent struct {
5959
Uri string `json:"uri,omitempty"`
6060
}
6161

62+
// +kubebuilder:validation:Enum=string;file-uri;git-file;git-dir;git
63+
type TestContentType string
64+
65+
const (
66+
TestContentTypeString TestContentType = "string"
67+
TestContentTypeFileURI TestContentType = "file-uri"
68+
// Deprecated: use git instead
69+
TestContentTypeGitFile TestContentType = "git-file"
70+
// Deprecated: use git instead
71+
TestContentTypeGitDir TestContentType = "git-dir"
72+
TestContentTypeGit TestContentType = "git"
73+
)
74+
6275
// Testkube internal reference for secret storage in Kubernetes secrets
6376
type SecretRef struct {
6477
// object kubernetes namespace
@@ -88,9 +101,20 @@ type Repository struct {
88101
// if provided we checkout the whole repository and run test from this directory
89102
WorkingDir string `json:"workingDir,omitempty"`
90103
// auth type for git requests
91-
AuthType string `json:"authType,omitempty"`
104+
AuthType GitAuthType `json:"authType,omitempty"`
92105
}
93106

107+
// GitAuthType defines git auth type
108+
// +kubebuilder:validation:Enum=basic;header
109+
type GitAuthType string
110+
111+
const (
112+
// GitAuthTypeBasic for git basic auth requests
113+
GitAuthTypeBasic GitAuthType = "basic"
114+
// GitAuthTypeHeader for git header auth requests
115+
GitAuthTypeHeader GitAuthType = "header"
116+
)
117+
94118
// artifact request body for container executors with test artifacts
95119
type ArtifactRequest struct {
96120
// artifact storage class name
@@ -104,11 +128,22 @@ type ArtifactRequest struct {
104128
// running context for test or test suite execution
105129
type RunningContext struct {
106130
// One of possible context types
107-
Type_ string `json:"type"`
131+
Type_ RunningContextType `json:"type"`
108132
// Context value depending from its type
109133
Context string `json:"context,omitempty"`
110134
}
111135

136+
type RunningContextType string
137+
138+
const (
139+
RunningContextTypeUserCLI RunningContextType = "user-cli"
140+
RunningContextTypeUserUI RunningContextType = "user-ui"
141+
RunningContextTypeTestSuite RunningContextType = "testsuite"
142+
RunningContextTypeTestTrigger RunningContextType = "testtrigger"
143+
RunningContextTypeScheduler RunningContextType = "scheduler"
144+
RunningContextTypeEmpty RunningContextType = ""
145+
)
146+
112147
// test execution request body
113148
type ExecutionRequest struct {
114149
// test execution custom name
@@ -168,17 +203,6 @@ type ExecutionRequest struct {
168203
RunningContext *RunningContext `json:"runningContext,omitempty"`
169204
}
170205

171-
type RunningContextType string
172-
173-
const (
174-
RunningContextTypeUserCLI RunningContextType = "user-cli"
175-
RunningContextTypeUserUI RunningContextType = "user-ui"
176-
RunningContextTypeTestSuite RunningContextType = "testsuite"
177-
RunningContextTypeTestTrigger RunningContextType = "testtrigger"
178-
RunningContextTypeScheduler RunningContextType = "scheduler"
179-
RunningContextTypeEmpty RunningContextType = ""
180-
)
181-
182206
// Reference to env resource
183207
type EnvReference struct {
184208
v1.LocalObjectReference `json:"reference"`
@@ -190,6 +214,7 @@ type EnvReference struct {
190214
MapToVariables bool `json:"mapToVariables,omitempty"`
191215
}
192216

217+
// +kubebuilder:validation:Enum=queued;running;passed;failed;aborted;timeout
193218
type ExecutionStatus string
194219

195220
// List of ExecutionStatus

apis/testsource/v1/testsource_types.go

+26-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type TestSourceSpec struct {
2828
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
2929
// Important: Run "make" to regenerate code after modifying this file
3030

31-
Type_ string `json:"type,omitempty"`
31+
Type_ TestSourceType `json:"type,omitempty"`
3232
// repository of test content
3333
Repository *Repository `json:"repository,omitempty"`
3434
// test content body
@@ -37,6 +37,19 @@ type TestSourceSpec struct {
3737
Uri string `json:"uri,omitempty"`
3838
}
3939

40+
// +kubebuilder:validation:Enum=string;file-uri;git-file;git-dir;git
41+
type TestSourceType string
42+
43+
const (
44+
TestSourceTypeString TestSourceType = "string"
45+
TestSourceTypeFileURI TestSourceType = "file-uri"
46+
// Deprecated: use git instead
47+
TestSourceTypeGitFile TestSourceType = "git-file"
48+
// Deprecated: use git instead
49+
TestSourceTypeGitDir TestSourceType = "git-dir"
50+
TestSourceTypeGit TestSourceType = "git"
51+
)
52+
4053
// Testkube internal reference for secret storage in Kubernetes secrets
4154
type SecretRef struct {
4255
// object kubernetes namespace
@@ -66,9 +79,20 @@ type Repository struct {
6679
// if provided we checkout the whole repository and run test from this directory
6780
WorkingDir string `json:"workingDir,omitempty"`
6881
// auth type for git requests
69-
AuthType string `json:"authType,omitempty"`
82+
AuthType GitAuthType `json:"authType,omitempty"`
7083
}
7184

85+
// GitAuthType defines git auth type
86+
// +kubebuilder:validation:Enum=basic;header
87+
type GitAuthType string
88+
89+
const (
90+
// GitAuthTypeBasic for git basic auth requests
91+
GitAuthTypeBasic GitAuthType = "basic"
92+
// GitAuthTypeHeader for git header auth requests
93+
GitAuthTypeHeader GitAuthType = "header"
94+
)
95+
7296
// TestSourceStatus defines the observed state of TestSource
7397
type TestSourceStatus struct {
7498
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster

apis/testsuite/v2/testsuite_types.go

+15-13
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ type Variable commonv1.Variable
4747

4848
// TestSuiteStepSpec for particular type will have config for possible step types
4949
type TestSuiteStepSpec struct {
50-
Type string `json:"type,omitempty"`
50+
Type TestSuiteStepType `json:"type,omitempty"`
5151
Execute *TestSuiteStepExecute `json:"execute,omitempty"`
5252
Delay *TestSuiteStepDelay `json:"delay,omitempty"`
5353
}
5454

5555
// TestSuiteStepType deines different type of test suite steps
56+
// +kubebuilder:validation:Enum=execute;delay
5657
type TestSuiteStepType string
5758

5859
const (
@@ -76,11 +77,22 @@ type TestSuiteStepDelay struct {
7677
// running context for test or test suite execution
7778
type RunningContext struct {
7879
// One of possible context types
79-
Type_ string `json:"type"`
80+
Type_ RunningContextType `json:"type"`
8081
// Context value depending from its type
8182
Context string `json:"context,omitempty"`
8283
}
8384

85+
type RunningContextType string
86+
87+
const (
88+
RunningContextTypeUserCLI RunningContextType = "user-cli"
89+
RunningContextTypeUserUI RunningContextType = "user-ui"
90+
RunningContextTypeTestSuite RunningContextType = "testsuite"
91+
RunningContextTypeTestTrigger RunningContextType = "testtrigger"
92+
RunningContextTypeScheduler RunningContextType = "scheduler"
93+
RunningContextTypeEmpty RunningContextType = ""
94+
)
95+
8496
// test suite execution request body
8597
type TestSuiteExecutionRequest struct {
8698
// test execution custom name
@@ -105,17 +117,7 @@ type TestSuiteExecutionRequest struct {
105117
RunningContext *RunningContext `json:"runningContext,omitempty"`
106118
}
107119

108-
type RunningContextType string
109-
110-
const (
111-
RunningContextTypeUserCLI RunningContextType = "user-cli"
112-
RunningContextTypeUserUI RunningContextType = "user-ui"
113-
RunningContextTypeTestSuite RunningContextType = "testsuite"
114-
RunningContextTypeTestTrigger RunningContextType = "testtrigger"
115-
RunningContextTypeScheduler RunningContextType = "scheduler"
116-
RunningContextTypeEmpty RunningContextType = ""
117-
)
118-
120+
// +kubebuilder:validation:Enum=queued;running;passed;failed;aborting;aborted;timeout
119121
type TestSuiteExecutionStatus string
120122

121123
// List of TestSuiteExecutionStatus

apis/testtriggers/v1/testtrigger_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ type TestTriggerStatus struct {
7878
}
7979

8080
// TestTriggerConditionStatuses defines condition statuses for test triggers
81+
// +kubebuilder:validation:Enum=True;False;Unknown
8182
type TestTriggerConditionStatuses string
8283

8384
// List of TestTriggerConditionStatuses

config/crd/bases/executor.testkube.io_webhooks.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ spec:
3939
description: Events declare list if events on which webhook should
4040
be called
4141
items:
42+
enum:
43+
- start-test
44+
- end-test-success
45+
- end-test-failed
46+
- end-test-aborted
47+
- end-test-timeout
48+
- start-testsuite
49+
- end-testsuite-success
50+
- end-testsuite-failed
51+
- end-testsuite-aborted
52+
- end-testsuite-timeout
4253
type: string
4354
type: array
4455
payloadObjectField:

config/crd/bases/tests.testkube.io_tests.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ spec:
361361
properties:
362362
authType:
363363
description: auth type for git requests
364+
enum:
365+
- basic
366+
- header
364367
type: string
365368
branch:
366369
description: branch/tag name for checkout
@@ -422,6 +425,12 @@ spec:
422425
type: object
423426
type:
424427
description: test type
428+
enum:
429+
- string
430+
- file-uri
431+
- git-file
432+
- git-dir
433+
- git
425434
type: string
426435
uri:
427436
description: uri of test content
@@ -741,6 +750,13 @@ spec:
741750
format: date-time
742751
type: string
743752
status:
753+
enum:
754+
- queued
755+
- running
756+
- passed
757+
- failed
758+
- aborted
759+
- timeout
744760
type: string
745761
type: object
746762
type: object

config/crd/bases/tests.testkube.io_testsources.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ spec:
4343
properties:
4444
authType:
4545
description: auth type for git requests
46+
enum:
47+
- basic
48+
- header
4649
type: string
4750
branch:
4851
description: branch/tag name for checkout
@@ -106,6 +109,12 @@ spec:
106109
- uri
107110
type: object
108111
type:
112+
enum:
113+
- string
114+
- file-uri
115+
- git-file
116+
- git-dir
117+
- git
109118
type: string
110119
uri:
111120
description: uri of test content

config/crd/bases/tests.testkube.io_testsuites.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ spec:
283283
type: boolean
284284
type: object
285285
type:
286+
description: TestSuiteStepType deines different type of test
287+
suite steps
288+
enum:
289+
- execute
290+
- delay
286291
type: string
287292
type: object
288293
type: array
@@ -312,6 +317,11 @@ spec:
312317
type: boolean
313318
type: object
314319
type:
320+
description: TestSuiteStepType deines different type of test
321+
suite steps
322+
enum:
323+
- execute
324+
- delay
315325
type: string
316326
type: object
317327
type: array
@@ -482,6 +492,11 @@ spec:
482492
type: boolean
483493
type: object
484494
type:
495+
description: TestSuiteStepType deines different type of test
496+
suite steps
497+
enum:
498+
- execute
499+
- delay
485500
type: string
486501
type: object
487502
type: array
@@ -504,6 +519,14 @@ spec:
504519
format: date-time
505520
type: string
506521
status:
522+
enum:
523+
- queued
524+
- running
525+
- passed
526+
- failed
527+
- aborting
528+
- aborted
529+
- timeout
507530
type: string
508531
type: object
509532
type: object

config/crd/bases/tests.testkube.io_testtriggers.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ spec:
6767
status:
6868
description: TestTriggerConditionStatuses defines condition
6969
statuses for test triggers
70+
enum:
71+
- "True"
72+
- "False"
73+
- Unknown
7074
type: string
7175
type:
7276
description: test trigger condition

0 commit comments

Comments
 (0)