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
2 changes: 2 additions & 0 deletions src/config_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ function validateFileLoad(kc: KubeConfig) {
const context2 = kc.contexts[1];
expect(context1.name).to.equal('context1');
expect(context1.user).to.equal('user1');
expect(context1.namespace).to.equal(undefined);
expect(context1.cluster).to.equal('cluster1');
expect(context2.name).to.equal('context2');
expect(context2.user).to.equal('user2');
expect(context2.namespace).to.equal('namespace2');
expect(context2.cluster).to.equal('cluster2');

expect(kc.getCurrentContext()).to.equal('context2');
Expand Down
4 changes: 3 additions & 1 deletion src/config_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export interface Context {
readonly cluster: string;
readonly user: string;
readonly name: string;
readonly namespace?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be just namespace like the others and set to undefined if not set?

}

export function newContexts(a: any): Context[] {
Expand All @@ -104,7 +105,8 @@ function contextIterator(): u.ListIterator<any, Context> {
return {
cluster: elt.context.cluster,
name: elt.name,
user: (elt.context.user ? elt.context.user : undefined),
user: elt.context.user || undefined,
namespace: elt.context.namespace || undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we standise on one of the above to formats? Not sure which one is better though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| syntax is fine with me, and agree standardization is good.

};
};
}
1 change: 1 addition & 0 deletions testdata/kubeconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ contexts:
name: context1
- context:
cluster: cluster2
namespace: namespace2
user: user2
name: context2

Expand Down