From d677ef7c3437cfee9c07607f45a5f6775266283d Mon Sep 17 00:00:00 2001 From: Vladislav Sukhin Date: Fri, 19 Jul 2024 15:26:53 +0400 Subject: [PATCH] fix: deprecate on state change (#285) * fix: deprecate on state change Signed-off-by: Vladislav Sukhin * fix: add new events Signed-off-by: Vladislav Sukhin --------- Signed-off-by: Vladislav Sukhin --- api/executor/v1/webhook_types.go | 47 ++++++++++++------- .../bases/executor.testkube.io_webhooks.yaml | 20 ++++++-- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/api/executor/v1/webhook_types.go b/api/executor/v1/webhook_types.go index 0c697bcc..70613e09 100644 --- a/api/executor/v1/webhook_types.go +++ b/api/executor/v1/webhook_types.go @@ -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 diff --git a/config/crd/bases/executor.testkube.io_webhooks.yaml b/config/crd/bases/executor.testkube.io_webhooks.yaml index 462e5d5e..b5803d26 100644 --- a/config/crd/bases/executor.testkube.io_webhooks.yaml +++ b/config/crd/bases/executor.testkube.io_webhooks.yaml @@ -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: @@ -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