Skip to content

Commit

Permalink
Merge pull request #101 from PTC-Global/no_ns
Browse files Browse the repository at this point in the history
adding flag to disable namespace creation
  • Loading branch information
Sami Alajrami authored Oct 27, 2018
2 parents c3e57ae + 5ca4121 commit 3ccd340
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
5 changes: 5 additions & 0 deletions helm_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
29 changes: 17 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3ccd340

Please sign in to comment.