Merge pull request #123 from fluxcd/optional-notifications

Make notification component optional
pull/124/head
Stefan Prodan 5 years ago committed by GitHub
commit 2c2fc6dd97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -118,6 +118,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
} else if installExport { } else if installExport {
fmt.Println("---") fmt.Println("---")
fmt.Println("# GitOps Toolkit revision", installVersion, time.Now().Format(time.RFC3339)) fmt.Println("# GitOps Toolkit revision", installVersion, time.Now().Format(time.RFC3339))
fmt.Println("# Components:", strings.Join(installComponents, ","))
fmt.Print(yaml) fmt.Print(yaml)
fmt.Println("---") fmt.Println("---")
return nil return nil
@ -183,7 +184,7 @@ fieldSpecs:
` `
var kustomizationTmpl = `--- var kustomizationTmpl = `---
{{- $version := .Version }} {{- $eventsAddr := .EventsAddr }}
apiVersion: kustomize.config.k8s.io/v1beta1 apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
namespace: {{.Namespace}} namespace: {{.Namespace}}
@ -196,6 +197,21 @@ resources:
{{- range .Components }} {{- range .Components }}
- {{.}}.yaml - {{.}}.yaml
{{- end }} {{- end }}
patchesJson6902:
{{- range $i, $v := .Components }}
{{- if ne $v "notification-controller" }}
- target:
group: apps
version: v1
kind: Deployment
name: {{$v}}
patch: |-
- op: replace
path: /spec/template/spec/containers/0/args/0
value: --events-addr={{$eventsAddr}}
{{- end }}
{{- end }}
` `
var kustomizationRolesTmpl = `--- var kustomizationRolesTmpl = `---
@ -241,14 +257,21 @@ func downloadManifests(version string, tmpDir string) error {
} }
func genInstallManifests(version string, namespace string, components []string, tmpDir string) error { func genInstallManifests(version string, namespace string, components []string, tmpDir string) error {
eventsAddr := ""
if utils.containsItemString(components, defaultNotification) {
eventsAddr = fmt.Sprintf("http://%s/", defaultNotification)
}
model := struct { model := struct {
Version string Version string
Namespace string Namespace string
Components []string Components []string
EventsAddr string
}{ }{
Version: version, Version: version,
Namespace: namespace, Namespace: namespace,
Components: components, Components: components,
EventsAddr: eventsAddr,
} }
if err := downloadManifests(version, tmpDir); err != nil { if err := downloadManifests(version, tmpDir); err != nil {

@ -107,6 +107,7 @@ var (
defaultComponents = []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"} defaultComponents = []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"}
defaultVersion = "latest" defaultVersion = "latest"
defaultNamespace = "gitops-system" defaultNamespace = "gitops-system"
defaultNotification = "notification-controller"
) )
func init() { func init() {

@ -166,3 +166,12 @@ func (*Utils) copyFile(src, dst string) error {
} }
return out.Close() return out.Close()
} }
func (*Utils) containsItemString(s []string, e string) bool {
for _, a := range s {
if a == e {
return true
}
}
return false
}

Loading…
Cancel
Save