diff --git a/charts/flagger/templates/deployment.yaml b/charts/flagger/templates/deployment.yaml index 34fb70750..73a1ebb1c 100644 --- a/charts/flagger/templates/deployment.yaml +++ b/charts/flagger/templates/deployment.yaml @@ -102,6 +102,10 @@ spec: - --spider - http://localhost:8080/healthz timeoutSeconds: 5 + {{- if .Values.env }} + env: +{{ toYaml .Values.env | indent 12 }} + {{- end }} resources: {{ toYaml .Values.resources | indent 12 }} {{- with .Values.nodeSelector }} diff --git a/charts/flagger/values.yaml b/charts/flagger/values.yaml index c13f37e69..9128fbb25 100644 --- a/charts/flagger/values.yaml +++ b/charts/flagger/values.yaml @@ -32,6 +32,19 @@ msteams: # MS Teams incoming webhook URL url: +#env: +#- name: SLACK_URL +# valueFrom: +# secretKeyRef: +# name: slack +# key: url +#- name: MSTEAMS_URL +# valueFrom: +# secretKeyRef: +# name: msteams +# key: url +env: [] + leaderElection: enabled: false replicaCount: 1 diff --git a/cmd/flagger/main.go b/cmd/flagger/main.go index 5556a940a..529c9b32a 100644 --- a/cmd/flagger/main.go +++ b/cmd/flagger/main.go @@ -286,10 +286,10 @@ func startLeaderElection(ctx context.Context, run func(), ns string, kubeClient func initNotifier(logger *zap.SugaredLogger) (client notifier.Interface) { provider := "slack" - notifierURL := slackURL - if msteamsURL != "" { + notifierURL := fromEnv("SLACK_URL", slackURL) + if msteamsURL != "" || os.Getenv("MSTEAMS_URL") != "" { provider = "msteams" - notifierURL = msteamsURL + notifierURL = fromEnv("MSTEAMS_URL", msteamsURL) } notifierFactory := notifier.NewFactory(notifierURL, slackUser, slackChannel) @@ -304,3 +304,10 @@ func initNotifier(logger *zap.SugaredLogger) (client notifier.Interface) { } return } + +func fromEnv(envVar string, defaultVal string) string { + if os.Getenv(envVar) != "" { + return os.Getenv(envVar) + } + return defaultVal +}