Skip to content

Commit 2a2cf2e

Browse files
authored
Merge pull request #93 from magento-commerce/develop
MCLOUD-9083: Release ece-tools 2002.1.11 and MCC 1.0.11
2 parents d980a6e + 658164e commit 2a2cf2e

File tree

16 files changed

+375
-48
lines changed

16 files changed

+375
-48
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/ece-tools",
33
"description": "Provides tools to build and deploy Magento 2 Enterprise Edition",
44
"type": "magento2-component",
5-
"version": "2002.1.10",
5+
"version": "2002.1.11",
66
"license": "OSL-3.0",
77
"repositories": {
88
"repo.magento.com": {

src/Command/Dev/GenerateSchemaError.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\MagentoCloud\Command\Dev;
99

10+
use Magento\MagentoCloud\Cli;
1011
use Magento\MagentoCloud\Filesystem\Driver\File;
1112
use Magento\MagentoCloud\Filesystem\FileList;
1213
use Symfony\Component\Console\Command\Command;
@@ -79,14 +80,11 @@ protected function configure(): void
7980
}
8081

8182
/**
82-
* @param InputInterface $input
83-
* @param OutputInterface $output
84-
* @return int|void
85-
* @throws \Magento\MagentoCloud\Filesystem\FileSystemException
83+
* @inheritdoc
8684
*
8785
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
8886
*/
89-
protected function execute(InputInterface $input, OutputInterface $output)
87+
protected function execute(InputInterface $input, OutputInterface $output): int
9088
{
9189
$errors = Yaml::parse(
9290
$this->file->fileGetContents($this->fileList->getErrorSchema()),
@@ -100,6 +98,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
10098
$this->file->filePutContents($this->fileList->getErrorDistConfig(), $docs);
10199

102100
$output->writeln(sprintf('File %s was generated', $this->fileList->getErrorDistConfig()));
101+
102+
return Cli::SUCCESS;
103103
}
104104

105105
/**

src/Command/Dev/UpdateComposer.php

+14-3
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
108108
{
109109
$gitOptions = $this->globalSection->get(GlobalSection::VAR_DEPLOY_FROM_GIT_OPTIONS);
110110

111-
$scripts = $this->composerGenerator->getInstallFromGitScripts($gitOptions['repositories']);
112-
foreach (array_slice($scripts, 1) as $script) {
111+
$InstallFromGitScripts = $this->composerGenerator->getInstallFromGitScripts($gitOptions['repositories']);
112+
foreach (array_slice($InstallFromGitScripts, 1) as $script) {
113113
$this->shell->execute($script);
114114
}
115115

116-
$composer = $this->composerGenerator->generate($gitOptions['repositories']);
116+
// Preparing framework modules for installation
117+
$frameworkPreparationScript = $this->composerGenerator->getFrameworkPreparationScript(
118+
array_keys($gitOptions['repositories'])
119+
);
120+
foreach ($frameworkPreparationScript as $script) {
121+
$this->shell->execute($script);
122+
}
123+
124+
$composer = $this->composerGenerator->generate(
125+
$gitOptions['repositories'],
126+
array_merge($InstallFromGitScripts, $frameworkPreparationScript)
127+
);
117128

118129
if (!empty($gitOptions['clear_magento_module_requirements'])) {
119130
$clearRequirementsScript = $this->clearModuleRequirements->generate();

src/Command/Dev/UpdateComposer/ComposerGenerator.php

+40-5
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ public function __construct(
6969
* Generates composer.json data for installation from git.
7070
*
7171
* @param array $repoOptions
72+
* @param array $installFromGitScripts
7273
* @return array
7374
* @throws FileSystemException
7475
* @codeCoverageIgnore
7576
*/
76-
public function generate(array $repoOptions): array
77+
public function generate(array $repoOptions, array $installFromGitScripts): array
7778
{
78-
$composer = $this->getBaseComposer($repoOptions);
79+
$composer = $this->getBaseComposer($installFromGitScripts);
7980

8081
$rootComposerJsonPath = $this->directoryList->getMagentoRoot() . '/composer.json';
8182
if ($this->file->isExists($rootComposerJsonPath)) {
@@ -162,15 +163,39 @@ public function getInstallFromGitScripts(array $repoOptions): array
162163
return $installFromGitScripts;
163164
}
164165

166+
/**
167+
* @param array $repoNames
168+
* @return array
169+
* @throws FileSystemException
170+
*/
171+
public function getFrameworkPreparationScript(array $repoNames): array
172+
{
173+
$script = [];
174+
175+
foreach ($repoNames as $repoName) {
176+
$path = $repoName . '/lib/internal/Magento/Framework';
177+
$absolutePath = $this->directoryList->getMagentoRoot() . '/' .$path;
178+
179+
if ($this->file->isExists($absolutePath)) {
180+
foreach ($this->findPackages($absolutePath) as $package) {
181+
if ($package) {
182+
$script[] = 'mv ' . $path . '/' . $package . ' ' . $path . '-' . $package;
183+
}
184+
}
185+
}
186+
}
187+
188+
return $script;
189+
}
190+
165191
/**
166192
* Returns base skeleton for composer.json.
167193
*
168-
* @param array $repoOptions
194+
* @param array $installFromGitScripts
169195
* @return array
170196
*/
171-
private function getBaseComposer(array $repoOptions): array
197+
private function getBaseComposer(array $installFromGitScripts): array
172198
{
173-
$installFromGitScripts = $this->getInstallFromGitScripts($repoOptions);
174199
$composer = [
175200
'name' => 'magento/cloud-dev',
176201
'description' => 'eCommerce Platform for Growth',
@@ -188,6 +213,11 @@ private function getBaseComposer(array $repoOptions): array
188213
],
189214
'config' => [
190215
'use-include-path' => true,
216+
'allow-plugins' => [
217+
'dealerdirect/phpcodesniffer-composer-installer' => true,
218+
'laminas/laminas-dependency-plugin' => true,
219+
'magento/*' => true
220+
]
191221
],
192222
'autoload' => [
193223
'psr-4' => [
@@ -200,6 +230,11 @@ private function getBaseComposer(array $repoOptions): array
200230
'extra' => [
201231
'magento-force' => 'override',
202232
'magento-deploystrategy' => 'copy',
233+
'magento-deploy-ignore' => [
234+
'*' => [
235+
'/.gitignore'
236+
]
237+
]
203238
],
204239
'scripts' => [
205240
'install-from-git' => $installFromGitScripts,

src/Step/Deploy/InstallUpdate/ConfigUpdate/Amqp/Config.php src/Config/Amqp.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\MagentoCloud\Step\Deploy\InstallUpdate\ConfigUpdate\Amqp;
8+
namespace Magento\MagentoCloud\Config;
99

10-
use Magento\MagentoCloud\Config\ConfigMerger;
1110
use Magento\MagentoCloud\Config\Stage\DeployInterface;
1211
use Magento\MagentoCloud\Service\RabbitMq;
1312
use Magento\MagentoCloud\Package\MagentoVersion;
1413

1514
/**
1615
* Returns queue configuration.
1716
*/
18-
class Config
17+
class Amqp
1918
{
2019
/**
2120
* @var RabbitMq
@@ -61,9 +60,9 @@ public function __construct(
6160
* @return array
6261
* @throws \Magento\MagentoCloud\Package\UndefinedPackageException
6362
*/
64-
public function get(): array
63+
public function getConfig(): array
6564
{
66-
$config = $this->getConfig();
65+
$config = $this->getMergedConfig();
6766

6867
if ($this->magentoVersion->isGreaterOrEqual('2.2')) {
6968
$config['consumers_wait_for_messages'] = $this->stageConfig->get(
@@ -79,7 +78,7 @@ public function get(): array
7978
*
8079
* @return array
8180
*/
82-
private function getConfig(): array
81+
private function getMergedConfig(): array
8382
{
8483
$envQueueConfig = $this->stageConfig->get(DeployInterface::VAR_QUEUE_CONFIGURATION);
8584
$mqConfig = $this->getAmqpConfig();

src/Config/Validator/Deploy/ElasticSuiteIntegrity.php

+12-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\MagentoCloud\Config\ValidatorException;
1616
use Magento\MagentoCloud\Config\ValidatorInterface;
1717
use Magento\MagentoCloud\Service\ElasticSearch;
18+
use Magento\MagentoCloud\Service\OpenSearch;
1819

1920
/**
2021
* Validates different aspects of ElasticSuite's configuration.
@@ -31,6 +32,11 @@ class ElasticSuiteIntegrity implements ValidatorInterface
3132
*/
3233
private $elasticSearch;
3334

35+
/**
36+
* @var OpenSearch
37+
*/
38+
private $openSearch;
39+
3440
/**
3541
* @var Validator\ResultFactory
3642
*/
@@ -44,24 +50,27 @@ class ElasticSuiteIntegrity implements ValidatorInterface
4450
/**
4551
* @param ElasticSuite $elasticSuite
4652
* @param ElasticSearch $elasticSearch
53+
* @param OpenSearch $openSearch
4754
* @param Validator\ResultFactory $resultFactory
4855
* @param DeployInterface $config
4956
*/
5057
public function __construct(
5158
ElasticSuite $elasticSuite,
5259
ElasticSearch $elasticSearch,
60+
OpenSearch $openSearch,
5361
Validator\ResultFactory $resultFactory,
5462
DeployInterface $config
5563
) {
5664
$this->elasticSuite = $elasticSuite;
5765
$this->elasticSearch = $elasticSearch;
66+
$this->openSearch = $openSearch;
5867
$this->resultFactory = $resultFactory;
5968
$this->config = $config;
6069
}
6170

6271
/**
6372
* If ElasticSuite is absent - skip validation.
64-
* If ElasticSuite is present and no ElasticSearch connection - fail validation.
73+
* If ElasticSuite is present and no ElasticSearch or OpenSearch connection - fail validation.
6574
* If search engine is manually set to non-ElasticSuite it will fail after deploy - fail validation.
6675
*
6776
* Otherwise - validation is successful.
@@ -76,9 +85,9 @@ public function validate(): Validator\ResultInterface
7685
return $this->resultFactory->success();
7786
}
7887

79-
if (!$this->elasticSearch->isInstalled()) {
88+
if (!$this->elasticSearch->isInstalled() && !$this->openSearch->isInstalled()) {
8089
return $this->resultFactory->error(
81-
'ElasticSuite is installed without available ElasticSearch service.',
90+
'ElasticSuite is installed without available ElasticSearch or OpenSearch service.',
8291
'',
8392
Error::DEPLOY_ELASTIC_SUITE_WITHOUT_ES
8493
);

src/Step/Deploy/InstallUpdate/ConfigUpdate/Amqp.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\MagentoCloud\Config\Magento\Env\ReaderInterface as ConfigReader;
1616
use Magento\MagentoCloud\Config\Magento\Env\WriterInterface as ConfigWriter;
1717
use Psr\Log\LoggerInterface;
18-
use Magento\MagentoCloud\Step\Deploy\InstallUpdate\ConfigUpdate\Amqp\Config as AmqpConfig;
18+
use Magento\MagentoCloud\Config\Amqp as AmqpConfig;
1919

2020
/**
2121
* @inheritdoc
@@ -75,7 +75,7 @@ public function execute()
7575
{
7676
try {
7777
$config = $this->configReader->read();
78-
$amqpConfig = $this->amqpConfig->get();
78+
$amqpConfig = $this->amqpConfig->getConfig();
7979
} catch (GenericException $e) {
8080
throw new StepException($e->getMessage(), $e->getCode(), $e);
8181
}

src/Step/Deploy/InstallUpdate/Install/Setup/InstallCommandFactory.php

+35-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Magento\MagentoCloud\Util\UrlManager;
2424
use Magento\MagentoCloud\Util\PasswordGenerator;
2525
use Magento\MagentoCloud\Config\RemoteStorage;
26+
use Magento\MagentoCloud\Config\Amqp as AmqpConfig;
2627

2728
/**
2829
* Generates command for magento installation
@@ -90,6 +91,11 @@ class InstallCommandFactory
9091
*/
9192
private $remoteStorage;
9293

94+
/**
95+
* @var AmqpConfig
96+
*/
97+
private $amqpConfig;
98+
9399
/**
94100
* @param UrlManager $urlManager
95101
* @param AdminDataInterface $adminData
@@ -102,6 +108,7 @@ class InstallCommandFactory
102108
* @param ElasticSearch $elasticSearch
103109
* @param OpenSearch $openSearch
104110
* @param RemoteStorage $remoteStorage
111+
* @param AmqpConfig $amqpConfig
105112
*
106113
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
107114
*/
@@ -116,7 +123,8 @@ public function __construct(
116123
MagentoVersion $magentoVersion,
117124
ElasticSearch $elasticSearch,
118125
OpenSearch $openSearch,
119-
RemoteStorage $remoteStorage
126+
RemoteStorage $remoteStorage,
127+
AmqpConfig $amqpConfig
120128
) {
121129
$this->urlManager = $urlManager;
122130
$this->adminData = $adminData;
@@ -129,6 +137,7 @@ public function __construct(
129137
$this->elasticSearch = $elasticSearch;
130138
$this->openSearch = $openSearch;
131139
$this->remoteStorage = $remoteStorage;
140+
$this->amqpConfig = $amqpConfig;
132141
}
133142

134143
/**
@@ -148,7 +157,8 @@ public function create(): string
148157
$this->getBaseOptions(),
149158
$this->getAdminOptions(),
150159
$this->getEsOptions(),
151-
$this->getRemoteStorageOptions()
160+
$this->getRemoteStorageOptions(),
161+
$this->getAmqpOptions()
152162
);
153163
} catch (GenericException $exception) {
154164
throw new ConfigException($exception->getMessage(), $exception->getCode(), $exception);
@@ -334,4 +344,27 @@ private function getConnectionData(): ConnectionInterface
334344

335345
return $this->connectionData;
336346
}
347+
348+
/**
349+
* Returns AMQP optional config options.
350+
*
351+
* @return array
352+
* @throws UndefinedPackageException
353+
*/
354+
private function getAmqpOptions(): array
355+
{
356+
$options = [];
357+
$config = $this->amqpConfig->getConfig();
358+
$map = ['host', 'port', 'user', 'password', 'virtualhost'];
359+
360+
if (!empty($config['amqp']['host'])) {
361+
foreach ($map as $option) {
362+
if (!empty($config['amqp'][$option])) {
363+
$options['--amqp-' . $option] = (string)$config['amqp'][$option];
364+
}
365+
}
366+
}
367+
368+
return $options;
369+
}
337370
}

0 commit comments

Comments
 (0)