From c9bcff53a90df4b38e0cbd1fcd502b92f1b9d65a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Mar 2026 23:59:51 +0000 Subject: [PATCH 1/4] Initial plan From f75ff67d8edc4c60e9fa61170916a72e6b0f42d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 00:06:08 +0000 Subject: [PATCH 2/4] Initial plan Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com> --- settings | 2 +- testdata/kubeconfig-proxy-url.yaml | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/settings b/settings index 8711628a48..88b18c470b 100644 --- a/settings +++ b/settings @@ -30,4 +30,4 @@ export CLIENT_VERSION="0.8-SNAPSHOT" # Name of the release package export PACKAGE_NAME="@kubernetes/node-client" -export OPENAPI_GENERATOR_COMMIT=9fa18d0c8102322039676a9d11107a7cd00bf6ae +export OPENAPI_GENERATOR_COMMIT=6e0fe098f1d9631c696135c7a3c46e4b0dc9ab3f diff --git a/testdata/kubeconfig-proxy-url.yaml b/testdata/kubeconfig-proxy-url.yaml index ee97c7f4fa..03ea1a2cdf 100644 --- a/testdata/kubeconfig-proxy-url.yaml +++ b/testdata/kubeconfig-proxy-url.yaml @@ -29,10 +29,6 @@ clusters: certificate-authority-data: Q0FEQVRA server: http://exampleerror.com name: clusterF - - cluster: - certificate-authority-data: Q0FEQVRA - server: https://example7.com - name: clusterG contexts: - context: @@ -59,10 +55,6 @@ contexts: cluster: clusterF user: userF name: contextF - - context: - cluster: clusterG - user: userG - name: contextG current-context: contextA kind: Config @@ -92,7 +84,3 @@ users: user: client-certificate-data: XVNFUl9DQURBVEE= client-key-data: XVNFUl9DS0RBVEE= - - name: userG - user: - client-certificate-data: XVNFUl9DQURBVEE= - client-key-data: XVNFUl9DS0RBVEE= From ec0a01fc5359f832b860db5f4ce04456409f2bbc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 00:10:16 +0000 Subject: [PATCH 3/4] fix: restore coverage for proxy agent paths and add missing contextG test data Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com> --- src/config_test.ts | 52 ++++++++++++++++++++++++++++++ testdata/kubeconfig-proxy-url.yaml | 12 +++++++ 2 files changed, 64 insertions(+) diff --git a/src/config_test.ts b/src/config_test.ts index 888b2138d5..980e408192 100644 --- a/src/config_test.ts +++ b/src/config_test.ts @@ -26,6 +26,8 @@ import { bufferFromFileOrString, findHomeDir, findObject, KubeConfig, makeAbsolu import { ActionOnInvalid, Cluster, newClusters, newContexts, newUsers, User } from './config_types.js'; import { ExecAuth } from './exec_auth.js'; import { Agent as UndiciAgent, ProxyAgent as UndiciProxyAgent } from 'undici'; +import { SocksProxyAgent } from 'socks-proxy-agent'; +import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent'; import { AddressInfo } from 'node:net'; const kcFileName = 'testdata/kubeconfig.yaml'; @@ -506,6 +508,56 @@ describe('KubeConfig', () => { strictEqual(rc.getDispatcher() instanceof UndiciAgent, true); }); + it('should apply socks proxy agent via applyToHTTPSOptions', async () => { + const kc = new KubeConfig(); + kc.loadFromFile(kcProxyUrl); + kc.setCurrentContext('contextA'); + + const opts: https.RequestOptions = {}; + await kc.applyToHTTPSOptions(opts); + + strictEqual(opts.agent instanceof SocksProxyAgent, true); + }); + it('should apply https proxy agent via applyToHTTPSOptions', async () => { + const kc = new KubeConfig(); + kc.loadFromFile(kcProxyUrl); + kc.setCurrentContext('contextB'); + + const opts: https.RequestOptions = {}; + await kc.applyToHTTPSOptions(opts); + + strictEqual(opts.agent instanceof HttpsProxyAgent, true); + }); + it('should apply http proxy agent via applyToHTTPSOptions', async () => { + const kc = new KubeConfig(); + kc.loadFromFile(kcProxyUrl); + kc.setCurrentContext('contextC'); + + const opts: https.RequestOptions = {}; + await kc.applyToHTTPSOptions(opts); + + strictEqual(opts.agent instanceof HttpProxyAgent, true); + }); + it('should throw unsupported proxy type via applyToHTTPSOptions', async () => { + const kc = new KubeConfig(); + kc.loadFromFile(kcProxyUrl); + kc.setCurrentContext('contextD'); + + const opts: https.RequestOptions = {}; + await rejects(kc.applyToHTTPSOptions(opts), { + message: 'Unsupported proxy type', + }); + }); + it('should throw if cluster.server starts with http and skipTLSVerify is not set via applyToHTTPSOptions', async () => { + const kc = new KubeConfig(); + kc.loadFromFile(kcProxyUrl); + kc.setCurrentContext('contextF'); + + const opts: https.RequestOptions = {}; + await rejects(kc.applyToHTTPSOptions(opts), { + message: 'HTTP protocol is not allowed when skipTLSVerify is not set or false', + }); + }); it('should apply NODE_TLS_REJECT_UNAUTHORIZED from environment to agent', async () => { const { server, host, port } = await createTestHttpsServer((req, res) => { diff --git a/testdata/kubeconfig-proxy-url.yaml b/testdata/kubeconfig-proxy-url.yaml index 03ea1a2cdf..ee97c7f4fa 100644 --- a/testdata/kubeconfig-proxy-url.yaml +++ b/testdata/kubeconfig-proxy-url.yaml @@ -29,6 +29,10 @@ clusters: certificate-authority-data: Q0FEQVRA server: http://exampleerror.com name: clusterF + - cluster: + certificate-authority-data: Q0FEQVRA + server: https://example7.com + name: clusterG contexts: - context: @@ -55,6 +59,10 @@ contexts: cluster: clusterF user: userF name: contextF + - context: + cluster: clusterG + user: userG + name: contextG current-context: contextA kind: Config @@ -84,3 +92,7 @@ users: user: client-certificate-data: XVNFUl9DQURBVEE= client-key-data: XVNFUl9DS0RBVEE= + - name: userG + user: + client-certificate-data: XVNFUl9DQURBVEE= + client-key-data: XVNFUl9DS0RBVEE= From b15d9bdcce61d388da4b82815bf0610fd140f1c2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 14:51:44 +0000 Subject: [PATCH 4/4] revert: restore settings file to original state Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com> --- settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings b/settings index 88b18c470b..8711628a48 100644 --- a/settings +++ b/settings @@ -30,4 +30,4 @@ export CLIENT_VERSION="0.8-SNAPSHOT" # Name of the release package export PACKAGE_NAME="@kubernetes/node-client" -export OPENAPI_GENERATOR_COMMIT=6e0fe098f1d9631c696135c7a3c46e4b0dc9ab3f +export OPENAPI_GENERATOR_COMMIT=9fa18d0c8102322039676a9d11107a7cd00bf6ae