Commit 313a9dc4 authored by Adam Reese's avatar Adam Reese Committed by GitHub

Merge pull request #1400 from adamreese/fix/1396-kubeconfig-namespace

fix(helm): respect kubeconfig default namespace
parents 1ea977b5 e93d5b90
...@@ -35,6 +35,7 @@ import ( ...@@ -35,6 +35,7 @@ import (
"k8s.io/helm/cmd/helm/downloader" "k8s.io/helm/cmd/helm/downloader"
"k8s.io/helm/cmd/helm/helmpath" "k8s.io/helm/cmd/helm/helmpath"
"k8s.io/helm/pkg/helm" "k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/proto/hapi/release" "k8s.io/helm/pkg/proto/hapi/release"
) )
...@@ -127,8 +128,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command { ...@@ -127,8 +128,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.StringVarP(&inst.valuesFile, "values", "f", "", "specify values in a YAML file") f.StringVarP(&inst.valuesFile, "values", "f", "", "specify values in a YAML file")
f.StringVarP(&inst.name, "name", "n", "", "release name. If unspecified, it will autogenerate one for you") f.StringVarP(&inst.name, "name", "n", "", "release name. If unspecified, it will autogenerate one for you")
// TODO use kubeconfig default f.StringVar(&inst.namespace, "namespace", "", "namespace to install the release into")
f.StringVar(&inst.namespace, "namespace", "default", "namespace to install the release into")
f.BoolVar(&inst.dryRun, "dry-run", false, "simulate an install") f.BoolVar(&inst.dryRun, "dry-run", false, "simulate an install")
f.BoolVar(&inst.disableHooks, "no-hooks", false, "prevent hooks from running during install") f.BoolVar(&inst.disableHooks, "no-hooks", false, "prevent hooks from running during install")
f.BoolVar(&inst.replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production") f.BoolVar(&inst.replace, "replace", false, "re-use the given name, even if that name is already used. This is unsafe in production")
...@@ -146,6 +146,10 @@ func (i *installCmd) run() error { ...@@ -146,6 +146,10 @@ func (i *installCmd) run() error {
fmt.Fprintf(i.out, "CHART PATH: %s\n", i.chartPath) fmt.Fprintf(i.out, "CHART PATH: %s\n", i.chartPath)
} }
if i.namespace == "" {
i.namespace = defaultNamespace()
}
rawVals, err := i.vals() rawVals, err := i.vals()
if err != nil { if err != nil {
return err return err
...@@ -363,3 +367,10 @@ func generateName(nameTemplate string) (string, error) { ...@@ -363,3 +367,10 @@ func generateName(nameTemplate string) (string, error) {
} }
return b.String(), nil return b.String(), nil
} }
func defaultNamespace() string {
if ns, _, err := kube.GetConfig(kubeContext).Namespace(); err == nil {
return ns
}
return "default"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment