|
|
|
@ -39,10 +39,6 @@ import (
|
|
|
|
|
"k8s.io/helm/pkg/tlsutil"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
localRepoIndexFilePath = "index.yaml"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
tlsCaCertFile string // path to TLS CA certificate file
|
|
|
|
|
tlsCertFile string // path to TLS certificate file
|
|
|
|
@ -52,10 +48,9 @@ var (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
kubeContext string
|
|
|
|
|
settings helm_env.EnvSettings
|
|
|
|
|
// TODO refactor out this global var
|
|
|
|
|
kubeContext string
|
|
|
|
|
tillerTunnel *kube.Tunnel
|
|
|
|
|
settings helm_env.EnvSettings
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var globalUsage = `The Kubernetes package manager
|
|
|
|
@ -82,34 +77,57 @@ Environment:
|
|
|
|
|
$KUBECONFIG set an alternative Kubernetes configuration file (default "~/.kube/config")
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func setFlagFromEnv(name, envar string, cmd *cobra.Command) {
|
|
|
|
|
if cmd.Flags().Changed(name) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if v, ok := os.LookupEnv(envar); ok {
|
|
|
|
|
cmd.Flags().Set(name, v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func setFlagsFromEnv(flags map[string]string, cmd *cobra.Command) {
|
|
|
|
|
for name, envar := range flags {
|
|
|
|
|
setFlagFromEnv(name, envar, cmd)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func addRootFlags(cmd *cobra.Command) {
|
|
|
|
|
pf := cmd.PersistentFlags()
|
|
|
|
|
pf.StringVar((*string)(&settings.Home), "home", helm_env.DefaultHelmHome, "location of your Helm config. Overrides $HELM_HOME")
|
|
|
|
|
pf.StringVar(&settings.TillerHost, "host", "", "address of tiller. Overrides $HELM_HOST")
|
|
|
|
|
pf.StringVar(&kubeContext, "kube-context", "", "name of the kubeconfig context to use")
|
|
|
|
|
pf.BoolVar(&settings.Debug, "debug", false, "enable verbose output")
|
|
|
|
|
pf.StringVar(&settings.TillerNamespace, "tiller-namespace", tiller_env.DefaultTillerNamespace, "namespace of tiller")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func initRootFlags(cmd *cobra.Command) {
|
|
|
|
|
setFlagsFromEnv(map[string]string{
|
|
|
|
|
"debug": helm_env.DebugEnvVar,
|
|
|
|
|
"home": helm_env.HomeEnvVar,
|
|
|
|
|
"host": helm_env.HostEnvVar,
|
|
|
|
|
"tiller-namespace": tiller_env.TillerNamespaceEnvVar,
|
|
|
|
|
}, cmd.Root())
|
|
|
|
|
|
|
|
|
|
tlsCaCertFile = os.ExpandEnv(tlsCaCertFile)
|
|
|
|
|
tlsCertFile = os.ExpandEnv(tlsCertFile)
|
|
|
|
|
tlsKeyFile = os.ExpandEnv(tlsKeyFile)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func newRootCmd(out io.Writer) *cobra.Command {
|
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
|
Use: "helm",
|
|
|
|
|
Short: "The Helm package manager for Kubernetes.",
|
|
|
|
|
Long: globalUsage,
|
|
|
|
|
SilenceUsage: true,
|
|
|
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
|
|
|
tlsCaCertFile = os.ExpandEnv(tlsCaCertFile)
|
|
|
|
|
tlsCertFile = os.ExpandEnv(tlsCertFile)
|
|
|
|
|
tlsKeyFile = os.ExpandEnv(tlsKeyFile)
|
|
|
|
|
PersistentPreRun: func(cmd *cobra.Command, _ []string) {
|
|
|
|
|
initRootFlags(cmd)
|
|
|
|
|
},
|
|
|
|
|
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
|
|
|
|
PersistentPostRun: func(_ *cobra.Command, _ []string) {
|
|
|
|
|
teardown()
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
p := cmd.PersistentFlags()
|
|
|
|
|
p.StringVar((*string)(&settings.Home), "home", helm_env.DefaultHelmHome(), "location of your Helm config. Overrides $HELM_HOME")
|
|
|
|
|
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.BoolVar(&settings.Debug, "debug", false, "enable verbose output")
|
|
|
|
|
p.StringVar(&settings.TillerNamespace, "tiller-namespace", tiller_env.GetTillerNamespace(), "namespace of tiller")
|
|
|
|
|
|
|
|
|
|
if os.Getenv(helm_env.PluginDisableEnvVar) != "1" {
|
|
|
|
|
settings.PlugDirs = os.Getenv(helm_env.PluginEnvVar)
|
|
|
|
|
if settings.PlugDirs == "" {
|
|
|
|
|
settings.PlugDirs = settings.Home.Plugins()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
addRootFlags(cmd)
|
|
|
|
|
|
|
|
|
|
cmd.AddCommand(
|
|
|
|
|
// chart commands
|
|
|
|
|