|
|
@ -31,23 +31,22 @@ func TestEnvSettings(t *testing.T) {
|
|
|
|
name string
|
|
|
|
name string
|
|
|
|
|
|
|
|
|
|
|
|
// input
|
|
|
|
// input
|
|
|
|
args []string
|
|
|
|
args string
|
|
|
|
envars map[string]string
|
|
|
|
envars map[string]string
|
|
|
|
|
|
|
|
|
|
|
|
// expected values
|
|
|
|
// expected values
|
|
|
|
home, ns, plugins string
|
|
|
|
home, ns, kcontext, plugins string
|
|
|
|
debug bool
|
|
|
|
debug bool
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "defaults",
|
|
|
|
name: "defaults",
|
|
|
|
args: []string{},
|
|
|
|
home: defaultHelmHome,
|
|
|
|
home: DefaultHelmHome,
|
|
|
|
plugins: helmpath.Home(defaultHelmHome).Plugins(),
|
|
|
|
plugins: helmpath.Home(DefaultHelmHome).Plugins(),
|
|
|
|
ns: "",
|
|
|
|
ns: "kube-system",
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "with flags set",
|
|
|
|
name: "with flags set",
|
|
|
|
args: []string{"--home", "/foo", "--debug"},
|
|
|
|
args: "--home /foo --debug --namespace=myns",
|
|
|
|
home: "/foo",
|
|
|
|
home: "/foo",
|
|
|
|
plugins: helmpath.Home("/foo").Plugins(),
|
|
|
|
plugins: helmpath.Home("/foo").Plugins(),
|
|
|
|
ns: "myns",
|
|
|
|
ns: "myns",
|
|
|
@ -55,8 +54,7 @@ func TestEnvSettings(t *testing.T) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "with envvars set",
|
|
|
|
name: "with envvars set",
|
|
|
|
args: []string{},
|
|
|
|
envars: map[string]string{"HELM_HOME": "/bar", "HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns"},
|
|
|
|
envars: map[string]string{"HELM_HOME": "/bar", "HELM_DEBUG": "1"},
|
|
|
|
|
|
|
|
home: "/bar",
|
|
|
|
home: "/bar",
|
|
|
|
plugins: helmpath.Home("/bar").Plugins(),
|
|
|
|
plugins: helmpath.Home("/bar").Plugins(),
|
|
|
|
ns: "yourns",
|
|
|
|
ns: "yourns",
|
|
|
@ -64,8 +62,8 @@ func TestEnvSettings(t *testing.T) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "with flags and envvars set",
|
|
|
|
name: "with flags and envvars set",
|
|
|
|
args: []string{"--home", "/foo", "--debug"},
|
|
|
|
args: "--home /foo --debug --namespace=myns",
|
|
|
|
envars: map[string]string{"HELM_HOME": "/bar", "HELM_DEBUG": "1", "HELM_PLUGIN": "glade"},
|
|
|
|
envars: map[string]string{"HELM_HOME": "/bar", "HELM_DEBUG": "1", "HELM_NAMESPACE": "yourns", "HELM_PLUGIN": "glade"},
|
|
|
|
home: "/foo",
|
|
|
|
home: "/foo",
|
|
|
|
plugins: "glade",
|
|
|
|
plugins: "glade",
|
|
|
|
ns: "myns",
|
|
|
|
ns: "myns",
|
|
|
@ -86,7 +84,7 @@ func TestEnvSettings(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
settings := &EnvSettings{}
|
|
|
|
settings := &EnvSettings{}
|
|
|
|
settings.AddFlags(flags)
|
|
|
|
settings.AddFlags(flags)
|
|
|
|
flags.Parse(tt.args)
|
|
|
|
flags.Parse(strings.Split(tt.args, " "))
|
|
|
|
|
|
|
|
|
|
|
|
settings.Init(flags)
|
|
|
|
settings.Init(flags)
|
|
|
|
|
|
|
|
|
|
|
@ -99,6 +97,12 @@ func TestEnvSettings(t *testing.T) {
|
|
|
|
if settings.Debug != tt.debug {
|
|
|
|
if settings.Debug != tt.debug {
|
|
|
|
t.Errorf("expected debug %t, got %t", tt.debug, settings.Debug)
|
|
|
|
t.Errorf("expected debug %t, got %t", tt.debug, settings.Debug)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if settings.Namespace != tt.ns {
|
|
|
|
|
|
|
|
t.Errorf("expected namespace %q, got %q", tt.ns, settings.Namespace)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if settings.KubeContext != tt.kcontext {
|
|
|
|
|
|
|
|
t.Errorf("expected kube-context %q, got %q", tt.kcontext, settings.KubeContext)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cleanup()
|
|
|
|
cleanup()
|
|
|
|
})
|
|
|
|
})
|
|
|
|