Implemented wildcard selector (based on #238)#488
Implemented wildcard selector (based on #238)#488maxcoulombe merged 18 commits intohashicorp:mainfrom
Conversation
Temp action to allow manual build
There was a problem hiding this comment.
Hey @keattang , thanks for picking up the work on this, this is super appreciated.
The changes look good. My only suggestion is regarding test coverage so I'll merge the PR as is and adjust the test in a separate PR when we prepare the release to spare you the back-and-forth.
Cheers and thanks again!
|
|
||
| expect(core.exportVariable).toBeCalledWith('GROUP_SECRET', 'SUPERSECRET'); | ||
| }); | ||
|
|
There was a problem hiding this comment.
One small suggestion would be to setup a secret with multiple keys to validate that the wildcard operator does indeed picks up all the sub-keys.
For example on l.22:
await got(`${vaultUrl}/v1/secret/data/test`, {
method: 'POST',
headers: {
'X-Vault-Token': vaultToken,
},
json: {
data: {
secret: 'SUPERSECRET',
secret_2: 'SUPERSECRET_2',
},
},
});
|
|
||
| expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERCUSTOMSECRET'); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Then you can modify the test to cover not only that the wildcard is valid & the prefix gets applied, but that multiple sub-keys get picked up as well as desired:
it('get wildcard secrets', async () => {
mockInput(`secret/data/test * ;`);
await exportSecrets();
expect(core.exportVariable).toBeCalledTimes(2);
expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET');
expect(core.exportVariable).toBeCalledWith('SECRET_2', 'SUPERSECRET_2');
});
it('get wildcard secrets with name prefix', async () => {
mockInput(`secret/data/test * | GROUP_ ;`);
await exportSecrets();
expect(core.exportVariable).toBeCalledTimes(2);
expect(core.exportVariable).toBeCalledWith('GROUP_SECRET', 'SUPERSECRET');
expect(core.exportVariable).toBeCalledWith('GROUP_SECRET_2', 'SUPERSECRET_2');
});
|
|
||
| expect(core.exportVariable).toBeCalledWith('GROUP_SECRET', 'CUSTOMSECRET_IN_NAMESPACE'); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Same here, would be great to have a multi-value secret as part of the tests.
|
Yep sounds great! Thanks for getting this merged in! |
This PR builds upon the work done in #238 and implements all of the requested code review changes.