Implement Keystone environment deployments
This commit is contained in:
46
app/Data/Operations/PlannedStep.php
Normal file
46
app/Data/Operations/PlannedStep.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Data\Operations;
|
||||
|
||||
class PlannedStep
|
||||
{
|
||||
protected string $script;
|
||||
|
||||
public function __construct(
|
||||
public string $name = 'Step',
|
||||
protected array $secrets = [],
|
||||
string|callable $script = 'echo "Incomplete Step"',
|
||||
) {
|
||||
$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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return $script;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user