Skip to content

Commit 63cbc28

Browse files
authored
Merge pull request #189 from swcho/add-namespace-to-context
Add `namespace` To Context
2 parents b9022fc + 6237fb6 commit 63cbc28

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/config_test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ function validateFileLoad(kc: KubeConfig) {
4646
const context2 = kc.contexts[1];
4747
expect(context1.name).to.equal('context1');
4848
expect(context1.user).to.equal('user1');
49+
expect(context1.namespace).to.equal(undefined);
4950
expect(context1.cluster).to.equal('cluster1');
5051
expect(context2.name).to.equal('context2');
5152
expect(context2.user).to.equal('user2');
53+
expect(context2.namespace).to.equal('namespace2');
5254
expect(context2.cluster).to.equal('cluster2');
5355

5456
expect(kc.getCurrentContext()).to.equal('context2');

src/config_types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export interface Context {
8484
readonly cluster: string;
8585
readonly user: string;
8686
readonly name: string;
87+
readonly namespace?: string;
8788
}
8889

8990
export function newContexts(a: any): Context[] {
@@ -104,7 +105,8 @@ function contextIterator(): u.ListIterator<any, Context> {
104105
return {
105106
cluster: elt.context.cluster,
106107
name: elt.name,
107-
user: (elt.context.user ? elt.context.user : undefined),
108+
user: elt.context.user || undefined,
109+
namespace: elt.context.namespace || undefined,
108110
};
109111
};
110112
}

testdata/kubeconfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ contexts:
1717
name: context1
1818
- context:
1919
cluster: cluster2
20+
namespace: namespace2
2021
user: user2
2122
name: context2
2223

0 commit comments

Comments
 (0)