-
Notifications
You must be signed in to change notification settings - Fork 557
update HeaderMiddleware types, export PatchStrategy with Integration Tests #2316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
k8s-ci-robot
merged 9 commits into
kubernetes-client:main
from
davidgamero:kind-integration-tests
Mar 26, 2025
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a66aa27
integration test for patch middleware
davidgamero acc225e
update middleware unit tests
davidgamero 4254345
kind integration test in workflow
davidgamero 43b8ea6
kind integration test in workflow
davidgamero 4029d2e
extension
davidgamero 7b19ee6
update to strictequals, imports, and remove mixed then/await
davidgamero 0dc4bbe
remove unused deepequal import
davidgamero 75c11e2
checkout main package-lock
davidgamero 64ff97d
switch to await
davidgamero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import patchNamespace from './patchNamespace.js'; | ||
|
||
console.log('Integration testing'); | ||
|
||
patchNamespace(); | ||
davidgamero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import assert, { deepEqual } from 'node:assert'; | ||
import { PatchStrategy, CoreV1Api, KubeConfig, setHeaderOptions, V1Namespace } from '../../index.js'; | ||
|
||
export default async function patchNamespace() { | ||
const kc = new KubeConfig(); | ||
kc.loadFromDefault(); | ||
|
||
const coreV1Client = kc.makeApiClient(CoreV1Api); | ||
let newNS = new V1Namespace(); | ||
const testNSName = 'integration-test-patch-ns'; | ||
davidgamero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
newNS.metadata = { | ||
name: testNSName, | ||
labels: { | ||
initialLabel: 'initialValue', | ||
}, | ||
}; | ||
console.log(`Creating namespace ${testNSName}`); | ||
await coreV1Client.createNamespace({ body: newNS }); | ||
newNS = await coreV1Client.readNamespace({ name: testNSName }); | ||
assert(newNS.metadata?.name === testNSName); | ||
davidgamero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
deepEqual(newNS.metadata?.labels?.initialLabel, 'initialValue'); | ||
davidgamero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
console.log('Namespace created with initial label.'); | ||
|
||
const patch = [ | ||
{ | ||
op: 'replace', | ||
path: '/metadata/labels', | ||
value: { | ||
foo: 'bar', | ||
}, | ||
}, | ||
]; | ||
|
||
console.log(`Patching namespace ${testNSName} to replace labels`); | ||
await coreV1Client.patchNamespace( | ||
{ | ||
name: testNSName, | ||
body: patch, | ||
}, | ||
setHeaderOptions('Content-Type', PatchStrategy.JsonPatch), | ||
); | ||
|
||
const patchedNS = await coreV1Client.readNamespace({ name: testNSName }); | ||
deepEqual(patchedNS.metadata?.labels?.foo, 'bar'); | ||
deepEqual(patchedNS.metadata?.labels?.initialLabel, undefined); | ||
davidgamero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
console.log('Namespace patched with new label.'); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.