diff --git a/__tests__/run.test.ts b/__tests__/run.test.ts index 3dc1ab3f..8e35f048 100644 --- a/__tests__/run.test.ts +++ b/__tests__/run.test.ts @@ -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); diff --git a/src/arc-login.ts b/src/arc-login.ts index dda28e3d..1d9a3a0b 100644 --- a/src/arc-login.ts +++ b/src/arc-login.ts @@ -8,7 +8,7 @@ var azPath: string; const kubeconfig_timeout = 120;//timeout in seconds -export async function getArcKubeconfig(): Promise { +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 { 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); } } diff --git a/src/login.ts b/src/login.ts index 79820c9c..a2d751aa 100644 --- a/src/login.ts +++ b/src/login.ts @@ -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