mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-14 18:13:45 +00:00
build
This commit is contained in:
parent
10ec29c5fb
commit
da71d5cb54
1 changed files with 18 additions and 12 deletions
26
dist/index.js
vendored
26
dist/index.js
vendored
|
|
@ -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<VaultLoginResponse>} */
|
||||
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();
|
||||
try {
|
||||
/** @type {import('got').Response<VaultLoginResponse>} */
|
||||
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');
|
||||
|
||||
return response.body.auth.client_token;
|
||||
} else {
|
||||
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.`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue