From d7b85cf2c9f123a9d88625828dcc22de30842dfe Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 31 Jan 2025 14:32:59 -0500 Subject: [PATCH] examples: fix confusing patch example code This commit updates the patch examples to use getCurrentCluster(). The existing code relied on the current context having the same name as a cluster. Refs: https://github.com/kubernetes-client/javascript/issues/2168 --- examples/patch-example.js | 5 ++--- examples/typescript/patch/patch-example.ts | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/patch-example.js b/examples/patch-example.js index 9f2ab55b9c..4fe1a1a262 100644 --- a/examples/patch-example.js +++ b/examples/patch-example.js @@ -25,9 +25,8 @@ try { }, post: async (responseContext) => responseContext, }); - let currentContext = kc.getCurrentContext(); - let currentCluster = kc.getCluster(currentContext); - if (currentCluster === undefined || currentCluster === null) { + let currentCluster = kc.getCurrentCluster(); + if (currentCluster === null) { throw new Error('Cluster is undefined'); } let server = currentCluster.server; diff --git a/examples/typescript/patch/patch-example.ts b/examples/typescript/patch/patch-example.ts index 5cef886695..124e9b6278 100644 --- a/examples/typescript/patch/patch-example.ts +++ b/examples/typescript/patch/patch-example.ts @@ -32,9 +32,8 @@ try { }, post: async (responseContext: ResponseContext) => responseContext, }); - const currentContext = kc.getCurrentContext(); - const currentCluster = kc.getCluster(currentContext); - if (currentCluster === undefined || currentCluster === null) { + const currentCluster = kc.getCurrentCluster(); + if (currentCluster === null) { throw new Error('Cluster is undefined'); } const server = currentCluster.server;