Skip to content

Commit

Permalink
feat: add option to optionally specify output file to write to
Browse files Browse the repository at this point in the history
some setups (calls from npm-scripts etc) will pollute stdout, and hence we need an alternative way
to get the encrypted content into a file.
  • Loading branch information
nutgaard committed Jun 13, 2024
1 parent 6a6b290 commit 812d78c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/commands/wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export const wrapCommand: Command = program
.createCommand('wrap')
.description('Download secrets, and encrypt environment')
.argument('<configfile>', 'Path to dktp yaml file')
.argument('[outputfile]', 'Path to encrypted vault file')
.option('-c, --container <container_name>', 'Container name to process (defaults to create a combined env file)')
.option('-e, --env <env_file>', 'Envfile to use for interpolation')
.action(async (configfile, options) => {
.action(async (configfile, outputfile, options) => {
logger.info('Verifying AZ CLI status');
const azcli = await AZCli.assertLogin();
exitInvariant(azcli, `Could not resolve AZ cli, or you're not logged in`);
Expand Down Expand Up @@ -67,5 +68,9 @@ export const wrapCommand: Command = program
logger.info(`Creating vault-env content`);
const encryptedContent = await Encryption.encrypt(password, envFileContent);

console.log(JSON.stringify(encryptedContent, null, 2));
if (outputfile) {
getFS().write(outputfile, JSON.stringify(encryptedContent, null, 2));
} else {
console.log(JSON.stringify(encryptedContent, null, 2));
}
});

0 comments on commit 812d78c

Please sign in to comment.