File tree Expand file tree Collapse file tree 4 files changed +59
-12
lines changed Expand file tree Collapse file tree 4 files changed +59
-12
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Hypernode \DeployConfiguration ;
6
+
7
+ class BrancherServer extends Server
8
+ {
9
+ public function getLabels (): array
10
+ {
11
+ return $ this ->getOptions ()[self ::OPTION_HN_BRANCHER_LABELS ] ?? [];
12
+ }
13
+
14
+ /**
15
+ * @param string[] $labels Labels to be applied to the brancher node
16
+ * @return $this
17
+ */
18
+ public function setLabels (array $ labels ): self
19
+ {
20
+ $ this ->setOption (self ::OPTION_HN_BRANCHER_LABELS , $ labels );
21
+ return $ this ;
22
+ }
23
+
24
+ public function getSettings (): array
25
+ {
26
+ return $ this ->getOptions ()[self ::OPTION_HN_BRANCHER_SETTINGS ] ?? [];
27
+ }
28
+
29
+ /**
30
+ * @param array $settings Settings to be applied to the brancher node
31
+ * @return $this
32
+ */
33
+ public function setSettings (array $ settings ): self
34
+ {
35
+ $ this ->setOption (self ::OPTION_HN_BRANCHER_SETTINGS , $ settings );
36
+ return $ this ;
37
+ }
38
+ }
Original file line number Diff line number Diff line change 8
8
class Server
9
9
{
10
10
public const OPTION_HN_BRANCHER = 'hn_brancher ' ;
11
+ public const OPTION_HN_BRANCHER_LABELS = 'hn_brancher_labels ' ;
12
+ public const OPTION_HN_BRANCHER_SETTINGS = 'hn_brancher_settings ' ;
11
13
public const OPTION_HN_PARENT_APP = 'hn_parent_app ' ;
12
14
13
15
/**
@@ -20,10 +22,7 @@ class Server
20
22
*/
21
23
private $ roles ;
22
24
23
- /**
24
- * @var string[]
25
- */
26
- private $ options = [];
25
+ private array $ options ;
27
26
28
27
/**
29
28
* @var string[]
@@ -32,7 +31,6 @@ class Server
32
31
33
32
/**
34
33
* @param string[] $roles
35
- * @param string[] $options
36
34
*/
37
35
public function __construct (string $ hostname , array $ roles = null , array $ options = [])
38
36
{
@@ -62,9 +60,6 @@ public function getRoles(): array
62
60
return $ this ->roles ;
63
61
}
64
62
65
- /**
66
- * @return string[]
67
- */
68
63
public function getOptions (): array
69
64
{
70
65
return $ this ->options ;
@@ -78,6 +73,16 @@ public function getSshOptions(): array
78
73
return $ this ->sshOptions ;
79
74
}
80
75
76
+ /**
77
+ * @param string $option
78
+ * @param mixed $value
79
+ * @return void
80
+ */
81
+ protected function setOption (string $ option , $ value )
82
+ {
83
+ $ this ->options [$ option ] = $ value ;
84
+ }
85
+
81
86
/**
82
87
* @param $options
83
88
*/
Original file line number Diff line number Diff line change @@ -75,16 +75,18 @@ public function addServer(
75
75
* @param array|null $roles Roles for the server to be applied
76
76
* @param array $options Extra host options for Deployer
77
77
* @see ServerRole
78
- * @return Server
78
+ * @return BrancherServer
79
79
*/
80
- public function addBrancherServer (string $ appName , array $ roles = null , array $ options = []): Server
80
+ public function addBrancherServer (string $ appName , array $ roles = null , array $ options = []): BrancherServer
81
81
{
82
82
$ brancherOptions = [
83
83
Server::OPTION_HN_BRANCHER => true ,
84
84
Server::OPTION_HN_PARENT_APP => $ appName ,
85
+ Server::OPTION_HN_BRANCHER_LABELS => [],
86
+ Server::OPTION_HN_BRANCHER_SETTINGS => [],
85
87
];
86
88
$ options = array_merge ($ brancherOptions , $ options );
87
- $ server = new Server ('' , $ roles , $ options );
89
+ $ server = new BrancherServer ('' , $ roles , $ options );
88
90
$ this ->servers [] = $ server ;
89
91
return $ server ;
90
92
}
Original file line number Diff line number Diff line change 14
14
$ productionStage ->addServer ('appname.hypernode.io ' );
15
15
16
16
$ testStage = $ configuration ->addStage ('test ' , 'example.com ' );
17
- $ testStage ->addBrancherServer ('appname ' );
17
+ $ testStage ->addBrancherServer ('appname ' )
18
+ ->setLabels (['stage=test ' , 'ci_ref= ' . \getenv ('GITHUB_RUN_ID ' ) ?: 'none ' ])
19
+ ->setSettings (['cron_enabled ' => false , 'supervisor_enabled ' => false ]);
18
20
19
21
return $ configuration ;
You can’t perform that action at this time.
0 commit comments