Skip to content

Commit

Permalink
Made that the Remove and Update commands in the Cloud context can be …
Browse files Browse the repository at this point in the history
…used with several satellites in a single file
  • Loading branch information
sebprt committed Jan 22, 2024
1 parent 85aaa1f commit 7d7c6d6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
20 changes: 12 additions & 8 deletions src/Cloud/Console/Command/RemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,18 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
}

$context = new Satellite\Cloud\Context($client, $auth, $url);
$instance = match (true) {
\array_key_exists('pipeline', $configuration) => new Satellite\Cloud\Pipeline($context),
\array_key_exists('workflow', $configuration) => new Satellite\Cloud\Workflow($context),
default => throw new \RuntimeException('Invalid runtime satellite configuration.'),
};

foreach ($instance->remove($instance::fromApiWithCode($client, array_key_first($configuration['satellites']))->id()) as $command) {
$bus->push($command);

foreach ($configuration['satellites'] as $code => $satellite) {
$satellite['code'] = $code;
$instance = match (true) {
\array_key_exists('pipeline', $satellite) => new Satellite\Cloud\Pipeline($context),
\array_key_exists('workflow', $satellite) => new Satellite\Cloud\Workflow($context),
default => throw new \RuntimeException('Invalid runtime satellite configuration.'),
};

foreach ($instance->remove($instance::fromApiWithCode($client, array_key_first($configuration['satellites']))->id()) as $command) {
$bus->push($command);
}
}

$bus->execute();
Expand Down
20 changes: 12 additions & 8 deletions src/Cloud/Console/Command/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,18 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
}

$context = new Satellite\Cloud\Context($client, $auth, $url);
$instance = match (true) {
\array_key_exists('pipeline', $configuration) => new Satellite\Cloud\Pipeline($context),
\array_key_exists('workflow', $configuration) => new Satellite\Cloud\Workflow($context),
default => throw new \RuntimeException('Invalid runtime satellite configuration.'),
};

foreach ($instance->update($instance::fromApiWithCode($client, array_key_first($configuration['satellites'])), $instance::fromLegacyConfiguration($configuration['satellite'])) as $command) {
$bus->push($command);

foreach ($configuration['satellites'] as $code => $satellite) {
$satellite['code'] = $code;
$instance = match (true) {
\array_key_exists('pipeline', $satellite) => new Satellite\Cloud\Pipeline($context),
\array_key_exists('workflow', $satellite) => new Satellite\Cloud\Workflow($context),
default => throw new \RuntimeException('Invalid runtime satellite configuration.'),
};

foreach ($instance->update($instance::fromApiWithCode($client, array_key_first($configuration['satellites'])), $instance::fromLegacyConfiguration($configuration['satellite'])) as $command) {
$bus->push($command);
}
}

$bus->execute();
Expand Down
1 change: 1 addition & 0 deletions src/Console/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class RunCommand extends Console\Command\Command
{
protected function configure(): void
{

$this->addArgument('path', Console\Input\InputArgument::REQUIRED);
}

Expand Down

0 comments on commit 7d7c6d6

Please sign in to comment.