-
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
Open
dxvargas
wants to merge
15
commits into
master
Choose a base branch
from
OPENEUROPA-1739
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
81da3e3
OPENEUROPA-1739: Add services setup command.
0b01fdd
OPENEUROPA-1739: Add services setup tests.
d1c58da
OPENEUROPA-1739: Add simulating test.
c2a63f9
OPENEUROPA-1739: Fix code after review.
e93ba77
OPENEUROPA-1739: Adapt to allow parameters to be set in runner file.
648fe0c
OPENEUROPA-1739: Adapt README file.
19e698e
OPENEUROPA-1739: Add replacable parameters in test.
88bc406
OPENEUROPA-1739: Add more tests.
55eda92
OPENEUROPA-1739: Improve dumped YAML format and tests.
ademarco 07ddf79
OPENEUROPA-1739: Add tests for force option.
9cea0e2
OPENEUROPA-1739: Ensure compatibility with version 2 of simfony/yaml.
beeb546
OPENEUROPA-1739: Ensure Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE exists b…
0d6d4db
OPENEUROPA-1739: Ensure services file is created without service_para…
fc5a85d
OPENEUROPA-1739: Fix code after review.
a5a6440
OPENEUROPA-1739: OPENEUROPA-1739: Add cweagans/composer-patches depen…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
use OpenEuropa\TaskRunner\Traits as TaskRunnerTraits; | ||
use Symfony\Component\Console\Event\ConsoleCommandEvent; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Yaml\Dumper; | ||
use Symfony\Component\Yaml\Yaml; | ||
|
||
/** | ||
|
@@ -307,7 +308,7 @@ public function drushSetup(array $options = [ | |
]) | ||
{ | ||
$config = $this->getConfig(); | ||
$yaml = Yaml::dump($config->get('drupal.drush')); | ||
$yaml = $this->dumpYaml($config->get('drupal.drush')); | ||
|
||
return $this->collectionBuilder()->addTaskList([ | ||
$this->taskWriteConfiguration($options['root'].'/sites/default/drushrc.php', $config)->setConfigKey('drupal.drush'), | ||
|
@@ -316,8 +317,45 @@ public function drushSetup(array $options = [ | |
} | ||
|
||
/** | ||
* Setup Drupal settings overrides. | ||
* Setup Drupal services file. | ||
* | ||
* This command will add the configuration under service_parameters present in | ||
* runner.yml into "services.yml" file in the site directory. | ||
* | ||
* @command drupal:services-setup | ||
* | ||
* @option root Drupal root. | ||
* @option sites-subdir Drupal site subdirectory. | ||
* @option force Drupal force generation of a new services.yml. | ||
* | ||
* @param array $options | ||
* | ||
* @return \Robo\Collection\CollectionBuilder | ||
*/ | ||
voidtek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public function servicesSetup(array $options = [ | ||
'root' => InputOption::VALUE_REQUIRED, | ||
'sites-subdir' => InputOption::VALUE_REQUIRED, | ||
'force' => false, | ||
]) | ||
{ | ||
// Read given parameters. | ||
$service_parameters['parameters'] = $this->getConfig()->get('drupal.service_parameters', []); | ||
$yaml = $this->dumpYaml($service_parameters); | ||
Comment on lines
+342
to
+343
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
// Set the destination file. | ||
$services_destination_file = $options['root'] . '/sites/' . $options['sites-subdir'] . '/services.yml'; | ||
|
||
$collection = []; | ||
if ($options['force'] || !file_exists($services_destination_file)) { | ||
$collection[] = $this->taskWriteToFile($services_destination_file)->append(false)->text($yaml); | ||
} | ||
|
||
return $this->collectionBuilder()->addTaskList($collection); | ||
} | ||
|
||
/** | ||
* Setup Drupal settings overrides. | ||
** | ||
* This command will: | ||
* | ||
* - Copy "default.settings.php" to "settings.php", which will be overridden if existing | ||
|
@@ -437,4 +475,16 @@ protected function processPrePostInstallCommands(array &$commands, array $tokens | |
} | ||
} | ||
} | ||
|
||
/** | ||
* Dump Yaml into file using same format as in Drupal. | ||
* | ||
* @param $yaml | ||
* @return string | ||
*/ | ||
protected function dumpYaml($yaml) | ||
{ | ||
$dumper = new Dumper(2); | ||
return $dumper->dump($yaml, PHP_INT_MAX, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
- config: | ||
runner: | | ||
my_settings: | ||
foo: bar | ||
drupal: | ||
service_parameters: | ||
settings: | ||
foo: ${my_settings.foo} | ||
expected: | ||
- contains: | | ||
parameters: | ||
settings: | ||
foo: bar | ||
dxvargas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- config: | ||
force: true | ||
services_file_content: "parameters: false" | ||
runner: | | ||
my_settings: | ||
foo: bar | ||
drupal: | ||
service_parameters: | ||
settings: | ||
foo: ${my_settings.foo} | ||
expected: | ||
- contains: | | ||
parameters: | ||
settings: | ||
foo: bar | ||
- config: | ||
services_file_content: "parameters: false" | ||
runner: | | ||
my_settings: | ||
foo: bar | ||
drupal: | ||
service_parameters: | ||
settings: | ||
foo: ${my_settings.foo} | ||
expected: | ||
- contains: "parameters: false" | ||
- config: | ||
runner: | | ||
my_settings: | ||
foo: bar | ||
drupal: [] | ||
expected: | ||
- contains: | | ||
parameters: { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -260,6 +260,16 @@ | |
- "WriteConfiguration('web/sites/default/drushrc.php'" | ||
- "File\\Write('./drush/drush.yml')" | ||
|
||
- command: 'drupal:services-setup' | ||
configuration: | ||
drupal: | ||
service_parameters: | ||
cors.config: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be:
|
||
|
||
composer: '' | ||
contains: | ||
- "File\\Write('build/sites/default/services.yml'" | ||
|
||
- command: 'drupal:settings-setup' | ||
configuration: [] | ||
composer: '' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: