Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit d5b8fbf

Browse files
committed
fix(plugins/plugin-kubectl): does not get from namespace
1 parent b6d19ed commit d5b8fbf

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

plugins/plugin-kubectl/src/controller/kubectl/options.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,16 @@ export function hasLabel(args: Arguments<KubeOptions>) {
195195
/** @return the namespace as expressed in the command line, or undefined if not */
196196
export function getNamespaceAsExpressed(args: Pick<Arguments<KubeOptions>, 'parsedOptions'>): string {
197197
const ns = args.parsedOptions.n || args.parsedOptions.namespace
198-
if (Array.isArray(ns)) {
198+
if (!ns) {
199+
// look for -nfoo, which yargs-parser doesn't handle very well
200+
// this will show up as a parsedOption of { nfoo: true }
201+
const maybeNs = Object.entries(args.parsedOptions).find(
202+
([key, value]) => value === true && key.length > 1 && key[0] === 'n'
203+
)
204+
if (maybeNs) {
205+
return maybeNs[0].slice(1)
206+
}
207+
} else if (Array.isArray(ns)) {
199208
return ns[ns.length - 1]
200209
} else {
201210
return ns

plugins/plugin-kubectl/src/test/k8s1/apply-pod.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ describe(`kubectl apply pod ${process.env.MOCHA_RUN_TARGET || ''}`, function(thi
3232
after(Common.after(this))
3333

3434
const ns: string = createNS()
35-
const inNamespace = `-n ${ns}`
35+
const inNamespace = `-n${ns}`
36+
// ^^^ intentionally no space between -n and ${ns} to cover #8992
3637

3738
allocateNS(this, ns)
3839

0 commit comments

Comments
 (0)