Add exportConfigEnv option

This setting this will export `VAULT_ADDR`, `VAULT_SKIP_VERIFY`, and
`VAULT_NAMESPACE` when set in the action's configuration.
This commit is contained in:
Pieter Lexis 2022-10-06 13:58:09 +02:00
parent 7d98524254
commit 9c41d44553
No known key found for this signature in database
GPG key ID: B6ED640F21BF69E3
5 changed files with 59 additions and 0 deletions

View file

@ -109,6 +109,23 @@ describe('integration', () => {
expect(core.exportVariable).toBeCalledWith('OTHERSECRET', 'OTHERCUSTOMSECRET_IN_NAMESPACE');
});
it('export Vault config env', async () => {
mockExportConfigEnv("true");
await exportSecrets();
expect(core.exportVariable).toBeCalledTimes(3);
expect(core.exportVariable).toBeCalledWith('VAULT_ADDR', vaultUrl);
expect(core.exportVariable).toBeCalledWith('VAULT_SKIP_VERIFY', 'false');
expect(core.exportVariable).toBeCalledWith('VAULT_NAMESPACE', vaultNamespace);
});
it('not export Vault config env', async () => {
mockExportConfigEnv("false");
await exportSecrets();
expect(core.exportVariable).toBeCalledTimes(0);
});
});
describe('authenticate with approle', () => {
@ -289,3 +306,9 @@ function mockInput(secrets) {
.calledWith('secrets', expect.anything())
.mockReturnValueOnce(secrets);
}
function mockExportConfigEnv(doExport) {
when(core.getInput)
.calledWith('exportConfEnv', expect.anything())
.mockReturnValueOnce(doExport);
}