8000 Add strict mode option for secrets:decrypt-to-local command · symfony/symfony@8f643fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f643fb

Browse files
Add strict mode option for secrets:decrypt-to-local command
1 parent fe7f3af commit 8f643fb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Derivate `kernel.secret` from the decryption secret when its env var is not defined
99
* Make the `config/` directory optional in `MicroKernelTrait`, add support for service arguments in the
1010
invokable Kernel class, and register `FrameworkBundle` by default when the `bundles.php` file is missing
11+
* Add strict mode option for `secrets:decrypt-to-local` command
1112

1213
7.1
1314
---

src/Symfony/Bundle/FrameworkBundle/Command/SecretsDecryptToLocalCommand.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __construct(
3838
protected function configure(): void
3939
{
4040
$this
41+
->addOption('strict', 's', InputOption::VALUE_NONE, 'Returns a non-zero exit code if any errors are encountered')
4142
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force overriding of secrets that already exist in the local vault')
4243
->setHelp(<<<'EOF'
4344
The <info>%command.name%</info> command decrypts all secrets and copies them in the local vault.
@@ -47,6 +48,10 @@ protected function configure(): void
4748
When the option <info>--force</info> is provided, secrets that already exist in the local vault are overriden.
4849
4950
<info>%command.full_name% --force</info>
51+
52+
When the option <info>--strict</info> is provided, the command will return a non-zero exit code if any errors are encountered.
53+
54+
<info>%command.full_name% --strict</info>
5055
EOF
5156
)
5257
;
@@ -83,16 +88,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8388
]);
8489
}
8590

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

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

103+
if ($hadErrors && $input->getOption('strict')) {
104+
return 1;
105+
}
106+
96107
return 0;
97108
}
98109
}

0 commit comments

Comments
 (0)
0