Skip to content

Commit

Permalink
rename withheader to setheader for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamero committed Feb 28, 2025
1 parent e04bc14 commit 697f13b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/patch-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ try {

await k8sApi.patchNamespacedPod(
{ name: res?.items?.[0]?.metadata?.name ?? '', namespace, body: patch },
k8s.withHeaderOptions('Content-Type', 'application/json-patch+json'),
k8s.setHeaderOptions('Content-Type', k8s.JsonPatch),
);

console.log('Patched.');
Expand Down
4 changes: 2 additions & 2 deletions examples/typescript/patch/patch-example.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CoreV1Api, KubeConfig, withHeaderOptions } from '@kubernetes/client-node';
import { CoreV1Api, KubeConfig, setHeaderOptions, JsonPatch } from '@kubernetes/client-node';

const kc = new KubeConfig();
kc.loadFromDefault();
Expand Down Expand Up @@ -28,7 +28,7 @@ try {
namespace: 'default',
body: patch,
},
withHeaderOptions('Content-Type', JsonPatch),
setHeaderOptions('Content-Type', JsonPatch),
);

console.log('Patched.');
Expand Down
8 changes: 4 additions & 4 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { RequestContext, ResponseContext, ConfigurationOptions, Middleware } from './gen/index.js';
import { PromiseMiddleware } from './gen/middleware.js';

// withHeaderMiddleware returns Middleware[] that sets a header value
export function withHeaderMiddleware(key: string, value: string): Middleware[] {
// setHeaderMiddleware returns Middleware[] that sets a header value
export function setHeaderMiddleware(key: string, value: string): Middleware[] {
return [
{
pre: async (c: RequestContext) => {
Expand All @@ -17,12 +17,12 @@ export function withHeaderMiddleware(key: string, value: string): Middleware[] {
}

// Returns ConfigurationOptions that set a header
export function withHeaderOptions(
export function setHeaderOptions(
key: string,
value: string,
opt?: ConfigurationOptions<PromiseMiddleware>,
): ConfigurationOptions<PromiseMiddleware> {
const newMiddlware = withHeaderMiddleware(key, value);
const newMiddlware = setHeaderMiddleware(key, value);
const existingMiddlware = opt?.middleware || [];
return {
...opt,
Expand Down

0 comments on commit 697f13b

Please sign in to comment.