mirror of
https://github.com/hashicorp/vault-action.git
synced 2026-04-07 12:39:26 +00:00
print vault error message on authentication failure (#409)
Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
This commit is contained in:
parent
b08bc4993d
commit
7318a98db7
4 changed files with 9288 additions and 9261 deletions
12
src/auth.js
12
src/auth.js
|
|
@ -2,6 +2,7 @@
|
|||
const core = require('@actions/core');
|
||||
const rsasign = require('jsrsasign');
|
||||
const fs = require('fs');
|
||||
const { default: got } = require('got');
|
||||
|
||||
const defaultKubernetesTokenPath = '/var/run/secrets/kubernetes.io/serviceaccount/token'
|
||||
/***
|
||||
|
|
@ -109,7 +110,16 @@ 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);
|
||||
let response;
|
||||
try {
|
||||
response = await client.post(`v1/auth/${path}/login`, options);
|
||||
} catch (err) {
|
||||
if (err instanceof got.HTTPError) {
|
||||
throw Error(`failed to retrieve vault token. code: ${err.code}, message: ${err.message}, vaultResponse: ${JSON.stringify(err.response.body)}`)
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
if (response && response.body && response.body.auth && response.body.auth.client_token) {
|
||||
core.debug('✔ Vault Token successfully retrieved');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue