Skip to content

Commit

Permalink
deployer refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
julienj committed Mar 10, 2024
1 parent 2d1010d commit 1c5c230
Show file tree
Hide file tree
Showing 19 changed files with 341 additions and 579 deletions.
7 changes: 1 addition & 6 deletions src/Automate/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Automate\Model\Project;
use Automate\VariableResolver;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

abstract class BaseCommand extends Command
Expand All @@ -26,11 +25,7 @@ abstract class BaseCommand extends Command

protected function getLogger(SymfonyStyle $io): LoggerInterface
{
$verbosity = $io->getVerbosity() > OutputInterface::VERBOSITY_NORMAL
? LoggerInterface::VERBOSITY_DEBUG
: LoggerInterface::VERBOSITY_NORMAL;

return new ConsoleLogger($io, $verbosity);
return new ConsoleLogger($io);
}

protected function resolveVariables(SymfonyStyle $io, Project $project, Platform $platform): void
Expand Down
9 changes: 6 additions & 3 deletions src/Automate/Command/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

namespace Automate\Command;

use Automate\Context\SSHContext;
use Automate\Loader;
use Automate\Workflow\Context;
use Automate\Workflow\Session;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -45,11 +46,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$logger = $this->getLogger($io);

try {
$context = new SSHContext($project, $platform, $logger, $platform->getDefaultBranch());
$context = new Context($project, $platform, $logger, $platform->getDefaultBranch());

$context->connect();
$logger->section('Check git access');
$context->run('git ls-remote '.$project->getRepository(), false, null, false);
$context->exec(function (Session $session) use ($project) {
$session->exec('git ls-remote '.$project->getRepository(), false);
});
} catch (\Exception $exception) {
$io->error($exception->getMessage());

Expand Down
4 changes: 2 additions & 2 deletions src/Automate/Command/DeployCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace Automate\Command;

use Automate\Context\SSHContext;
use Automate\Loader;
use Automate\Model\Platform;
use Automate\Workflow\Context;
use Automate\Workflow\Deployer;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -59,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
['Version', $input->getArgument('gitRef') ?: $platform->getDefaultBranch()],
]);

$context = new SSHContext($project, $platform, $logger, $gitRef, $input->getOption('force'));
$context = new Context($project, $platform, $logger, $gitRef, $input->getOption('force'));
$workflow = new Deployer($context);

if (!$workflow->deploy()) {
Expand Down
154 changes: 0 additions & 154 deletions src/Automate/Context/AbstractContext.php

This file was deleted.

57 changes: 0 additions & 57 deletions src/Automate/Context/ContextInterface.php

This file was deleted.

59 changes: 0 additions & 59 deletions src/Automate/Context/SSHContext.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/Automate/Event/DeployEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

namespace Automate\Event;

use Automate\Context\ContextInterface;
use Automate\Workflow\Context;
use Symfony\Contracts\EventDispatcher\Event;

class DeployEvent extends Event
{
public function __construct(
private readonly ContextInterface $context,
private readonly Context $context,
) {
}

public function getContext(): ContextInterface
public function getContext(): Context
{
return $this->context;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Automate/Event/FailedDeployEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

namespace Automate\Event;

use Automate\Context\ContextInterface;
use Automate\Workflow\Context;

class FailedDeployEvent extends DeployEvent
{
public function __construct(ContextInterface $context, private readonly \Exception $exception)
public function __construct(Context $context, private readonly \Exception $exception)
{
parent::__construct($context);
}
Expand Down
Loading

0 comments on commit 1c5c230

Please sign in to comment.