Allow specifying a default namespace used across all the releases (#39)

* Allow specifying a default namespace used across all the releases

Omit `namespace` in `charts[].namespace` of charts.yaml and then run `helmfile sync -n yourns` to install your charts into `yourns`.

Resolves #31
This commit is contained in:
KUOKA Yusuke
2018-03-01 23:09:02 +09:00
committed by GitHub
parent f02790d566
commit efdede1658
2 changed files with 20 additions and 2 deletions
+12
View File
@@ -38,6 +38,10 @@ func main() {
Name: "kube-context",
Usage: "Set kubectl context. Uses current context by default",
},
cli.StringFlag{
Name: "namespace, n",
Usage: "Set namespace. Uses the namespace set in the context by default",
},
}
app.Commands = []cli.Command{
@@ -232,6 +236,7 @@ func before(c *cli.Context) (*state.HelmState, helmexec.Interface, error) {
file := c.GlobalString("file")
quiet := c.GlobalBool("quiet")
kubeContext := c.GlobalString("kube-context")
namespace := c.GlobalString("namespace")
state, err := state.ReadFromFile(file)
if err != nil {
@@ -244,6 +249,13 @@ func before(c *cli.Context) (*state.HelmState, helmexec.Interface, error) {
}
kubeContext = state.Context
}
if namespace != "" {
if state.Namespace != "" {
log.Printf("err: Cannot use option --namespace and set attribute namespace.")
os.Exit(1)
}
state.Namespace = namespace
}
var writer io.Writer
if !quiet {
writer = os.Stdout