Skip to content

Commit ee58c2a

Browse files
[FrameworkBundle] Fix secrets:encrypt-from-local
1 parent 6066342 commit ee58c2a

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

Command/SecretsEncryptFromLocalCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6161
}
6262

6363
foreach ($this->vault->list(true) as $name => $value) {
64-
$localValue = $this->localVault->reveal($name);
64+
if (null === $localValue = $this->localVault->reveal($name)) {
65+
continue;
66+
}
6567

66-
if (null !== $localValue && $value !== $localValue) {
68+
if ($value !== $localValue) {
6769
$this->vault->seal($name, $localValue);
68-
} elseif (null !== $message = $this->localVault->getLastMessage()) {
69-
$io->error($message);
70-
71-
return 1;
70+
$io->note($this->vault->getLastMessage());
7271
}
7372
}
7473

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private function addSecretsSection(ArrayNodeDefinition $rootNode): void
204204
->canBeDisabled()
205205
->children()
206206
->scalarNode('vault_directory')->defaultValue('%kernel.project_dir%/config/secrets/%kernel.runtime_environment%')->cannotBeEmpty()->end()
207-
->scalarNode('local_dotenv_file')->defaultValue('%kernel.project_dir%/.env.%kernel.environment%.local')->end()
207+
->scalarNode('local_dotenv_file')->defaultValue('%kernel.project_dir%/.env.%kernel.runtime_environment%.local')->end()
208208
->scalarNode('decryption_env_var')->defaultValue('base64:default::SYMFONY_DECRYPTION_SECRET')->end()
209209
->end()
210210
->end()

Tests/Command/SecretsEncryptFromLocalCommandTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testDoesNotSealIfSameValue()
9292
$this->assertSame('same-value', $revealed);
9393
}
9494

95-
public function testFailsIfLocalSecretIsMissing()
95+
public function testStillSucceedsIfLocalSecretIsMissing()
9696
{
9797
$vault = new SodiumVault($this->vaultDir);
9898
$vault->generateKeys();
@@ -105,7 +105,8 @@ public function testFailsIfLocalSecretIsMissing()
105105
$command = new SecretsEncryptFromLocalCommand($vault, $localVault);
106106
$tester = new CommandTester($command);
107107

108-
$this->assertSame(1, $tester->execute([]));
109-
$this->assertStringContainsString('Secret "MISSING_IN_LOCAL" not found', $tester->getDisplay());
108+
$this->assertSame(0, $tester->execute([]));
109+
$revealed = $vault->reveal('MISSING_IN_LOCAL');
110+
$this->assertSame('prod-only', $revealed);
110111
}
111112
}

Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor
856856
'secrets' => [
857857
'enabled' => true,
858858
'vault_directory' => '%kernel.project_dir%/config/secrets/%kernel.runtime_environment%',
859-
'local_dotenv_file' => '%kernel.project_dir%/.env.%kernel.environment%.local',
859+
'local_dotenv_file' => '%kernel.project_dir%/.env.%kernel.runtime_environment%.local',
860860
'decryption_env_var' => 'base64:default::SYMFONY_DECRYPTION_SECRET',
861861
],
862862
'http_cache' => [

0 commit comments

Comments
 (0)