8000 [FrameworkBundle] Add `exit` option to `secrets:decrypt-to-local` command by dciprian-petrisor · Pull Request #57670 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Add exit option to secrets:decrypt-to-local command #57670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CHANGELOG
* Derivate `kernel.secret` from the decryption secret when its env var is not defined
* Make the `config/` directory optional in `MicroKernelTrait`, add support for service arguments in the
invokable Kernel class, and register `FrameworkBundle` by default when the `bundles.php` file is missing
* Add `exit` option for `secrets:decrypt-to-local` command

7.1
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,20 @@ public function __construct(
protected function configure(): void
{
$this
->addOption('exit', null, InputOption::VALUE_NONE, 'Returns a non-zero exit code if any errors are encountered')
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force overriding of secrets that already exist in the local vault')
->setHelp(<<<'EOF'
The <info>%command.name%</info> command decrypts all secrets and copies them in the local vault.

<info>%command.full_name%</info>

When the option <info>--force</info> is provided, secrets that already exist in the local vault are overriden.
When the <info>--force</info> option is provided, secrets that already exist in the local vault are overriden.

<info>%command.full_name% --force</info>

When the <info>--exit</info> option is provided, the command will return a non-zero exit code if any errors are encountered.

<info>%command.full_name% --exit</info>
EOF
)
;
Expand Down Expand Up @@ -83,16 +88,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int
]);
}

$hadErrors = false;
foreach ($secrets as $k => $v) {
if (null === $v) {
$io->error($this->vault->getLastMessage() ?? \sprintf('Secret "%s" has been skipped as there was an error reading it.', $k));
$hadErrors = true;
continue;
}

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

if ($hadErrors && $input->getOption('exit')) {
return 1;
}

return 0;
}
}
Loading
0