Skip to content

Commit

Permalink
Merge pull request #12979 from CalvinKrist/fix-namespace-on-kube-error
Browse files Browse the repository at this point in the history
12124: Fix namespace on kubeconfig error
  • Loading branch information
joejulian committed Apr 29, 2024
2 parents 14d0c13 + 214fb6e commit c6beb16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cli/environment.go
Expand Up @@ -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"
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/cli/environment_test.go
Expand Up @@ -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 {
Expand Down

0 comments on commit c6beb16

Please sign in to comment.