Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ export function findObject<T extends Named>(list: T[], name: string, key: string
for (const obj of list) {
if (obj.name === name) {
if (obj[key]) {
obj[key].name = name;
return obj[key];
}
return obj;
Expand Down
26 changes: 26 additions & 0 deletions src/config_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,32 @@ describe('KubeConfig', () => {
expect(opts.headers.Authorization).to.equal(`Bearer ${token}`);
}
});
it('should cache exec with name', async () => {
const config = new KubeConfig();
const token = 'token';
const responseStr = `{
"apiVersion": "client.authentication.k8s.io/v1beta1",
"kind": "ExecCredential",
"status": {
"token": "${token}"
}
}`;
config.loadFromClusterAndUser(
{ skipTLSVerify: false } as Cluster,
{
name: 'exec',
exec: {
command: 'echo',
args: [`${responseStr}`],
},
} as User,
);
// TODO: inject the exec command here?
const opts = {} as requestlib.Options;
await config.applyToRequest(opts);
expect((KubeConfig as any).authenticators[1].tokenCache['exec']).to.deep.equal(JSON.parse(responseStr));
});

it('should throw with no command.', () => {
const config = new KubeConfig();
config.loadFromClusterAndUser(
Expand Down