Skip to content

Commit

Permalink
If applied, this commit will add optional canary spec fields, summary…
Browse files Browse the repository at this point in the history
… and cluster, for notification purposes

Signed-off-by: baldey-nz <baldey@gmail.com>
  • Loading branch information
baldey-nz committed Oct 26, 2021
1 parent 01d4780 commit 7189eb5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions artifacts/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ spec:
- service
- analysis
properties:
summary:
description: Optional msg to add to each notification
type: string
provider:
description: Traffic managent provider
type: string
Expand All @@ -103,6 +106,9 @@ spec:
- Service
name:
type: string
cluster:
description: Optional msg to add to Target notification line
type: string
autoscalerRef:
description: HPA selector
type: object
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/flagger/v1beta1/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ type CanarySpec struct {
// revert canary mutation on deletion of canary resource
// +optional
RevertOnDeletion bool `json:"revertOnDeletion,omitempty"`

// Summary creates new notification message
// +optional
Summary string `json:"summary,omitempty"`
}

// CanaryService defines how ClusterIP services, service mesh or ingress routing objects are generated
Expand Down Expand Up @@ -377,6 +381,10 @@ type CrossNamespaceObjectReference struct {
// Namespace of the referent
// +optional
Namespace string `json:"namespace,omitempty"`

// Cluster name will append to Target notification msg
// +optional
Cluster string `json:"cluster,omitempty"`
}

// CustomMetadata holds labels and annotations to set on generated objects.
Expand Down
12 changes: 11 additions & 1 deletion pkg/controller/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,20 @@ func (c *Controller) alert(canary *flaggerv1.Canary, message string, metadata bo

func alertMetadata(canary *flaggerv1.Canary) []notifier.Field {
var fields []notifier.Field

if canary.Spec.Summary != "" {
fields = append(fields,
notifier.Field{
Name: "Summary",
Value: canary.Spec.Summary,
},
)
}

fields = append(fields,
notifier.Field{
Name: "Target",
Value: fmt.Sprintf("%s/%s.%s", canary.Spec.TargetRef.Kind, canary.Spec.TargetRef.Name, canary.Namespace),
Value: fmt.Sprintf("%s/%s.%s %s", canary.Spec.TargetRef.Kind, canary.Spec.TargetRef.Name, canary.Namespace, canary.Spec.TargetRef.Cluster),
},
notifier.Field{
Name: "Failed checks threshold",
Expand Down

0 comments on commit 7189eb5

Please sign in to comment.