From 1b7dd717a5b609853bcbf2bdda9bda8b123913ee Mon Sep 17 00:00:00 2001 From: chh <1474479+chenhunghan@users.noreply.github.com> Date: Tue, 7 Jun 2022 20:06:58 +0800 Subject: [PATCH] Allow using custom https.Agent instance (#5564) * Allow using custom https.Agent instance Signed-off-by: Hung-Han (Henry) Chen * Use .constructor(agentOptions) Signed-off-by: Hung-Han (Henry) Chen * Revert Signed-off-by: Hung-Han (Henry) Chen --- src/common/k8s-api/kube-api.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/common/k8s-api/kube-api.ts b/src/common/k8s-api/kube-api.ts index bc1c2f6415..4a487b82d3 100644 --- a/src/common/k8s-api/kube-api.ts +++ b/src/common/k8s-api/kube-api.ts @@ -169,6 +169,13 @@ export interface IRemoteKubeApiConfig { clientCertificateData?: string; clientKeyData?: string; }; + /** + * Custom instance of https.agent to use for the requests + * + * @remarks the custom agent replaced default agent, options skipTLSVerify, + * clientCertificateData, clientKeyData and caData are ignored. + */ + agent?: Agent; } export function forCluster< @@ -240,6 +247,10 @@ export function forRemoteCluster< reqInit.agent = new Agent(agentOptions); } + if (config.agent) { + reqInit.agent = config.agent; + } + const token = config.user.token; const request = new KubeJsonApi({ serverAddress: config.cluster.server,