Implement Keystone environment deployments
This commit is contained in:
24
app/Data/Environments/EnvironmentDeploymentPlan.php
Normal file
24
app/Data/Environments/EnvironmentDeploymentPlan.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Data\Environments;
|
||||
|
||||
use App\Models\Service;
|
||||
|
||||
class EnvironmentDeploymentPlan
|
||||
{
|
||||
/**
|
||||
* @param array<int, Service> $services
|
||||
* @param array<int, Service> $dependencies
|
||||
* @param array<int, string> $warnings
|
||||
* @param array<int, string> $blockers
|
||||
*/
|
||||
public function __construct(
|
||||
public array $services = [],
|
||||
public array $dependencies = [],
|
||||
public bool $requiresRegistry = false,
|
||||
public array $warnings = [],
|
||||
public array $blockers = [],
|
||||
) {
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Data\Deployments;
|
||||
namespace App\Data\Operations;
|
||||
|
||||
class Plan
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Data\Deployments;
|
||||
namespace App\Data\Operations;
|
||||
|
||||
class PlannedStep
|
||||
{
|
||||
@@ -11,28 +11,34 @@ class PlannedStep
|
||||
protected array $secrets = [],
|
||||
string|callable $script = 'echo "Incomplete Step"',
|
||||
) {
|
||||
if (is_callable($script)) {
|
||||
$this->script = $script();
|
||||
} else {
|
||||
$this->script = $script;
|
||||
}
|
||||
$this->script = is_callable($script) ? $script() : $script;
|
||||
}
|
||||
|
||||
public function getSafeScript(): string
|
||||
{
|
||||
$script = $this->script;
|
||||
foreach ($this->secrets as $key => $value) {
|
||||
$script = str_replace("[!{$key}]", '********', $script);
|
||||
$script = str_replace("[!{$key}!]", '********', $script);
|
||||
}
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function getScriptTemplate(): string
|
||||
{
|
||||
return $this->script;
|
||||
}
|
||||
|
||||
public function secrets(): array
|
||||
{
|
||||
return $this->secrets;
|
||||
}
|
||||
|
||||
public function getScript(): string
|
||||
{
|
||||
$script = $this->script;
|
||||
foreach ($this->secrets as $key => $value) {
|
||||
$script = str_replace("[!{$key}]", $value, $script);
|
||||
$script = str_replace("[!{$key}!]", $value, $script);
|
||||
}
|
||||
|
||||
return $script;
|
||||
Reference in New Issue
Block a user