Skip to content

Commit

Permalink
MCLOUD-6294: If Mysql set as DB docker set up 3 split DB by default (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhen Miroshnychenko authored Jun 24, 2020
1 parent 3624506 commit 12be27b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
46 changes: 35 additions & 11 deletions src/Config/Source/CliSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,29 @@ class CliSource implements SourceInterface
* @var array
*/
private static $enableOptionsMap = [
self::OPTION_PHP => [self::PHP],
self::OPTION_PHP => [
self::PHP => true
],
self::OPTION_DB => [
self::SERVICES_DB,
self::SERVICES_DB_QUOTE,
self::SERVICES_DB_SALES
self::SERVICES_DB => true,
self::SERVICES_DB_QUOTE => false,
self::SERVICES_DB_SALES => false
],
self::OPTION_NGINX => [
self::SERVICES_NGINX => true
],
self::OPTION_REDIS => [
self::SERVICES_REDIS => true
],
self::OPTION_ES => [
self::SERVICES_ES => true
],
self::OPTION_NODE => [
self::SERVICES_NODE => true
],
self::OPTION_RABBIT_MQ => [
self::SERVICES_RMQ => true
],
self::OPTION_NGINX => [self::SERVICES_NGINX],
self::OPTION_REDIS => [self::SERVICES_REDIS],
self::OPTION_ES => [self::SERVICES_ES],
self::OPTION_NODE => [self::SERVICES_NODE],
self::OPTION_RABBIT_MQ => [self::SERVICES_RMQ],
];

/**
Expand Down Expand Up @@ -128,13 +140,25 @@ public function read(): Repository
]);
}

/**
* Loop through options to enable services.
* Each option may have one or more dependencies.
*
* The dependencies must be in sync.
* The dependencies which does not change status, must keep their default status.
*/
foreach (self::$enableOptionsMap as $option => $services) {
if ($value = $this->input->getOption($option)) {
foreach ($services as $service) {
foreach ($services as $service => $status) {
$repository->set([
$service . '.enabled' => true,
$service . '.version' => $value
]);

if ($status === true) {
$repository->set([
$service . '.enabled' => true
]);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Unit/Config/Dist/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function testGenerate(): void
->willReturn('magento2.docker');
$config->expects($this->once())
->method('getPort')
->willReturn(80);
->willReturn('80');
$this->envReaderMock->expects($this->once())
->method('read')
->willReturn([]);
Expand Down

0 comments on commit 12be27b

Please sign in to comment.