Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion plugins/plugin-kubectl/src/controller/kubectl/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,16 @@ export function hasLabel(args: Arguments<KubeOptions>) {
/** @return the namespace as expressed in the command line, or undefined if not */
export function getNamespaceAsExpressed(args: Pick<Arguments<KubeOptions>, 'parsedOptions'>): string {
const ns = args.parsedOptions.n || args.parsedOptions.namespace
if (Array.isArray(ns)) {
if (!ns) {
// look for -nfoo, which yargs-parser doesn't handle very well
// this will show up as a parsedOption of { nfoo: true }
const maybeNs = Object.entries(args.parsedOptions).find(
([key, value]) => value === true && key.length > 1 && key[0] === 'n'
)
if (maybeNs) {
return maybeNs[0].slice(1)
}
} else if (Array.isArray(ns)) {
return ns[ns.length - 1]
} else {
return ns
Expand Down
3 changes: 2 additions & 1 deletion plugins/plugin-kubectl/src/test/k8s1/apply-pod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ describe(`kubectl apply pod ${process.env.MOCHA_RUN_TARGET || ''}`, function(thi
after(Common.after(this))

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

allocateNS(this, ns)

Expand Down