forked from ByteInternet/hypernode-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHypernodeSettingTask.php
More file actions
43 lines (36 loc) · 1.43 KB
/
HypernodeSettingTask.php
File metadata and controls
43 lines (36 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Hypernode\Deploy\Deployer\Task\PlatformConfiguration;
use Deployer\Task\Task;
use Hypernode\Deploy\Deployer\Task\ConfigurableTaskInterface;
use Hypernode\Deploy\Deployer\Task\IncrementedTaskTrait;
use Hypernode\Deploy\Deployer\Task\TaskBase;
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
use Hypernode\DeployConfiguration\PlatformConfiguration\HypernodeSettingConfiguration;
use Webmozart\Assert\Assert;
use function Deployer\after;
use function Deployer\run;
use function Deployer\task;
class HypernodeSettingTask extends TaskBase implements ConfigurableTaskInterface
{
use IncrementedTaskTrait;
protected function getIncrementalNamePrefix(): string
{
return 'deploy:configuration:hypernode:setting:';
}
public function supports(TaskConfigurationInterface $config): bool
{
return $config instanceof HypernodeSettingConfiguration;
}
public function configureWithTaskConfig(TaskConfigurationInterface $config): ?Task
{
Assert::isInstanceOf($config, HypernodeSettingConfiguration::class);
$attribute = $config->getAttribute();
$value = $config->getValue();
$taskName = "deploy:hypernode:setting:$attribute";
$task = task($taskName, function () use ($attribute, $value) {
run("yes | hypernode-systemctl settings $attribute $value --block");
});
after('deploy:setup', $taskName);
return $task;
}
}