Skip to content

[DI] Add select specific key from an array resolved env var documentation #9734

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

Closed
bobvandevijver opened this issue May 4, 2018 · 4 comments

Comments

@bobvandevijver
Copy link
Contributor

bobvandevijver commented May 4, 2018

In symfony/symfony#27157, the key processor is added. This should also be documented, but currently there is no documentation yet (see #8382, with #9507 as work-in-progress MR).

When the initial documentation is merged, the new key processor should also be added

@xabbuh
Copy link
Member

xabbuh commented May 6, 2018

Did you mean symfony/symfony#27157?

@bobvandevijver
Copy link
Contributor Author

I did indeed, good catch!

symfony-splitter pushed a commit to symfony/dependency-injection that referenced this issue May 21, 2018
…r (bobvandevijver)

This PR was squashed before being merged into the 4.2-dev branch (closes #27157).

Discussion
----------

[DI] Select specific key from an array resolved env var

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | Discussed in #25643    <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#9734 <!-- required for new features -->

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

As discussed in #25643, it would be convenient to have an key processor for environment variables which have been read from for example a JSON file.

The main advantage of this feature lies in specifying a single file for your secrets, that can be directly used in your configuration, without leaking them into your env.

## Example
**.secrets.json**
```json
{
  "database_password": "xxx"
}
```
**.env**
```env
APP_SECRETS=/opt/application/.secrets.json
DATABASE_URL=mysql://myuser:%database_password%@localhost:3306/mydb
```
**services.yaml**
```yaml
parameters:
  database_password: '%env(key:database_password:json:file:APP_SECRETS)%'
```

This example configuration will result in a `database_password` parameter being filled with `xxx`, and due to Doctrine defaults, the database url will be resolved with the correct password.

Commits
-------

42186a2bac [DI] Select specific key from an array resolved env var
nicolas-grekas added a commit to symfony/symfony that referenced this issue May 21, 2018
…r (bobvandevijver)

This PR was squashed before being merged into the 4.2-dev branch (closes #27157).

Discussion
----------

[DI] Select specific key from an array resolved env var

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | Discussed in #25643    <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#9734 <!-- required for new features -->

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->

As discussed in #25643, it would be convenient to have an key processor for environment variables which have been read from for example a JSON file.

The main advantage of this feature lies in specifying a single file for your secrets, that can be directly used in your configuration, without leaking them into your env.

## Example
**.secrets.json**
```json
{
  "database_password": "xxx"
}
```
**.env**
```env
APP_SECRETS=/opt/application/.secrets.json
DATABASE_URL=mysql://myuser:%database_password%@localhost:3306/mydb
```
**services.yaml**
```yaml
parameters:
  database_password: '%env(key:database_password:json:file:APP_SECRETS)%'
```

This example configuration will result in a `database_password` parameter being filled with `xxx`, and due to Doctrine defaults, the database url will be resolved with the correct password.

Commits
-------

42186a2 [DI] Select specific key from an array resolved env var
@nicolas-grekas
Copy link
Member

@bobvandevijver would you mind sending a PR now that this is merged?

@HeahDude HeahDude removed the Waiting Code Merge Docs for features pending to be merged label Jul 1, 2018
@HeahDude HeahDude modified the milestones: next, 4.2 Jul 1, 2018
@bobvandevijver
Copy link
Contributor Author

bobvandevijver commented Jul 2, 2018

@nicolas-grekas I wouldn't, I've put it on my list to do this soon!

javiereguiluz added a commit that referenced this issue Jul 4, 2018
…guiluz)

This PR was merged into the master branch.

Discussion
----------

Added key env processor to docs

Not much more to say, this is documenting the feature added in symfony/symfony#27157.

Fixes #9734.

Commits
-------

9c91cf1 Reworded and added other config formats
1d72bc2 Added key env processor to docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants