Skip to content
Merged
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
23 changes: 23 additions & 0 deletions src/config_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ describe('KubeConfig', () => {
});
});

describe('loadFromCluster', () => {
it('should load from cluster', () => {
process.env.KUBERNETES_SERVICE_HOST = 'example.com';
process.env.KUBERNETES_SERVICE_PORT = '8080';

const kc = new KubeConfig();
kc.loadFromCluster();
const expectedCluster = {
caFile: '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt',
name: 'inCluster',
server: 'http://example.com:8080',
skipTLSVerify: false,
};

process.env.KUBERNETES_SERVICE_HOST = undefined;
process.env.KUBERNETES_SERVICE_PORT = undefined;

strictEqual(kc.getCurrentContext(), 'inClusterContext');
deepEqual(kc.getCurrentCluster(), expectedCluster);
deepEqual(kc.getCluster(kc.getContextObject(kc.getCurrentContext())!.cluster), expectedCluster);
});
});

describe('loadFromClusterAndUser', () => {
it('should load from cluster and user', () => {
const kc = new KubeConfig();
Expand Down
Loading