Skip to content
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

Environment variables configurable thru yaml file #394

Conversation

vkerkhoff
Copy link
Contributor

@vkerkhoff vkerkhoff commented Dec 12, 2018

Description

Make the RELATIONSHIP/ROUTES/APPLICATION and VARIABLES configurable thru the .magento.app.yaml file to allow users to specify an alternative variable name that is used to get the configuration value.

An example is the use of the ECE tools on a native Platform.sh environment where the variables used are prefixed by PLATFORM instead of MAGENTO_CLOUD.

Manual testing scenarios

Add for example the following settings in .magento.env.yaml
stage:
global:
ENV_RELATIONSHIPS: "PLATFORM_RELATIONSHIPS"
ENV_ROUTES: "PLATFORM_ROUTES"
ENV_APPLICATION: "PLATFORM_APPLICATION"
ENV_VARIABLES: "PLATFORM_VARIABLES"

No automated tests yet, if feature idea is approved I will add them

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

vkerkhoff and others added 2 commits December 12, 2018 07:42
Make the RELATIONSHIP/ROUTES/APPLICATION and VARIABLES configurable thru the .magento.app.yaml file to allow users to specify an alternative variable name that is used to get the configuration value.

An example is the use of the ECE tools on a native Platform.sh environment where the variables used are prefixed by PLATFORM instead of MAGENTO_CLOUD.
@magento-cicd2
Copy link

magento-cicd2 commented Dec 12, 2018

CLA assistant check
All committers have signed the CLA.

@shiftedreality shiftedreality added the Progress: review PR/Issue status label Dec 12, 2018
Copy link
Member

@shiftedreality shiftedreality left a comment

Choose a reason for hiding this comment

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

@vkerkhoff thank you for your contribution!
I left 1 comment regarding location of those new varaiables.

src/Config/StageConfigInterface.php Show resolved Hide resolved
@shiftedreality
Copy link
Member

Please also fix failed tests

Added extra section in the .magento.env.yaml that allows storing the new variable options
Created a reader/processor for getting the options from the system section
@vkerkhoff
Copy link
Contributor Author

Moved the environment variables options to a new system => variables section in the .magento.env.yaml file.

Let me know if this setup fits the design wanted so I can also add the tests and check why some tests fail.

@shiftedreality
Copy link
Member

@vkerkhoff this looks good, thanks!
The only comment I have is about inheritance in interface VariablesInterface extends SystemConfigInterface

It looks like SystemConfigInterface is independent from stage, so we can avoid this inheritance.

@vkerkhoff
Copy link
Contributor Author

vkerkhoff commented Dec 12, 2018

@shiftedreality Thanks! I added the SystemConfigInterface so it's possible to add extra sections under the system as like with the stages. I now removed the VariablesInterface and only use the SystemConfigInterface

/**
* Option for enabling merging given configuration with default configuration
*/
const OPTION_MERGE = '_merge';
Copy link
Member

Choose a reason for hiding this comment

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

This seems not necessary in system config

Copy link
Contributor

@billygilbert billygilbert left a comment

Choose a reason for hiding this comment

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

Please also update the dist/.magento.env.yaml file: https://github.com/magento/ece-tools/blob/develop/dist/.magento.env.yaml

Also for completeness, please also move MAGENTO_CLOUD_MODE and MAGENTO_CLOUD_ENVIRONMENT

Thanks for the contribution!!!

src/Config/Environment.php Outdated Show resolved Hide resolved
src/Config/Environment.php Show resolved Hide resolved
src/Config/Environment.php Outdated Show resolved Hide resolved
src/Config/SystemConfigInterface.php Outdated Show resolved Hide resolved
Fixed comments from code review (doc blocks and code styling)
Added MAGENTO_CLOUD_MODE and MAGENTO_CLOUD_ENVIRONMENT variables to be configurable
Updated Unit Tests to cover changes
@vkerkhoff
Copy link
Contributor Author

@billygilbert I updated the code with your comments and added some documentation in the dist/.magento.env.yaml file.

@shiftedreality I added/fixed the unit tests, the only message I don't see how to resolve is the code coverage, if this needs some changes please give some input on what to add.

@shiftedreality
Copy link
Member

@vkerkhoff code coverage is increasing by unit tests. Looks like it's already green

@vkerkhoff
Copy link
Contributor Author

@shiftedreality Thanks, I see it indeed. Funny that if I run the test locally I get 94.69% code coverage.

@shiftedreality
Copy link
Member

shiftedreality commented Dec 13, 2018

@vkerkhoff I observed the same and do not have a clear explanation of this. Looks like it somehow depends on OS(I use Mac).
Thanks for fixing the tests, I will proceed with QA.

# system: #
# variables: #
# ENV_ENVIRONMENT: "MAGENTO_CLOUD_ENVIRONMENT" #
#######################################################################################################################
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

src/Config/Stage/Deploy.php Outdated Show resolved Hide resolved
src/Config/Stage/Deploy.php Outdated Show resolved Hide resolved
src/Config/Stage/Deploy.php Outdated Show resolved Hide resolved
@vkerkhoff
Copy link
Contributor Author

@bbatsche Thanks, I updated the requested changes

@shiftedreality
Copy link
Member

QA approved

@shiftedreality shiftedreality added Progress: accept PR/issue status and removed Progress: testing in progress PR/issue status Progress: review PR/Issue status labels Dec 14, 2018
@shiftedreality shiftedreality merged commit a0791c2 into magento:develop Dec 14, 2018
@shiftedreality
Copy link
Member

@vkerkhoff thank you for your contribution!

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

Successfully merging this pull request may close these issues.

None yet

7 participants