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 88class Server
99{
1010 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 ' ;
1113 public const OPTION_HN_PARENT_APP = 'hn_parent_app ' ;
1214
1315 /**
@@ -20,10 +22,7 @@ class Server
2022 */
2123 private $ roles ;
2224
23- /**
24- * @var string[]
25- */
26- private $ options = [];
25+ private array $ options ;
2726
2827 /**
2928 * @var string[]
@@ -32,7 +31,6 @@ class Server
3231
3332 /**
3433 * @param string[] $roles
35- * @param string[] $options
3634 */
3735 public function __construct (string $ hostname , array $ roles = null , array $ options = [])
3836 {
@@ -62,9 +60,6 @@ public function getRoles(): array
6260 return $ this ->roles ;
6361 }
6462
65- /**
66- * @return string[]
67- */
6863 public function getOptions (): array
6964 {
7065 return $ this ->options ;
@@ -78,6 +73,16 @@ public function getSshOptions(): array
7873 return $ this ->sshOptions ;
7974 }
8075
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+
8186 /**
8287 * @param $options
8388 */
Original file line number Diff line number Diff line change @@ -75,16 +75,18 @@ public function addServer(
7575 * @param array|null $roles Roles for the server to be applied
7676 * @param array $options Extra host options for Deployer
7777 * @see ServerRole
78- * @return Server
78+ * @return BrancherServer
7979 */
80- public function addBrancherServer (string $ appName , array $ roles = null , array $ options = []): Server
80+ public function addBrancherServer (string $ appName , array $ roles = null , array $ options = []): BrancherServer
8181 {
8282 $ brancherOptions = [
8383 Server::OPTION_HN_BRANCHER => true ,
8484 Server::OPTION_HN_PARENT_APP => $ appName ,
85+ Server::OPTION_HN_BRANCHER_LABELS => [],
86+ Server::OPTION_HN_BRANCHER_SETTINGS => [],
8587 ];
8688 $ options = array_merge ($ brancherOptions , $ options );
87- $ server = new Server ('' , $ roles , $ options );
89+ $ server = new BrancherServer ('' , $ roles , $ options );
8890 $ this ->servers [] = $ server ;
8991 return $ server ;
9092 }
Original file line number Diff line number Diff line change 1414$ productionStage ->addServer ('appname.hypernode.io ' );
1515
1616$ 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 ]);
1820
1921return $ configuration ;
You can’t perform that action at this time.
0 commit comments