Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made that the Remove and Update commands in the Cloud context can be used with several satellites in a single file #152

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading