Skip to content

Commit

Permalink
Merge pull request #93 from magento-commerce/develop
Browse files Browse the repository at this point in the history
MCLOUD-9083: Release ece-tools 2002.1.11 and MCC 1.0.11
  • Loading branch information
BaDos authored Jul 29, 2022
2 parents d980a6e + 658164e commit 2a2cf2e
Show file tree
Hide file tree
Showing 16 changed files with 375 additions and 48 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/ece-tools",
"description": "Provides tools to build and deploy Magento 2 Enterprise Edition",
"type": "magento2-component",
"version": "2002.1.10",
"version": "2002.1.11",
"license": "OSL-3.0",
"repositories": {
"repo.magento.com": {
Expand Down
10 changes: 5 additions & 5 deletions src/Command/Dev/GenerateSchemaError.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Magento\MagentoCloud\Command\Dev;

use Magento\MagentoCloud\Cli;
use Magento\MagentoCloud\Filesystem\Driver\File;
use Magento\MagentoCloud\Filesystem\FileList;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -79,14 +80,11 @@ protected function configure(): void
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|void
* @throws \Magento\MagentoCloud\Filesystem\FileSystemException
* @inheritdoc
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$errors = Yaml::parse(
$this->file->fileGetContents($this->fileList->getErrorSchema()),
Expand All @@ -100,6 +98,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->file->filePutContents($this->fileList->getErrorDistConfig(), $docs);

$output->writeln(sprintf('File %s was generated', $this->fileList->getErrorDistConfig()));

return Cli::SUCCESS;
}

/**
Expand Down
17 changes: 14 additions & 3 deletions src/Command/Dev/UpdateComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
$gitOptions = $this->globalSection->get(GlobalSection::VAR_DEPLOY_FROM_GIT_OPTIONS);

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

$composer = $this->composerGenerator->generate($gitOptions['repositories']);
// Preparing framework modules for installation
$frameworkPreparationScript = $this->composerGenerator->getFrameworkPreparationScript(
array_keys($gitOptions['repositories'])
);
foreach ($frameworkPreparationScript as $script) {
$this->shell->execute($script);
}

$composer = $this->composerGenerator->generate(
$gitOptions['repositories'],
array_merge($InstallFromGitScripts, $frameworkPreparationScript)
);

if (!empty($gitOptions['clear_magento_module_requirements'])) {
$clearRequirementsScript = $this->clearModuleRequirements->generate();
Expand Down
45 changes: 40 additions & 5 deletions src/Command/Dev/UpdateComposer/ComposerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ public function __construct(
* Generates composer.json data for installation from git.
*
* @param array $repoOptions
* @param array $installFromGitScripts
* @return array
* @throws FileSystemException
* @codeCoverageIgnore
*/
public function generate(array $repoOptions): array
public function generate(array $repoOptions, array $installFromGitScripts): array
{
$composer = $this->getBaseComposer($repoOptions);
$composer = $this->getBaseComposer($installFromGitScripts);

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

/**
* @param array $repoNames
* @return array
* @throws FileSystemException
*/
public function getFrameworkPreparationScript(array $repoNames): array
{
$script = [];

foreach ($repoNames as $repoName) {
$path = $repoName . '/lib/internal/Magento/Framework';
$absolutePath = $this->directoryList->getMagentoRoot() . '/' .$path;

if ($this->file->isExists($absolutePath)) {
foreach ($this->findPackages($absolutePath) as $package) {
if ($package) {
$script[] = 'mv ' . $path . '/' . $package . ' ' . $path . '-' . $package;
}
}
}
}

return $script;
}

/**
* Returns base skeleton for composer.json.
*
* @param array $repoOptions
* @param array $installFromGitScripts
* @return array
*/
private function getBaseComposer(array $repoOptions): array
private function getBaseComposer(array $installFromGitScripts): array
{
$installFromGitScripts = $this->getInstallFromGitScripts($repoOptions);
$composer = [
'name' => 'magento/cloud-dev',
'description' => 'eCommerce Platform for Growth',
Expand All @@ -188,6 +213,11 @@ private function getBaseComposer(array $repoOptions): array
],
'config' => [
'use-include-path' => true,
'allow-plugins' => [
'dealerdirect/phpcodesniffer-composer-installer' => true,
'laminas/laminas-dependency-plugin' => true,
'magento/*' => true
]
],
'autoload' => [
'psr-4' => [
Expand All @@ -200,6 +230,11 @@ private function getBaseComposer(array $repoOptions): array
'extra' => [
'magento-force' => 'override',
'magento-deploystrategy' => 'copy',
'magento-deploy-ignore' => [
'*' => [
'/.gitignore'
]
]
],
'scripts' => [
'install-from-git' => $installFromGitScripts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
*/
declare(strict_types=1);

namespace Magento\MagentoCloud\Step\Deploy\InstallUpdate\ConfigUpdate\Amqp;
namespace Magento\MagentoCloud\Config;

use Magento\MagentoCloud\Config\ConfigMerger;
use Magento\MagentoCloud\Config\Stage\DeployInterface;
use Magento\MagentoCloud\Service\RabbitMq;
use Magento\MagentoCloud\Package\MagentoVersion;

/**
* Returns queue configuration.
*/
class Config
class Amqp
{
/**
* @var RabbitMq
Expand Down Expand Up @@ -61,9 +60,9 @@ public function __construct(
* @return array
* @throws \Magento\MagentoCloud\Package\UndefinedPackageException
*/
public function get(): array
public function getConfig(): array
{
$config = $this->getConfig();
$config = $this->getMergedConfig();

if ($this->magentoVersion->isGreaterOrEqual('2.2')) {
$config['consumers_wait_for_messages'] = $this->stageConfig->get(
Expand All @@ -79,7 +78,7 @@ public function get(): array
*
* @return array
*/
private function getConfig(): array
private function getMergedConfig(): array
{
$envQueueConfig = $this->stageConfig->get(DeployInterface::VAR_QUEUE_CONFIGURATION);
$mqConfig = $this->getAmqpConfig();
Expand Down
15 changes: 12 additions & 3 deletions src/Config/Validator/Deploy/ElasticSuiteIntegrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Magento\MagentoCloud\Config\ValidatorException;
use Magento\MagentoCloud\Config\ValidatorInterface;
use Magento\MagentoCloud\Service\ElasticSearch;
use Magento\MagentoCloud\Service\OpenSearch;

/**
* Validates different aspects of ElasticSuite's configuration.
Expand All @@ -31,6 +32,11 @@ class ElasticSuiteIntegrity implements ValidatorInterface
*/
private $elasticSearch;

/**
* @var OpenSearch
*/
private $openSearch;

/**
* @var Validator\ResultFactory
*/
Expand All @@ -44,24 +50,27 @@ class ElasticSuiteIntegrity implements ValidatorInterface
/**
* @param ElasticSuite $elasticSuite
* @param ElasticSearch $elasticSearch
* @param OpenSearch $openSearch
* @param Validator\ResultFactory $resultFactory
* @param DeployInterface $config
*/
public function __construct(
ElasticSuite $elasticSuite,
ElasticSearch $elasticSearch,
OpenSearch $openSearch,
Validator\ResultFactory $resultFactory,
DeployInterface $config
) {
$this->elasticSuite = $elasticSuite;
$this->elasticSearch = $elasticSearch;
$this->openSearch = $openSearch;
$this->resultFactory = $resultFactory;
$this->config = $config;
}

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

if (!$this->elasticSearch->isInstalled()) {
if (!$this->elasticSearch->isInstalled() && !$this->openSearch->isInstalled()) {
return $this->resultFactory->error(
'ElasticSuite is installed without available ElasticSearch service.',
'ElasticSuite is installed without available ElasticSearch or OpenSearch service.',
'',
Error::DEPLOY_ELASTIC_SUITE_WITHOUT_ES
);
Expand Down
4 changes: 2 additions & 2 deletions src/Step/Deploy/InstallUpdate/ConfigUpdate/Amqp.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Magento\MagentoCloud\Config\Magento\Env\ReaderInterface as ConfigReader;
use Magento\MagentoCloud\Config\Magento\Env\WriterInterface as ConfigWriter;
use Psr\Log\LoggerInterface;
use Magento\MagentoCloud\Step\Deploy\InstallUpdate\ConfigUpdate\Amqp\Config as AmqpConfig;
use Magento\MagentoCloud\Config\Amqp as AmqpConfig;

/**
* @inheritdoc
Expand Down Expand Up @@ -75,7 +75,7 @@ public function execute()
{
try {
$config = $this->configReader->read();
$amqpConfig = $this->amqpConfig->get();
$amqpConfig = $this->amqpConfig->getConfig();
} catch (GenericException $e) {
throw new StepException($e->getMessage(), $e->getCode(), $e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Magento\MagentoCloud\Util\UrlManager;
use Magento\MagentoCloud\Util\PasswordGenerator;
use Magento\MagentoCloud\Config\RemoteStorage;
use Magento\MagentoCloud\Config\Amqp as AmqpConfig;

/**
* Generates command for magento installation
Expand Down Expand Up @@ -90,6 +91,11 @@ class InstallCommandFactory
*/
private $remoteStorage;

/**
* @var AmqpConfig
*/
private $amqpConfig;

/**
* @param UrlManager $urlManager
* @param AdminDataInterface $adminData
Expand All @@ -102,6 +108,7 @@ class InstallCommandFactory
* @param ElasticSearch $elasticSearch
* @param OpenSearch $openSearch
* @param RemoteStorage $remoteStorage
* @param AmqpConfig $amqpConfig
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
Expand All @@ -116,7 +123,8 @@ public function __construct(
MagentoVersion $magentoVersion,
ElasticSearch $elasticSearch,
OpenSearch $openSearch,
RemoteStorage $remoteStorage
RemoteStorage $remoteStorage,
AmqpConfig $amqpConfig
) {
$this->urlManager = $urlManager;
$this->adminData = $adminData;
Expand All @@ -129,6 +137,7 @@ public function __construct(
$this->elasticSearch = $elasticSearch;
$this->openSearch = $openSearch;
$this->remoteStorage = $remoteStorage;
$this->amqpConfig = $amqpConfig;
}

/**
Expand All @@ -148,7 +157,8 @@ public function create(): string
$this->getBaseOptions(),
$this->getAdminOptions(),
$this->getEsOptions(),
$this->getRemoteStorageOptions()
$this->getRemoteStorageOptions(),
$this->getAmqpOptions()
);
} catch (GenericException $exception) {
throw new ConfigException($exception->getMessage(), $exception->getCode(), $exception);
Expand Down Expand Up @@ -334,4 +344,27 @@ private function getConnectionData(): ConnectionInterface

return $this->connectionData;
}

/**
* Returns AMQP optional config options.
*
* @return array
* @throws UndefinedPackageException
*/
private function getAmqpOptions(): array
{
$options = [];
$config = $this->amqpConfig->getConfig();
$map = ['host', 'port', 'user', 'password', 'virtualhost'];

if (!empty($config['amqp']['host'])) {
foreach ($map as $option) {
if (!empty($config['amqp'][$option])) {
$options['--amqp-' . $option] = (string)$config['amqp'][$option];
}
}
}

return $options;
}
}
Loading

0 comments on commit 2a2cf2e

Please sign in to comment.