From e0fc5ecb39f0304a2fc8114c4421dcc024307297 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Sat, 13 Apr 2019 15:37:41 +0300 Subject: [PATCH] Add hook type to CRD - pre-rollout execute webhook before routing traffic to canary - rollout execute webhook during the canary analysis on each iteration - post-rollout execute webhook after the canary has been promoted or rolled back Add canary phase to webhook payload --- pkg/apis/flagger/v1alpha3/types.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/apis/flagger/v1alpha3/types.go b/pkg/apis/flagger/v1alpha3/types.go index 92bc55164..4b0b9d129 100755 --- a/pkg/apis/flagger/v1alpha3/types.go +++ b/pkg/apis/flagger/v1alpha3/types.go @@ -148,11 +148,24 @@ type CanaryMetric struct { Query string `json:"query,omitempty"` } +// HookType can be pre, post or during rollout +type HookType string + +const ( + // RolloutHook execute webhook during the canary analysis + RolloutHook HookType = "rollout" + // PreRolloutHook execute webhook before routing traffic to canary + PreRolloutHook HookType = "pre-rollout" + // PreRolloutHook execute webhook after the canary analysis + PostRolloutHook HookType = "post-rollout" +) + // CanaryWebhook holds the reference to external checks used for canary analysis type CanaryWebhook struct { - Name string `json:"name"` - URL string `json:"url"` - Timeout string `json:"timeout"` + Type HookType `json:"type"` + Name string `json:"name"` + URL string `json:"url"` + Timeout string `json:"timeout"` // +optional Metadata *map[string]string `json:"metadata,omitempty"` } @@ -161,6 +174,7 @@ type CanaryWebhook struct { type CanaryWebhookPayload struct { Name string `json:"name"` Namespace string `json:"namespace"` + Phase CanaryPhase `json:"phase"` Metadata map[string]string `json:"metadata,omitempty"` }