Merge pull request #11 from Azure/users/shigupt/add-env-variable
Setting KUBECONFIG for current step
This commit is contained in:
commit
163908311f
@ -91,10 +91,12 @@ function getKubectlPath() {
|
|||||||
return kubectlPath;
|
return kubectlPath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function setContext() {
|
function setContext(kubeconfigPath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let context = core.getInput('context');
|
let context = core.getInput('context');
|
||||||
if (context) {
|
if (context) {
|
||||||
|
//To use kubectl commands, the environment variable KUBECONFIG needs to be set for this step
|
||||||
|
process.env['KUBECONFIG'] = kubeconfigPath;
|
||||||
const kubectlPath = yield getKubectlPath();
|
const kubectlPath = yield getKubectlPath();
|
||||||
let toolRunner = new toolrunner_1.ToolRunner(kubectlPath, ['config', 'use-context', context]);
|
let toolRunner = new toolrunner_1.ToolRunner(kubectlPath, ['config', 'use-context', context]);
|
||||||
yield toolRunner.exec();
|
yield toolRunner.exec();
|
||||||
@ -112,7 +114,7 @@ function run() {
|
|||||||
fs.writeFileSync(kubeconfigPath, kubeconfig);
|
fs.writeFileSync(kubeconfigPath, kubeconfig);
|
||||||
command_1.issueCommand('set-env', { name: 'KUBECONFIG' }, kubeconfigPath);
|
command_1.issueCommand('set-env', { name: 'KUBECONFIG' }, kubeconfigPath);
|
||||||
console.log('KUBECONFIG environment variable is set');
|
console.log('KUBECONFIG environment variable is set');
|
||||||
yield setContext();
|
yield setContext(kubeconfigPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
run().catch(core.setFailed);
|
run().catch(core.setFailed);
|
||||||
|
@ -89,9 +89,11 @@ async function getKubectlPath() {
|
|||||||
return kubectlPath;
|
return kubectlPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setContext() {
|
async function setContext(kubeconfigPath: string) {
|
||||||
let context = core.getInput('context');
|
let context = core.getInput('context');
|
||||||
if (context) {
|
if (context) {
|
||||||
|
//To use kubectl commands, the environment variable KUBECONFIG needs to be set for this step
|
||||||
|
process.env['KUBECONFIG'] = kubeconfigPath;
|
||||||
const kubectlPath = await getKubectlPath();
|
const kubectlPath = await getKubectlPath();
|
||||||
let toolRunner = new ToolRunner(kubectlPath, ['config', 'use-context', context]);
|
let toolRunner = new ToolRunner(kubectlPath, ['config', 'use-context', context]);
|
||||||
await toolRunner.exec();
|
await toolRunner.exec();
|
||||||
@ -108,7 +110,7 @@ async function run() {
|
|||||||
fs.writeFileSync(kubeconfigPath, kubeconfig);
|
fs.writeFileSync(kubeconfigPath, kubeconfig);
|
||||||
issueCommand('set-env', { name: 'KUBECONFIG' }, kubeconfigPath);
|
issueCommand('set-env', { name: 'KUBECONFIG' }, kubeconfigPath);
|
||||||
console.log('KUBECONFIG environment variable is set');
|
console.log('KUBECONFIG environment variable is set');
|
||||||
await setContext();
|
await setContext(kubeconfigPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
run().catch(core.setFailed);
|
run().catch(core.setFailed);
|
Loading…
x
Reference in New Issue
Block a user