Merge pull request #10230 from yxxhero/fix_sdk_namespace_issue

add SetNamespace method for EnvSettings, in order to set namespace in helm sdk
pull/10201/head
Matthew Fisher 4 years ago committed by GitHub
commit 5d47255a3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -180,6 +180,11 @@ func (s *EnvSettings) Namespace() string {
return "default" return "default"
} }
// SetNamespace sets the namespace in the configuration
func (s *EnvSettings) SetNamespace(namespace string) {
s.namespace = namespace
}
// RESTClientGetter gets the kubeconfig from EnvSettings // RESTClientGetter gets the kubeconfig from EnvSettings
func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter { func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter {
return s.config return s.config

@ -25,6 +25,20 @@ import (
"github.com/spf13/pflag" "github.com/spf13/pflag"
) )
func TestSetNamespace(t *testing.T) {
settings := New()
if settings.namespace != "" {
t.Errorf("Expected empty namespace, got %s", settings.namespace)
}
settings.SetNamespace("testns")
if settings.namespace != "testns" {
t.Errorf("Expected namespace testns, got %s", settings.namespace)
}
}
func TestEnvSettings(t *testing.T) { func TestEnvSettings(t *testing.T) {
tests := []struct { tests := []struct {
name string name string

Loading…
Cancel
Save