Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle] Add resolve-env option to debug:config command #46821

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
merged 1 commit into from
Jul 21, 2022

Conversation

alexandre-daubois
Copy link
Member

@alexandre-daubois alexandre-daubois commented Jul 1, 2022

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #40582
License MIT
Doc PR NA

Add --resolve-env option to debug:config command to display actual values of environment variables in dumped configuration.

This main purpose of this command is debugging as its name suggests. In order to help the developer to debug its configuration, it is convenient to display the actual value of environment variables present in the dumped configuration, instead of placeholders.

Here is the result:

$ symfony console debug:config framework | grep secret
    secret: '%env(APP_SECRET)%'
    secrets:
        vault_directory: '/home/alexandredaubois/(...)/config/secrets/%env(default:kernel.environment:APP_RUNTIME_ENV)%'

$ symfony console debug:config framework --resolve-env | grep secret
    secret: 90d83502629d64dec4cd6e33c9b31267
    secrets:
        vault_directory: /home/alexandredaubois/(...)/config/secrets/dev

@carsonbot
Copy link

Hey!

I think @jack-worman has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice feature. It simplifies debug of env var processing.

Thanks to it, I found something that looks like a bug.

$ SYMFONY_DECRYPTION_SECRET=Zm9v bin/console debug:config framework secrets.decryption_env_var --resolve-env 

Current configuration for "framework.secrets.decryption_env_var"
================================================================

'base64:default::SYMFONY_DECRYPTION_SECRET'

@alexandre-daubois
Copy link
Member Author

Didn't think of this case @GromNaN, thank you! I'm taking a look at it soon.

@GromNaN
Copy link
Member

GromNaN commented Jul 13, 2022

That seems to be a special feature made by @nicolas-grekas. The value is correctly resolved by the command from a config pov.

if ($config['decryption_env_var']) {
if (!preg_match('/^(?:[-.\w\\\\]*+:)*+\w++$/', $config['decryption_env_var'])) {
throw new InvalidArgumentException(sprintf('Invalid value "%s" set as "decryption_env_var": only "word" characters are allowed.', $config['decryption_env_var']));
}
if (ContainerBuilder::willBeAvailable('symfony/string', LazyString::class, ['symfony/framework-bundle'])) {
$container->getDefinition('secrets.decryption_key')->replaceArgument(1, $config['decryption_env_var']);
} else {
$container->getDefinition('secrets.vault')->replaceArgument(1, "%env({$config['decryption_env_var']})%");
$container->removeDefinition('secrets.decryption_key');
}

@GromNaN
Copy link
Member

GromNaN commented Jul 13, 2022

There is a conflict in the changelog, can you rebase please?

@alexandre-daubois
Copy link
Member Author

Very interesting, thank you for the investigation Jérôme!

Also, the rebase is done 🙂

@fabpot
Copy link
Member

fabpot commented Jul 21, 2022

Thank you @alexandre-daubois.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to resolve environment variables in debug:config
5 participants