-
Notifications
You must be signed in to change notification settings - Fork 11
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
OPENEUROPA-1739: Add services setup command. #104
base: master
Are you sure you want to change the base?
Conversation
5823b25
to
2186813
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somes remarks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposed solution does not implement what the issue is asking. What is proposed here can be achieved via YAML commands with a simple:
setup:services:
- { task: "process", source: "services.yml", destination: "${drupal.root}/sites/default/services.yml" }
We basically need to be able to have something like the following in the local runner.yml
:
service_parameters:
cors.config:
enabled: ${my_settings.cors.config_enabled}
And this to produce a sites/default/services.yml
with:
parameters:
service_parameters:
cors.config:
enabled: false
1939266
to
dea64da
Compare
365c822
to
88c15e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on one of our components and it works well, I've just pointed out some changes, after this round I think we can close it.
composer.json
Outdated
@@ -10,12 +10,16 @@ | |||
"consolidation/robo": "^1.4", | |||
"gitonomy/gitlib": "^1.0", | |||
"nuvoleweb/robo-config": "^0.2.1", | |||
"jakeasmith/http_build_url": "^1.0.1" | |||
"jakeasmith/http_build_url": "^1.0.1", | |||
"symfony/yaml": ">3.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be checked against Symfony's major upgrading policy, we should come up with a proper version string here.
Not that Drupal core is already on 3.4.* which should be deprecation free.
Something like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok 3.4 or 4.
composer.json
Outdated
}, | ||
"require-dev": { | ||
"openeuropa/code-review": "~1.0.0-beta3", | ||
"phpunit/phpunit": "~5.5||~6.0" | ||
}, | ||
"_readme": [ | ||
"We need require a version of 'symfony/yaml' higher then '3.1' since versions before 3.1.0 don't have dumper 'DUMP' constants available and 3.1.0 breaks permissions setup in tests." | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not needed, it's only needed when we fix dependencies when they break builds etc. not when we need a specific version because we use its API, for that having it in the requirements is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me there are two kind of dependencies. The first is when we need the package and it wouldn't be fetched if out of composer requirements. Second kind is like here when we're not really requiring the package since it was already being fetched, we're only adding it to adjust the accepted versions. For this later kind of dependencies I think it's good to understand why it was needed and to differentiate it since sometime soon we may remove it from the list, when other packages update their requirements.
Just saying, no problem, I've removed it.
file_put_contents($services_destination_file, 'parameters: false'); | ||
if ($configs['force']) { | ||
$force = ' --force'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force is either true
or not set at all, it's a valueless parameter, we can remove the inner if
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "force" option in configuration wasn't applying directly to the force option in the command, it was also being used to know if a previous service.yml
should happen.
But ok let's avoid confusion, I've changed the logic here and I think now it's clear.
settings: | ||
foo: bar | ||
- config: | ||
force: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
force: false
is not a thing, 😄 it's either there or it's not. If you want to test it for false then don't set it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
// Read given parameters. | ||
$service_parameters['parameters'] = $this->getConfig()->get('drupal.service_parameters', []); | ||
$dumper = new Dumper(2); | ||
$yaml = $dumper->dump($service_parameters, PHP_INT_MAX, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this basically prints out a YAML file as Drupal expects to let's move this two lines in a separated protected method, so it can be used on all Drupal commands.
$services_destination_file = $options['root'] . '/sites/' . $options['sites-subdir'] . '/services.yml'; | ||
|
||
$collection = []; | ||
if (true === (bool) $options['force'] || !file_exists($services_destination_file)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$options['force']
is either true
or false
, Robo internals make sure of that, we don't need casting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
$force = ''; | ||
if (isset($configs['force'])) { | ||
mkdir($services_destination_dir, 0777, true); | ||
file_put_contents($services_destination_file, 'parameters: false'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have 'parameters: false'
as part of the fixture. If more comfortable you can create a separate test for the force option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it's in fixture now.
22a76ff
to
f59b9c5
Compare
…y requiring simfony/yaml >3.1.0
…meters in config.
f59b9c5
to
fc5a85d
Compare
3e845d9
to
a5a6440
Compare
* | ||
* This command will add the configuration under service_parameters present in | ||
* runner.yml into "services.yml" file in the site directory. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to add example. Something like:
> drupal:
> service_parameters:
> session.storage.options:
> cookie_lifetime: 0
configuration: | ||
drupal: | ||
service_parameters: | ||
cors.config: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be:
cors.config:
enabled: false
Tested... Works perfectly :) |
$service_parameters['parameters'] = $this->getConfig()->get('drupal.service_parameters', []); | ||
$yaml = $this->dumpYaml($service_parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This better go to the IF statement (line 349) as they are used in the statement only.
OPENEUROPA-1739
Description
Add services setup command and tests.