Commit e93d5b90 authored by Adam Reese's avatar Adam Reese

fix(helm): respect kubeconfig default namespace

fixes: #1396
parent d744a3d0
......@@ -35,6 +35,7 @@ import (
"k8s.io/helm/cmd/helm/downloader"
"k8s.io/helm/cmd/helm/helmpath"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/proto/hapi/release"
)
......@@ -127,8 +128,7 @@ func newInstallCmd(c helm.Interface, out io.Writer) *cobra.Command {
f := cmd.Flags()
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")
// TODO use kubeconfig default
f.StringVar(&inst.namespace, "namespace", "default", "namespace to install the release into")
f.StringVar(&inst.namespace, "namespace", "", "namespace to install the release into")
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.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 {
fmt.Fprintf(i.out, "CHART PATH: %s\n", i.chartPath)
}
if i.namespace == "" {
i.namespace = defaultNamespace()
}
rawVals, err := i.vals()
if err != nil {
return err
......@@ -363,3 +367,10 @@ func generateName(nameTemplate string) (string, error) {
}
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