Skip to content

Commit

Permalink
examples: fix confusing patch example code
Browse files Browse the repository at this point in the history
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: kubernetes-client#2168
  • Loading branch information
cjihrig committed Jan 31, 2025
1 parent 247e4ed commit d7b85cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions examples/patch-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions examples/typescript/patch/patch-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d7b85cf

Please sign in to comment.