fix(helm): fix setting home via `helm --home=HOME`

pull/2303/head
Adam Reese 8 years ago
parent ec2597d03d
commit 9832e7df96
No known key found for this signature in database
GPG Key ID: 06F35E60A7A18DD6

@ -33,7 +33,6 @@ import (
"k8s.io/helm/pkg/helm" "k8s.io/helm/pkg/helm"
helm_env "k8s.io/helm/pkg/helm/environment" helm_env "k8s.io/helm/pkg/helm/environment"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/helm/portforwarder" "k8s.io/helm/pkg/helm/portforwarder"
"k8s.io/helm/pkg/kube" "k8s.io/helm/pkg/kube"
tiller_env "k8s.io/helm/pkg/tiller/environment" tiller_env "k8s.io/helm/pkg/tiller/environment"
@ -84,8 +83,6 @@ Environment:
` `
func newRootCmd(out io.Writer) *cobra.Command { func newRootCmd(out io.Writer) *cobra.Command {
var helmHomeTemp string
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "helm", Use: "helm",
Short: "The Helm package manager for Kubernetes.", Short: "The Helm package manager for Kubernetes.",
@ -101,8 +98,7 @@ func newRootCmd(out io.Writer) *cobra.Command {
}, },
} }
p := cmd.PersistentFlags() p := cmd.PersistentFlags()
p.StringVar(&helmHomeTemp, "home", helm_env.DefaultHelmHome(), "location of your Helm config. Overrides $HELM_HOME") p.StringVar((*string)(&settings.Home), "home", helm_env.DefaultHelmHome(), "location of your Helm config. Overrides $HELM_HOME")
settings.Home = helmpath.Home(helmHomeTemp)
p.StringVar(&settings.TillerHost, "host", helm_env.DefaultHelmHost(), "address of tiller. Overrides $HELM_HOST") p.StringVar(&settings.TillerHost, "host", helm_env.DefaultHelmHost(), "address of tiller. Overrides $HELM_HOST")
p.StringVar(&kubeContext, "kube-context", "", "name of the kubeconfig context to use") p.StringVar(&kubeContext, "kube-context", "", "name of the kubeconfig context to use")
p.BoolVar(&settings.Debug, "debug", false, "enable verbose output") p.BoolVar(&settings.Debug, "debug", false, "enable verbose output")

@ -55,19 +55,29 @@ func newServeCmd(out io.Writer) *cobra.Command {
Use: "serve", Use: "serve",
Short: "start a local http web server", Short: "start a local http web server",
Long: serveDesc, Long: serveDesc,
PreRunE: func(cmd *cobra.Command, args []string) error {
return srv.complete(args)
},
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return srv.run() return srv.run()
}, },
} }
f := cmd.Flags() f := cmd.Flags()
f.StringVar(&srv.repoPath, "repo-path", settings.Home.LocalRepository(), "local directory path from which to serve charts") f.StringVar(&srv.repoPath, "repo-path", "", "local directory path from which to serve charts")
f.StringVar(&srv.address, "address", "127.0.0.1:8879", "address to listen on") f.StringVar(&srv.address, "address", "127.0.0.1:8879", "address to listen on")
f.StringVar(&srv.url, "url", "", "external URL of chart repository") f.StringVar(&srv.url, "url", "", "external URL of chart repository")
return cmd return cmd
} }
func (s *serveCmd) complete(args []string) error {
if s.repoPath == "" {
s.repoPath = settings.Home.LocalRepository()
}
return nil
}
func (s *serveCmd) run() error { func (s *serveCmd) run() error {
repoPath, err := filepath.Abs(s.repoPath) repoPath, err := filepath.Abs(s.repoPath)
if err != nil { if err != nil {

@ -28,7 +28,7 @@ helm serve
``` ```
--address string address to listen on (default "127.0.0.1:8879") --address string address to listen on (default "127.0.0.1:8879")
--repo-path string local directory path from which to serve charts (default "~/.helm/repository/local") --repo-path string local directory path from which to serve charts
--url string external URL of chart repository --url string external URL of chart repository
``` ```
@ -45,4 +45,4 @@ helm serve
### SEE ALSO ### SEE ALSO
* [helm](helm.md) - The Helm package manager for Kubernetes. * [helm](helm.md) - The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 17-May-2017 ###### Auto generated by spf13/cobra on 18-May-2017

@ -39,7 +39,7 @@ for more information on hosting chart repositories in a production setting.
address to listen on address to listen on
.PP .PP
\fB\-\-repo\-path\fP="~/.helm/repository/local" \fB\-\-repo\-path\fP=""
local directory path from which to serve charts local directory path from which to serve charts
.PP .PP
@ -76,4 +76,4 @@ for more information on hosting chart repositories in a production setting.
.SH HISTORY .SH HISTORY
.PP .PP
17\-May\-2017 Auto generated by spf13/cobra 18\-May\-2017 Auto generated by spf13/cobra

Loading…
Cancel
Save