Merge pull request #12979 from CalvinKrist/fix-namespace-on-kube-error

12124: Fix namespace on kubeconfig error
This commit is contained in:
Joe Julian
2024-04-29 05:26:06 -07:00
committed by GitHub
2 changed files with 11 additions and 0 deletions

View File

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

View File

@@ -111,6 +111,14 @@ func TestEnvSettings(t *testing.T) {
kubeTLSServer: "example.org",
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 {