Skip to content

Commit

Permalink
fix: deprecate on state change (#285)
Browse files Browse the repository at this point in the history
* fix: deprecate on state change

Signed-off-by: Vladislav Sukhin <[email protected]>

* fix: add new events

Signed-off-by: Vladislav Sukhin <[email protected]>

---------

Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin authored Jul 19, 2024
1 parent a1fa1f1 commit d677ef7
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 19 deletions.
47 changes: 31 additions & 16 deletions api/executor/v1/webhook_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,44 @@ type WebhookSpec struct {
// Disabled will disable the webhook
Disabled bool `json:"disabled,omitempty"`
// OnStateChange will trigger the webhook only when the result of the current execution differs from the previous result of the same test/test suite/workflow
// Deprecated: field is not used
OnStateChange bool `json:"onStateChange,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;start-testworkflow;queue-testworkflow;end-testworkflow-success;end-testworkflow-failed;end-testworkflow-aborted
// +kubebuilder:validation:Enum=start-test;end-test-success;end-test-failed;end-test-aborted;end-test-timeout;become-test-up;become-test-down;become-test-failed;become-test-aborted;become-test-timeout;start-testsuite;end-testsuite-success;end-testsuite-failed;end-testsuite-aborted;end-testsuite-timeout;become-testsuite-up;become-testsuite-down;become-testsuite-failed;become-testsuite-aborted;become-testsuite-timeout;start-testworkflow;queue-testworkflow;end-testworkflow-success;end-testworkflow-failed;end-testworkflow-aborted;become-testworkflow-up;become-testworkflow-down;become-testworkflow-failed;become-testworkflow-aborted
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"
START_TESTWORKFLOW_EventType EventType = "start-testworkflow"
QUEUE_TESTWORKFLOW_EventType EventType = "queue-testworkflow"
END_TESTWORKFLOW_SUCCESS_EventType EventType = "end-testworkflow-success"
END_TESTWORKFLOW_FAILED_EventType EventType = "end-testworkflow-failed"
END_TESTWORKFLOW_ABORTED_EventType EventType = "end-testworkflow-aborted"
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"
BECOME_TEST_UP_EventType EventType = "become-test-up"
BECOME_TEST_DOWN_EventType EventType = "become-test-down"
BECOME_TEST_FAILED_EventType EventType = "become-test-failed"
BECOME_TEST_ABORTED_EventType EventType = "become-test-aborted"
BECOME_TEST_TIMEOUT_EventType EventType = "become-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"
BECOME_TESTSUITE_UP_EventType EventType = "become-testsuite-up"
BECOME_TESTSUITE_DOWN_EventType EventType = "become-testsuite-down"
BECOME_TESTSUITE_FAILED_EventType EventType = "become-testsuite-failed"
BECOME_TESTSUITE_ABORTED_EventType EventType = "become-testsuite-aborted"
BECOME_TESTSUITE_TIMEOUT_EventType EventType = "become-testsuite-timeout"
START_TESTWORKFLOW_EventType EventType = "start-testworkflow"
QUEUE_TESTWORKFLOW_EventType EventType = "queue-testworkflow"
END_TESTWORKFLOW_SUCCESS_EventType EventType = "end-testworkflow-success"
END_TESTWORKFLOW_FAILED_EventType EventType = "end-testworkflow-failed"
END_TESTWORKFLOW_ABORTED_EventType EventType = "end-testworkflow-aborted"
BECOME_TESTWORKFLOW_UP_EventType EventType = "become-testworkflow-up"
BECOME_TESTWORKFLOW_DOWN_EventType EventType = "become-testworkflow-down"
BECOME_TESTWORKFLOW_FAILED_EventType EventType = "become-testworkflow-failed"
BECOME_TESTWORKFLOW_ABORTED_EventType EventType = "become-testworkflow-aborted"
)

// WebhookStatus defines the observed state of Webhook
Expand Down
20 changes: 17 additions & 3 deletions config/crd/bases/executor.testkube.io_webhooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,30 @@ spec:
- end-test-failed
- end-test-aborted
- end-test-timeout
- become-test-up
- become-test-down
- become-test-failed
- become-test-aborted
- become-test-timeout
- start-testsuite
- end-testsuite-success
- end-testsuite-failed
- end-testsuite-aborted
- end-testsuite-timeout
- become-testsuite-up
- become-testsuite-down
- become-testsuite-failed
- become-testsuite-aborted
- become-testsuite-timeout
- start-testworkflow
- queue-testworkflow
- end-testworkflow-success
- end-testworkflow-failed
- end-testworkflow-aborted
- become-testworkflow-up
- become-testworkflow-down
- become-testworkflow-failed
- become-testworkflow-aborted
type: string
type: array
headers:
Expand All @@ -70,9 +84,9 @@ spec:
description: webhook headers (golang template supported)
type: object
onStateChange:
description: OnStateChange will trigger the webhook only when the
result of the current execution differs from the previous result
of the same test/test suite/workflow
description: |-
OnStateChange will trigger the webhook only when the result of the current execution differs from the previous result of the same test/test suite/workflow
Deprecated: field is not used
type: boolean
payloadObjectField:
description: will load the generated payload for notification inside
Expand Down

0 comments on commit d677ef7

Please sign in to comment.