changed getArcKubeconfig from promise to async function
This commit is contained in:
parent
b903fa8c1a
commit
f6361247fd
@ -223,8 +223,8 @@ describe('Testing all functions.', () => {
|
||||
jest.spyOn(arc,'sleep').mockImplementation();
|
||||
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {});
|
||||
jest.spyOn(core, 'exportVariable').mockImplementation(() => {});
|
||||
await arc.getArcKubeconfig();
|
||||
//expect(core.getInput).toBeCalledTimes(4);
|
||||
expect(await arc.getArcKubeconfig());
|
||||
expect(core.getInput).toBeCalledTimes(4);
|
||||
expect(io.which).toHaveBeenCalledWith("az",true);
|
||||
expect(arc.executeAzCliCommand).toHaveBeenNthCalledWith(1,`account show`, false);
|
||||
expect(arc.executeAzCliCommand).toHaveBeenNthCalledWith(2,`extension remove -n connectedk8s`, false);
|
||||
|
@ -8,7 +8,7 @@ var azPath: string;
|
||||
|
||||
const kubeconfig_timeout = 120;//timeout in seconds
|
||||
|
||||
export async function getArcKubeconfig(): Promise<string> {
|
||||
export async function getArcKubeconfig() {
|
||||
try {
|
||||
let method = core.getInput('method');
|
||||
if (method != 'service-account' && method != 'service-principal'){
|
||||
@ -59,8 +59,8 @@ export async function getArcKubeconfig(): Promise<string> {
|
||||
fs.chmodSync(kubeconfigPath, '600');
|
||||
core.exportVariable('KUBECONFIG', kubeconfigPath);
|
||||
console.log('KUBECONFIG environment variable is set');
|
||||
} catch (ex) {
|
||||
return Promise.reject(ex);
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,9 +107,12 @@ export async function run() {
|
||||
let kubeconfig = '';
|
||||
const cluster_type = core.getInput('cluster-type', { required: true });
|
||||
if (cluster_type == 'arc') {
|
||||
await getArcKubeconfig().catch(ex => {
|
||||
try{
|
||||
await getArcKubeconfig();
|
||||
}
|
||||
catch (ex){
|
||||
throw new Error('Error: Could not get the KUBECONFIG for arc cluster: ' + ex);
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
const runnerTempDirectory = process.env['RUNNER_TEMP']; // Using process.env until the core libs are updated
|
||||
|
Loading…
x
Reference in New Issue
Block a user