diff --git a/helm_helpers.go b/helm_helpers.go index fdebd7aa..173ff182 100644 --- a/helm_helpers.go +++ b/helm_helpers.go @@ -88,6 +88,11 @@ func getTillerReleases(tillerNS string) tillerReleases { exitCode, result := cmd.exec(debug, verbose) if exitCode != 0 { + if !apply { + log.Println("INFO: " + strings.Replace(result, "Error: ", "", 1)) + return tillerReleases{} + } + logError("ERROR: failed to list all releases in namespace [ " + tillerNS + " ]: " + result) } var out tillerReleases diff --git a/init.go b/init.go index 483de17a..daf2bad3 100644 --- a/init.go +++ b/init.go @@ -49,6 +49,7 @@ func init() { flag.BoolVar(&noBanner, "no-banner", false, "don't show the banner") flag.BoolVar(&noColors, "no-color", false, "don't use colors") flag.BoolVar(&noFancy, "no-fancy", false, "don't display the banner and don't use colors") + flag.BoolVar(&noNs, "no-ns", false, "don't create namespaces") flag.StringVar(&nsOverride, "ns-override", "", "override defined namespaces with this one") flag.BoolVar(&skipValidation, "skip-validation", false, "skip desired state validation") flag.BoolVar(&applyLabels, "apply-labels", false, "apply Helmsman labels to Helm state for all defined apps.") diff --git a/main.go b/main.go index 81b59c32..fb573fed 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,7 @@ var verbose bool var noBanner bool var noColors bool var noFancy bool +var noNs bool var nsOverride string var checkCleanup bool var skipValidation bool @@ -48,22 +49,26 @@ func main() { checkCleanup = true } - // add/validate namespaces - addNamespaces(s.Namespaces) + if apply { + // add/validate namespaces + if !noNs { + addNamespaces(s.Namespaces) + } - if r, msg := initHelm(); !r { - logError(msg) - } + if r, msg := initHelm(); !r { + logError(msg) + } - // check if helm Tiller is ready - for k, ns := range s.Namespaces { - if ns.InstallTiller || ns.UseTiller { - waitForTiller(k) + // check if helm Tiller is ready + for k, ns := range s.Namespaces { + if ns.InstallTiller || ns.UseTiller { + waitForTiller(k) + } } - } - if _, ok := s.Namespaces["kube-system"]; !ok { - waitForTiller("kube-system") + if _, ok := s.Namespaces["kube-system"]; !ok { + waitForTiller("kube-system") + } } // add repos -- fails if they are not valid