mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-09 16:16:55 +00:00
feat(namespace): handle request on vault namespace
This commit is contained in:
parent
0104a02854
commit
7c7d7f1fa0
2 changed files with 11 additions and 3 deletions
|
|
@ -5,17 +5,22 @@ const got = require('got');
|
|||
async function exportSecrets() {
|
||||
const vaultUrl = core.getInput('url', { required: true });
|
||||
const vaultToken = core.getInput('token', { required: true });
|
||||
const vaultNamespace = core.getInput('namespace', { required: false });
|
||||
|
||||
const secretsInput = core.getInput('secrets', { required: true });
|
||||
const secrets = parseSecretsInput(secretsInput);
|
||||
|
||||
for (const secret of secrets) {
|
||||
const { secretPath, outputName, secretKey } = secret;
|
||||
const result = await got(`${vaultUrl}/v1/secret/data/${secretPath}`, {
|
||||
var headers = {
|
||||
headers: {
|
||||
'X-Vault-Token': vaultToken
|
||||
}};
|
||||
if (vaultNamespace != null){
|
||||
headers.headers["X-Vault-Namespace"] = vaultNamespace
|
||||
}
|
||||
});
|
||||
|
||||
const result = await got(`${vaultUrl}/v1/secret/data/${secretPath}`, headers);
|
||||
|
||||
const parsedResponse = JSON.parse(result.body);
|
||||
const vaultKeyData = parsedResponse.data;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ inputs:
|
|||
secrets:
|
||||
description: 'A semicolon-separated list of secrets to retrieve. These will automatically be converted to environmental variable keys. See README for more details'
|
||||
required: true
|
||||
namespace:
|
||||
description: 'The Vault namespace to request, by default it request root'
|
||||
required: false
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
|
|
|
|||
Loading…
Reference in a new issue