deployments wip
This commit is contained in:
@@ -5,7 +5,7 @@ namespace App\Data\Deployments;
|
||||
class Plan
|
||||
{
|
||||
/**
|
||||
* @param Step[] $steps
|
||||
* @param PlannedStep[] $steps
|
||||
*/
|
||||
public function __construct(
|
||||
public array $steps = [],
|
||||
|
||||
38
app/Data/Deployments/PlannedStep.php
Normal file
38
app/Data/Deployments/PlannedStep.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Data\Deployments;
|
||||
|
||||
class PlannedStep
|
||||
{
|
||||
protected string $script;
|
||||
|
||||
public function __construct(
|
||||
public string $name = 'Step',
|
||||
protected array $secrets = [],
|
||||
string|callable $script = 'echo "Incomplete Step"',
|
||||
) {
|
||||
if (is_callable($script)) {
|
||||
$this->script = $script();
|
||||
} else {
|
||||
$this->script = $script;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSafeScript(): string
|
||||
{
|
||||
$script = $this->script;
|
||||
foreach ($this->secrets as $key => $value) {
|
||||
$script = str_replace("[!{$key}]", '********', $script);
|
||||
}
|
||||
return $script;
|
||||
}
|
||||
|
||||
public function getScript(): string
|
||||
{
|
||||
$script = $this->script;
|
||||
foreach ($this->secrets as $key => $value) {
|
||||
$script = str_replace("[!{$key}]", $value, $script);
|
||||
}
|
||||
return $script;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Data\Deployments;
|
||||
|
||||
class Step
|
||||
{
|
||||
public string $script;
|
||||
|
||||
public function __construct(
|
||||
public string $name = 'Step',
|
||||
string|callable $script = 'echo "Incomplete Step"',
|
||||
) {
|
||||
if (is_callable($script)) {
|
||||
$this->script = $script();
|
||||
} else {
|
||||
$this->script = $script;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user