Fix namespace on kubeconfig error

Signed-off-by: Calvin Krist <calvin.krist@yahoo.com>
pull/12979/head
Calvin Krist 8 months ago
parent 14d0c13e9e
commit 214fb6eff3

@ -244,6 +244,9 @@ func (s *EnvSettings) Namespace() string {
if ns, _, err := s.config.ToRawKubeConfigLoader().Namespace(); err == nil { if ns, _, err := s.config.ToRawKubeConfigLoader().Namespace(); err == nil {
return ns return ns
} }
if s.namespace != "" {
return s.namespace
}
return "default" return "default"
} }

@ -111,6 +111,14 @@ func TestEnvSettings(t *testing.T) {
kubeTLSServer: "example.org", kubeTLSServer: "example.org",
kubeInsecure: true, kubeInsecure: true,
}, },
{
name: "invalid kubeconfig",
ns: "testns",
args: "--namespace=testns --kubeconfig=/path/to/fake/file",
maxhistory: defaultMaxHistory,
burstLimit: defaultBurstLimit,
qps: defaultQPS,
},
} }
for _, tt := range tests { for _, tt := range tests {

Loading…
Cancel
Save