Skip to content

Commit

Permalink
MAGECLOUD-4104: Introduce an API endpoints (magento#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
oshmyheliuk authored and shiftedreality committed Nov 26, 2019
1 parent 647e93e commit 3f8c3fd
Show file tree
Hide file tree
Showing 120 changed files with 1,241 additions and 1,003 deletions.
9 changes: 9 additions & 0 deletions config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,14 @@
<service id="Magento\MagentoCloud\Shell\ShellInterface" alias="Magento\MagentoCloud\Shell\Shell" />
<service id="Magento\MagentoCloud\Config\Stage\DeployInterface" alias="Magento\MagentoCloud\Config\Stage\Deploy" />
<service id="Magento\MagentoCloud\Config\Stage\BuildInterface" alias="Magento\MagentoCloud\Config\Stage\Build" />
<service id="Magento\MagentoCloud\Config\Stage\PostDeployInterface" alias="Magento\MagentoCloud\Config\Stage\PostDeploy" />
<service id="Magento\MagentoCloud\Config\EnvironmentDataInterface" alias="Magento\MagentoCloud\Config\EnvironmentData" />
<service id="Magento\MagentoCloud\Config\AdminDataInterface" alias="Magento\MagentoCloud\Config\AdminData" />
<service id="Magento\MagentoCloud\PlatformVariable\DecoderInterface" alias="Magento\MagentoCloud\PlatformVariable\Decoder" />
<service id="Magento\MagentoCloud\Config\Environment\ReaderInterface" alias="Magento\MagentoCloud\Config\Environment\Reader" />
<service id="Magento\MagentoCloud\Config\Magento\Env\ReaderInterface" alias="Magento\MagentoCloud\Config\Magento\Env\Reader" />
<service id="Magento\MagentoCloud\Config\Magento\Env\WriterInterface" alias="Magento\MagentoCloud\Config\Magento\Env\Writer" />
<service id="Magento\MagentoCloud\Config\Magento\Shared\ReaderInterface" alias="Magento\MagentoCloud\Config\Magento\Shared\Reader" />
<service id="Magento\MagentoCloud\Config\Magento\Shared\WriterInterface" alias="Magento\MagentoCloud\Config\Magento\Shared\Writer" />
</services>
</container>
2 changes: 1 addition & 1 deletion scenario/build/generate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</arguments>
</step>
<step name="refresh-modules" type="Magento\MagentoCloud\Step\Build\RefreshModules" priority="400"/>
<step name="copy-pub-static" type="Magento\MagentoCloud\Command\CopyPubStatic" priority="500"/>
<step name="copy-pub-static" type="Magento\MagentoCloud\Step\Build\CopyPubStatic" priority="500"/>
<step name="apply-patches" type="Magento\MagentoCloud\Step\Build\ApplyPatches" priority="600"/>
<step name="set-report-dir-nesting-level" type="Magento\MagentoCloud\Step\Build\SetReportDirNestingLevel" priority="700"/>
<step name="marshall-files" type="Magento\MagentoCloud\Step\Build\MarshallFiles" priority="800"/>
Expand Down
2 changes: 2 additions & 0 deletions src/Command/BackupList.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

/**
* CLI command for showing the list of backup files.
*
* @api
*/
class BackupList extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/BackupRestore.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/**
* CLI command for restoring Magento configuration files from backup.
*
* @api
*/
class BackupRestore extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

/**
* CLI command for build hook. Responsible for preparing the codebase before it's moved to the server.
*
* @api
*/
class Build extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Build/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
/**
* CLI command that used as part of build hook.
* Responsible for patches applying, validating configuration, preparing the codebase, etc.
*
* @api
*/
class Generate extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Build/Transfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

/**
* CLI command for transfer data generated by build:generate command ot init directory.
*
* @api
*/
class Transfer extends Command
{
Expand Down
18 changes: 10 additions & 8 deletions src/Command/ConfigDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

use Magento\MagentoCloud\App\GenericException;
use Magento\MagentoCloud\Command\ConfigDump\Generate;
use Magento\MagentoCloud\Config\Deploy\Reader;
use Magento\MagentoCloud\Config\Deploy\Writer;
use Magento\MagentoCloud\Config\Magento\Env\ReaderInterface;
use Magento\MagentoCloud\Config\Magento\Env\WriterInterface;
use Magento\MagentoCloud\Package\MagentoVersion;
use Magento\MagentoCloud\Shell\ShellFactory;
use Magento\MagentoCloud\Shell\ShellInterface;
Expand All @@ -21,6 +21,8 @@

/**
* CLI command for dumping SCD related config.
*
* @api
*/
class ConfigDump extends Command
{
Expand All @@ -42,12 +44,12 @@ class ConfigDump extends Command
private $generate;

/**
* @var Reader
* @var ReaderInterface
*/
private $reader;

/**
* @var Writer
* @var WriterInterface
*/
private $writer;

Expand All @@ -60,16 +62,16 @@ class ConfigDump extends Command
* @param LoggerInterface $logger
* @param ShellFactory $shellFactory
* @param Generate $generate
* @param Reader $reader
* @param Writer $writer
* @param ReaderInterface $reader
* @param WriterInterface $writer
* @param MagentoVersion $magentoVersion
*/
public function __construct(
LoggerInterface $logger,
ShellFactory $shellFactory,
Generate $generate,
Reader $reader,
Writer $writer,
ReaderInterface $reader,
WriterInterface $writer,
MagentoVersion $magentoVersion
) {
$this->logger = $logger;
Expand Down
2 changes: 2 additions & 0 deletions src/Command/ConfigShow.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

/**
* CLI command to friendly display the encoded cloud configuration environment variables
*
* @api
*/
class ConfigShow extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/CronKill.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

/**
* CLI command for killing Magento cron processes
*
* @api
*/
class CronKill extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/CronUnlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/**
* CLI command for unlocking cron jobs that stuck in "running" state.
*
* @api
*/
class CronUnlock extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/DbDump.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/**
* Class DbDump for safely creating backup of database
*
* @api
*/
class DbDump extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/**
* CLI command for deploy hook. Responsible for installing/updating/configuring Magento
*
* @api
*/
class Deploy extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Dev/UpdateComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

/**
* Update composer command for deployment from git.
*
* @api
*/
class UpdateComposer extends Command
{
Expand Down
4 changes: 3 additions & 1 deletion src/Command/ModuleRefresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
use Symfony\Component\Console\Output\OutputInterface;

/**
* Performs module
* Performs module:refresh command
*
* @api
*/
class ModuleRefresh extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/PostDeploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

/**
* Performs post-deploy operations.
*
* @api
*/
class PostDeploy extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

/**
* Execute given scenarios.
*
* @api
*/
class RunCommand extends Command
{
Expand Down
5 changes: 4 additions & 1 deletion src/Command/Wizard/IdealState.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
use Symfony\Component\Console\Output\OutputInterface;

/**
* @inheritdoc
* Verifies ideal state of configuration
*
* @api
*/
class IdealState extends Command
{
Expand Down Expand Up @@ -63,6 +65,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$message = 'The configured state is ideal';

if (($result = $this->validator->validate()) instanceof Error) {
/** @var Error $result */
$message = $result->getError();

foreach ($this->validator->getErrors() as $error) {
Expand Down
4 changes: 3 additions & 1 deletion src/Command/Wizard/MasterSlave.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
use Symfony\Component\Console\Output\OutputInterface;

/**
* @inheritdoc
* Verifies master-slave configuration
*
* @api
*/
class MasterSlave extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Wizard/ScdOnBuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

/**
* Verifies configuration to be properly set and ready to use SCD on build phase.
*
* @api
*/
class ScdOnBuild extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Wizard/ScdOnDemand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

/**
* Verifies configuration to be properly set and ready to use SCD on demand.
*
* @api
*/
class ScdOnDemand extends Command
{
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Wizard/ScdOnDeploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

/**
* Verifies configuration to be properly set and ready to use SCD on deploy phase.
*
* @api
*/
class ScdOnDeploy extends Command
{
Expand Down
91 changes: 91 additions & 0 deletions src/Config/AdminData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\MagentoCloud\Config;

/**
* @inheritDoc
*/
class AdminData implements AdminDataInterface
{
/**
* @var EnvironmentDataInterface
*/
private $environmentData;

/**
* @param EnvironmentDataInterface $environmentData
*/
public function __construct(EnvironmentDataInterface $environmentData)
{
$this->environmentData = $environmentData;
}

/**
* @inheritDoc
*/
public function getLocale(): string
{
return $this->environmentData->getVariables()['ADMIN_LOCALE'] ?? 'en_US';
}

/**
* @inheritDoc
*/
public function getUsername(): string
{
return $this->environmentData->getVariables()['ADMIN_USERNAME'] ?? '';
}

/**
* @inheritDoc
*/
public function getFirstName(): string
{
return $this->environmentData->getVariables()['ADMIN_FIRSTNAME'] ?? '';
}

/**
* @inheritDoc
*/
public function getLastName(): string
{
return $this->environmentData->getVariables()['ADMIN_LASTNAME'] ?? '';
}

/**
* @inheritDoc
*/
public function getEmail(): string
{
return $this->environmentData->getVariables()['ADMIN_EMAIL'] ?? '';
}

/**
* @inheritDoc
*/
public function getPassword(): string
{
return $this->environmentData->getVariables()['ADMIN_PASSWORD'] ?? '';
}

/**
* @inheritDoc
*/
public function getUrl(): string
{
return $this->environmentData->getVariables()['ADMIN_URL'] ?? '';
}

/**
* @inheritDoc
*/
public function getDefaultCurrency(): string
{
return 'USD';
}
}
Loading

0 comments on commit 3f8c3fd

Please sign in to comment.