From da71d5cb54dbd7785f5a79e7b4e53ffeb51a2a25 Mon Sep 17 00:00:00 2001 From: Vincent Post Date: Thu, 11 Nov 2021 18:27:30 +0100 Subject: [PATCH] build --- dist/index.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/dist/index.js b/dist/index.js index e8d24fc..67007d3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1328,18 +1328,24 @@ async function getClientToken(client, method, path, payload) { core.debug(`Retrieving Vault Token from v1/auth/${path}/login endpoint`); - /** @type {import('got').Response} */ - const response = await client.post(`v1/auth/${path}/login`, options); - if (response && response.body && response.body.auth && response.body.auth.client_token) { - core.debug('✔ Vault Token successfully retrieved'); - - core.startGroup('Token Info'); - core.debug(`Operating under policies: ${JSON.stringify(response.body.auth.policies)}`); - core.debug(`Token Metadata: ${JSON.stringify(response.body.auth.metadata)}`); - core.endGroup(); - - return response.body.auth.client_token; - } else { + + try { + /** @type {import('got').Response} */ + const response = await client.post(`v1/auth/${path}/login`, options); + if (response && response.body && response.body.auth && response.body.auth.client_token) { + core.debug('✔ Vault Token successfully retrieved'); + + core.startGroup('Token Info'); + core.debug(`Operating under policies: ${JSON.stringify(response.body.auth.policies)}`); + core.debug(`Token Metadata: ${JSON.stringify(response.body.auth.metadata)}`); + core.endGroup(); + + return response.body.auth.client_token; + } else { + throw Error(`Unable to retrieve token from ${method}'s login endpoint.`); + } + } catch (error) { + core.debug(error.response.body); throw Error(`Unable to retrieve token from ${method}'s login endpoint.`); } }