From 3121c62dc235e2e6e8edb00114611c56c86d01be Mon Sep 17 00:00:00 2001 From: Nick Mitchell Date: Tue, 29 Jun 2021 18:25:56 -0400 Subject: [PATCH] fix(plugins/plugin-kubectl): oc login does not switch kube proxy in browser clients part of #7742 --- .../plugin-kubectl/oc/src/controller/oc/login.ts | 16 +++++++++++++++- .../src/controller/kubectl/exec.ts | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/plugin-kubectl/oc/src/controller/oc/login.ts b/plugins/plugin-kubectl/oc/src/controller/oc/login.ts index 9c798bc3134..4d839634a17 100644 --- a/plugins/plugin-kubectl/oc/src/controller/oc/login.ts +++ b/plugins/plugin-kubectl/oc/src/controller/oc/login.ts @@ -19,8 +19,22 @@ import { doExecWithPty, emitKubectlConfigChangeEvent } from '@kui-shell/plugin-k export default function registerOcLogin(registrar: Registrar) { registrar.listen('/oc/login', async args => { - const response = await doExecWithPty(args) + const command = args.command.replace(/login/, '_login') + const response = await args.REPL.qexec(command) emitKubectlConfigChangeEvent('SetNamespaceOrContext') return response }) + + registrar.listen( + '/oc/_login', + async args => { + args.command = args.command.replace(/_login/, 'login') + args.argvNoOptions[1] = 'login' + args.argv[1] = 'login' + const response = await doExecWithPty(args, undefined, 'oc') + emitKubectlConfigChangeEvent('SetNamespaceOrContext') + return response + }, + { requiresLocal: true } + ) } diff --git a/plugins/plugin-kubectl/src/controller/kubectl/exec.ts b/plugins/plugin-kubectl/src/controller/kubectl/exec.ts index 896d599ac16..84addf578ac 100644 --- a/plugins/plugin-kubectl/src/controller/kubectl/exec.ts +++ b/plugins/plugin-kubectl/src/controller/kubectl/exec.ts @@ -108,9 +108,9 @@ export async function doExecWithPty< Content = void, Response extends KResponse = KResponse, O extends KubeOptions = KubeOptions ->(args: Arguments, prepare: Prepare = NoPrepare): Promise { +>(args: Arguments, prepare: Prepare = NoPrepare, exec?: string): Promise { if (!reallyNeedsPty(args) && (isHeadless() || (!inBrowser() && args.execOptions.raw))) { - return doExecWithStdout(args, prepare) + return doExecWithStdout(args, prepare, exec) } else { // // For commands `kubectl (--help/-h)` and `k (--help/-h)`, render usage model;