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

Commit 8ca795f

Browse files
starpitk8s-ci-robot
authored andcommitted
fix(plugins/plugin-kubectl): oc login does not switch kube proxy in browser clients
part of #7742
1 parent a8d99a7 commit 8ca795f

File tree

2 files changed

+17
-3
lines changed
  • plugins/plugin-kubectl

2 files changed

+17
-3
lines changed

plugins/plugin-kubectl/oc/src/controller/oc/login.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,22 @@ import { doExecWithPty, emitKubectlConfigChangeEvent } from '@kui-shell/plugin-k
1919

2020
export default function registerOcLogin(registrar: Registrar) {
2121
registrar.listen('/oc/login', async args => {
22-
const response = await doExecWithPty(args)
22+
const command = args.command.replace(/login/, '_login')
23+
const response = await args.REPL.qexec(command)
2324
emitKubectlConfigChangeEvent('SetNamespaceOrContext')
2425
return response
2526
})
27+
28+
registrar.listen(
29+
'/oc/_login',
30+
async args => {
31+
args.command = args.command.replace(/_login/, 'login')
32+
args.argvNoOptions[1] = 'login'
33+
args.argv[1] = 'login'
34+
const response = await doExecWithPty(args, undefined, 'oc')
35+
emitKubectlConfigChangeEvent('SetNamespaceOrContext')
36+
return response
37+
},
38+
{ requiresLocal: true }
39+
)
2640
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ export async function doExecWithPty<
108108
Content = void,
109109
Response extends KResponse<Content> = KResponse<Content>,
110110
O extends KubeOptions = KubeOptions
111-
>(args: Arguments<O>, prepare: Prepare<O> = NoPrepare): Promise<string | Response> {
111+
>(args: Arguments<O>, prepare: Prepare<O> = NoPrepare, exec?: string): Promise<string | Response> {
112112
if (!reallyNeedsPty(args) && (isHeadless() || (!inBrowser() && args.execOptions.raw))) {
113-
return doExecWithStdout(args, prepare)
113+
return doExecWithStdout(args, prepare, exec)
114114
} else {
115115
//
116116
// For commands `kubectl (--help/-h)` and `k (--help/-h)`, render usage model;

0 commit comments

Comments
 (0)