-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from magento-commerce/develop
MCLOUD-9560: October cloud tools release
- Loading branch information
Showing
16 changed files
with
884 additions
and
37 deletions.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\MagentoCloud\Config\Validator\Build; | ||
|
||
use Magento\MagentoCloud\App\Error; | ||
use Magento\MagentoCloud\Config\Validator; | ||
use Magento\MagentoCloud\Config\ValidatorInterface; | ||
use Magento\MagentoCloud\Filesystem\Driver\File; | ||
use Magento\MagentoCloud\Filesystem\FileList; | ||
|
||
/** | ||
* Checks that required paths to exclude for OPCache are present. | ||
*/ | ||
class OpcacheExcludePaths implements ValidatorInterface | ||
{ | ||
/** | ||
* @var File | ||
*/ | ||
private $file; | ||
|
||
/** | ||
* @var FileList | ||
*/ | ||
private $fileList; | ||
|
||
/** | ||
* @var Validator\ResultFactory | ||
*/ | ||
private $resultFactory; | ||
|
||
/** | ||
* @param File $file | ||
* @param FileList $fileList | ||
* @param Validator\ResultFactory $resultFactory | ||
*/ | ||
public function __construct( | ||
File $file, | ||
FileList $fileList, | ||
Validator\ResultFactory $resultFactory | ||
) { | ||
$this->file = $file; | ||
$this->fileList = $fileList; | ||
$this->resultFactory = $resultFactory; | ||
} | ||
|
||
/** | ||
* Checks if php.ini and op-exclude.txt are present, and they contain needed configuration | ||
* | ||
* {@inheritdoc} | ||
*/ | ||
public function validate(): Validator\ResultInterface | ||
{ | ||
$phpIni = $this->fileList->getPhpIni(); | ||
$excludeList = $this->fileList->getOpCacheExcludeList(); | ||
|
||
// Checks if files are present | ||
if (!$this->file->isExists($phpIni) || !$this->file->isExists($excludeList)) { | ||
return $this->resultFactory->error( | ||
'File php.ini or op-exclude.txt does not exist', | ||
'Check if your cloud template contains latest php.ini and op-exclude.txt files', | ||
Error::WARN_WRONG_OPCACHE_CONFIG | ||
); | ||
} | ||
|
||
// Checks if the php.ini file contains correct path to the op-exclude.txt file | ||
$parsedPhpIni = (array) $this->file->parseIni($phpIni); | ||
|
||
if (!(array_key_exists('opcache.blacklist_filename', $parsedPhpIni) | ||
&& $parsedPhpIni['opcache.blacklist_filename'] == $excludeList)) { | ||
return $this->resultFactory->error( | ||
'File php.ini does not contain opcache.blacklist_filename configuration', | ||
'Check if your cloud template contains latest php.ini configuration file' | ||
. ' https://github.com/magento/magento-cloud/blob/master/php.ini', | ||
Error::WARN_WRONG_OPCACHE_CONFIG | ||
); | ||
} | ||
|
||
// Checks if the op-exclude.txt file contains all needed paths to exclude for OPCache | ||
$diff = array_diff( | ||
[ | ||
'/app/*/app/etc/config.php', | ||
'/app/*/app/etc/env.php', | ||
'/app/app/etc/config.php', | ||
'/app/app/etc/env.php', | ||
'/app/etc/config.php', | ||
'/app/etc/env.php' | ||
], | ||
explode(PHP_EOL, (string) $this->file->fileGetContents($excludeList)) | ||
); | ||
|
||
if (!empty($diff)) { | ||
return $this->resultFactory->error( | ||
'File op-exclude.txt does not contain required paths to exclude for OPCache', | ||
'Check if your op-exclude.txt contains the next paths:' . PHP_EOL | ||
. implode(PHP_EOL, $diff), | ||
Error::WARN_WRONG_OPCACHE_CONFIG | ||
); | ||
} | ||
|
||
return $this->resultFactory->create(Validator\ResultInterface::SUCCESS); | ||
} | ||
} |
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,92 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\MagentoCloud\Step\Build; | ||
|
||
use Magento\MagentoCloud\App\Error; | ||
use Magento\MagentoCloud\Config\ConfigException; | ||
use Magento\MagentoCloud\Config\GlobalSection; | ||
use Magento\MagentoCloud\Config\StageConfigInterface; | ||
use Magento\MagentoCloud\Shell\MagentoShell; | ||
use Magento\MagentoCloud\Shell\ShellException; | ||
use Magento\MagentoCloud\Shell\ShellFactory; | ||
use Magento\MagentoCloud\Step\StepException; | ||
use Magento\MagentoCloud\Step\StepInterface; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* Runs a command to generate a module for eventing and enables this module in case when | ||
* it is enabled in configuration | ||
*/ | ||
class EnableEventing implements StepInterface | ||
{ | ||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* @var MagentoShell | ||
*/ | ||
private $magentoShell; | ||
|
||
/** | ||
* @var GlobalSection | ||
*/ | ||
private $globalConfig; | ||
|
||
/** | ||
* @param LoggerInterface $logger | ||
* @param ShellFactory $shellFactory | ||
* @param GlobalSection $globalConfig | ||
*/ | ||
public function __construct( | ||
LoggerInterface $logger, | ||
ShellFactory $shellFactory, | ||
GlobalSection $globalConfig | ||
) { | ||
$this->logger = $logger; | ||
$this->magentoShell = $shellFactory->createMagento(); | ||
$this->globalConfig = $globalConfig; | ||
} | ||
|
||
/** | ||
* Generates and enables a module for eventing if @see StageConfigInterface::VAR_ENABLE_EVENTING set to true | ||
* | ||
* {@inheritDoc} | ||
*/ | ||
public function execute() | ||
{ | ||
try { | ||
if (!$this->globalConfig->get(StageConfigInterface::VAR_ENABLE_EVENTING)) { | ||
return; | ||
} | ||
} catch (ConfigException $e) { | ||
throw new StepException($e->getMessage(), $e->getCode(), $e); | ||
} | ||
|
||
try { | ||
$this->logger->notice('Generating module for eventing'); | ||
$this->magentoShell->execute('events:generate:module'); | ||
} catch (ShellException $e) { | ||
$this->logger->error( | ||
'Failed to generate the Magento_AdobeCommerceEvents module. ' . | ||
'Refer to the eventing documentation to determine if all required modules are have been installed. ' . | ||
'Error: ' . $e->getMessage() | ||
); | ||
throw new StepException($e->getMessage(), Error::GLOBAL_EVENTING_MODULE_GENERATE_FAILED, $e); | ||
} | ||
|
||
try { | ||
$this->logger->notice('Enabling module for eventing'); | ||
$this->magentoShell->execute('module:enable Magento_AdobeCommerceEvents'); | ||
} catch (ShellException $e) { | ||
$this->logger->error('Failed to enable module for eventing: ' . $e->getMessage()); | ||
throw new StepException($e->getMessage(), Error::GLOBAL_EVENTING_MODULE_ENABLEMENT_FAILED, $e); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.