Skip to content

Commit

Permalink
feat: webhook config
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <[email protected]>
  • Loading branch information
vsukhin committed Dec 20, 2024
1 parent 6a33aef commit 0fe88b5
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 0 deletions.
44 changes: 44 additions & 0 deletions api/executor/v1/webhook_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,50 @@ type WebhookSpec struct {
// 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"`
// webhook parameter configuration
WebhookConfig map[string]WebhookParameterSchema `json:"webhookConfig,omitempty"`
// webhook template reference
WebhookTemplateRef *WebhookTemplateRef `json:"webhookTemplateRef,omitempty"`
}

// webhook parameter schema
type WebhookParameterSchema struct {
// description for the property
Description string `json:"description,omitempty"`
// whether parameter is required
Required bool `json:"required,omitempty"`
// example value for the parameter
Example string `json:"example,omitempty"`
// default parameter value
Default_ *string `json:"default,omitempty"`
// regular expression to match
Pattern string `json:"pattern,omitempty"`
}

// webhook template reference
type WebhookTemplateRef struct {
// webhook template name to include
Name string `json:"name"`
// webhook config to use in webhook template
Config map[string]WebhookConfigValue `json:"config,omitempty"`
}

// webhook configuration value
type WebhookConfigValue struct {
// public value to use in webhook template
Public *string `json:"public,omitempty"`
// private value stored in secret to use in webhook template
Private *SecretRef `json:"private,omitempty"`
}

// Testkube internal reference for secret storage in Kubernetes secrets
type SecretRef struct {
// object kubernetes namespace
Namespace string `json:"namespace,omitempty"`
// object name
Name string `json:"name"`
// object key
Key string `json:"key"`
}

// +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
Expand Down
94 changes: 94 additions & 0 deletions api/executor/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions config/crd/bases/executor.testkube.io_webhooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,64 @@ spec:
description: Uri is address where webhook should be made (golang template
supported)
type: string
webhookConfig:
additionalProperties:
description: webhook parameter schema
properties:
default:
description: default parameter value
type: string
description:
description: description for the property
type: string
example:
description: example value for the parameter
type: string
pattern:
description: regular expression to match
type: string
required:
description: whether parameter is required
type: boolean
type: object
description: webhook parameter configuration
type: object
webhookTemplateRef:
description: webhook template reference
properties:
config:
additionalProperties:
description: webhook configuration value
properties:
private:
description: private value stored in secret to use in webhook
template
properties:
key:
description: object key
type: string
name:
description: object name
type: string
namespace:
description: object kubernetes namespace
type: string
required:
- key
- name
type: object
public:
description: public value to use in webhook template
type: string
type: object
description: ' webhook config to use in webhook template'
type: object
name:
description: webhook template name to include
type: string
required:
- name
type: object
type: object
status:
description: WebhookStatus defines the observed state of Webhook
Expand Down

0 comments on commit 0fe88b5

Please sign in to comment.