Skip to content

Commit

Permalink
Adding better output to secrets:decrypt-to-local command
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Jan 9, 2020
1 parent 5c37ab0 commit 5039b27
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -69,12 +69,25 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$secrets = $this->vault->list(true);

$io->comment(sprintf('%d secret%s found in the vault.', count($secrets), count($secrets) !== 1 ? 's' : ''));

$skipped = 0;
if (!$input->getOption('force')) {
foreach ($this->localVault->list() as $k => $v) {
unset($secrets[$k]);
if (isset($secrets[$k])) {
++$skipped;
unset($secrets[$k]);
}
}
}

if ($skipped > 0) {
$io->warning([
sprintf('%d secret%s already overridden in the local vault and are being skipped.', $skipped, $skipped !== 1 ? 's are' : ' is'),
'Use the <info>--force</info> flag to override these.'
]);
}

foreach ($secrets as $k => $v) {
if (null === $v) {
$io->error($this->vault->getLastMessage());
Expand All @@ -83,6 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$this->localVault->seal($k, $v);
$io->note($this->localVault->getLastMessage());
}

return 0;
Expand Down

0 comments on commit 5039b27

Please sign in to comment.