Skip to content

Commit

Permalink
as suggested changing cluster-name to flag
Browse files Browse the repository at this point in the history
  • Loading branch information
baldey-nz committed Dec 18, 2021
1 parent c638edd commit 707e7ba
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
3 changes: 0 additions & 3 deletions artifacts/flagger/crd.yaml
Expand Up @@ -79,9 +79,6 @@ spec:
- service
- analysis
properties:
summary:
description: Optional msg to add to each notification
type: string
provider:
description: Traffic managent provider
type: string
Expand Down
3 changes: 3 additions & 0 deletions cmd/flagger/main.go
Expand Up @@ -83,6 +83,7 @@ var (
enableConfigTracking bool
ver bool
kubeconfigServiceMesh string
clusterName string
)

func init() {
Expand Down Expand Up @@ -115,6 +116,7 @@ func init() {
flag.BoolVar(&enableConfigTracking, "enable-config-tracking", true, "Enable secrets and configmaps tracking.")
flag.BoolVar(&ver, "version", false, "Print version")
flag.StringVar(&kubeconfigServiceMesh, "kubeconfig-service-mesh", "", "Path to a kubeconfig for the service mesh control plane cluster.")
flag.StringVar(&clusterName, "cluster-name", "", "Cluster name to be included in alert msgs.")
}

func main() {
Expand Down Expand Up @@ -238,6 +240,7 @@ func main() {
meshProvider,
version.VERSION,
fromEnv("EVENT_WEBHOOK_URL", eventWebhook),
clusterName,
)

// leader election context
Expand Down
4 changes: 0 additions & 4 deletions pkg/apis/flagger/v1beta1/canary.go
Expand Up @@ -103,10 +103,6 @@ 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
3 changes: 3 additions & 0 deletions pkg/controller/controller.go
Expand Up @@ -66,6 +66,7 @@ type Controller struct {
observerFactory *observers.Factory
meshProvider string
eventWebhook string
clusterName string
}

type Informers struct {
Expand All @@ -87,6 +88,7 @@ func NewController(
meshProvider string,
version string,
eventWebhook string,
clusterName string,
) *Controller {
logger.Debug("Creating event broadcaster")
flaggerscheme.AddToScheme(scheme.Scheme)
Expand Down Expand Up @@ -118,6 +120,7 @@ func NewController(
routerFactory: routerFactory,
meshProvider: meshProvider,
eventWebhook: eventWebhook,
clusterName: clusterName,
}

flaggerInformers.CanaryInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller/events.go
Expand Up @@ -74,7 +74,7 @@ func (c *Controller) sendEventToWebhook(r *flaggerv1.Canary, eventType, template
func (c *Controller) alert(canary *flaggerv1.Canary, message string, metadata bool, severity flaggerv1.AlertSeverity) {
var fields []notifier.Field
if metadata {
fields = alertMetadata(canary)
fields = alertMetadata(canary, c.clusterName)
}

// send alert with the global notifier
Expand Down Expand Up @@ -173,14 +173,14 @@ func (c *Controller) alert(canary *flaggerv1.Canary, message string, metadata bo
}
}

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

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

0 comments on commit 707e7ba

Please sign in to comment.