mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-09 16:16:55 +00:00
feat: change how we export secrets
This commit is contained in:
parent
c0f6da16c2
commit
13eebbc4e5
2 changed files with 6 additions and 5 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
// @ts-check
|
|
||||||
// @ts-ignore
|
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
|
const command = require('@actions/core/lib/command');
|
||||||
const got = require('got');
|
const got = require('got');
|
||||||
|
|
||||||
async function exportSecrets() {
|
async function exportSecrets() {
|
||||||
|
|
@ -22,7 +21,8 @@ async function exportSecrets() {
|
||||||
const vaultKeyData = parsedResponse.data;
|
const vaultKeyData = parsedResponse.data;
|
||||||
const versionData = vaultKeyData.data;
|
const versionData = vaultKeyData.data;
|
||||||
const value = versionData[dataKey];
|
const value = versionData[dataKey];
|
||||||
core.exportSecret(outputName, value);
|
command.issue('add-mask', value);
|
||||||
|
core.exportVariable(outputName, `${value}`);
|
||||||
core.debug(`✔ ${keyPath} => ${outputName}`);
|
core.debug(`✔ ${keyPath} => ${outputName}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
jest.mock('got');
|
jest.mock('got');
|
||||||
jest.mock('@actions/core');
|
jest.mock('@actions/core');
|
||||||
|
jest.mock('@actions/core/lib/command');
|
||||||
|
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
const got = require('got');
|
const got = require('got');
|
||||||
|
|
@ -104,7 +105,7 @@ describe('exportSecrets', () => {
|
||||||
|
|
||||||
await exportSecrets();
|
await exportSecrets();
|
||||||
|
|
||||||
expect(core.exportSecret).toBeCalledWith('KEY', 1);
|
expect(core.exportVariable).toBeCalledWith('KEY', 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('mapped key retrieval', async () => {
|
it('mapped key retrieval', async () => {
|
||||||
|
|
@ -115,6 +116,6 @@ describe('exportSecrets', () => {
|
||||||
|
|
||||||
await exportSecrets();
|
await exportSecrets();
|
||||||
|
|
||||||
expect(core.exportSecret).toBeCalledWith('TEST_NAME', 1);
|
expect(core.exportVariable).toBeCalledWith('TEST_NAME', 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Loading…
Reference in a new issue