10000 feature #57670 [FrameworkBundle] Add `exit` option to `secrets:decryp… · symfony/symfony@32f601a · GitHub
[go: up one dir, main page]

Skip to content

Commit 32f601a

Browse files
feature #57670 [FrameworkBundle] Add exit option to secrets:decrypt-to-local command (dciprian-petrisor)
This PR was squashed before being merged into the 7.2 branch. Discussion ---------- [FrameworkBundle] Add `exit` option to `secrets:decrypt-to-local` command | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | Fix #57539 | License | MIT <!-- This merge requests adds a simple 'strict' option to the secrets:decrypt-to-local command which will spit out a non-zero exit code whenever errors happen during reading of a secret. --> Commits ------- 567b450 [FrameworkBundle] Add `exit` option to `secrets:decrypt-to-local` command
2 parents 74df71a + 567b450 commit 32f601a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
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 `exit` option for `secrets:decrypt-to-local` command
1112

10000 1213
7.1
1314
---

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,20 @@ public function __construct(
3838
protected function configure(): void
3939
{
4040
$this
41+
->addOption('exit', null, 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.
4445
4546
<info>%command.full_name%</info>
4647
47-
When the option <info>--force</info> is provided, secrets that already exist in the local vault are overriden.
48+
When the <info>--force</info> option is provided, secrets that already exist in the local vault are overriden.
4849
4950
<info>%command.full_name% --force</info>
51+
52+
When the <info>--exit</info> option is provided, the command will return a non-zero exit code if any errors are encountered.
53+
54+
<info>%command.full_name% --exit</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('exit')) {
104+
return 1;
105+
}
106+
96107
return 0;
97108
}
98109
}

0 commit comments

Comments
 (0)
0