File tree 4 files changed +58
-7
lines changed
4 files changed +58
-7
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
/**
@@ -62,9 +64,6 @@ public function getRoles(): array
62
64
return $ this ->roles ;
63
65
}
64
66
65
- /**
66
- * @return string[]
67
- */
68
67
public function getOptions (): array
69
68
{
70
69
return $ this ->options ;
@@ -78,6 +77,16 @@ public function getSshOptions(): array
78
77
return $ this ->sshOptions ;
79
78
}
80
79
80
+ /**
81
+ * @param string $option
82
+ * @param mixed $value
83
+ * @return void
84
+ */
85
+ protected function setOption (string $ option , $ value )
86
+ {
87
+ $ this ->options [$ option ] = $ value ;
88
+ }
89
+
81
90
/**
82
91
* @param $options
83
92
*/
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