1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* this file is part of pipelines */ |
4
|
|
|
|
5
|
|
|
namespace Ktomk\Pipelines\Runner; |
6
|
|
|
|
7
|
|
|
use Ktomk\Pipelines\Utility\Options; |
8
|
|
|
use Ktomk\Pipelines\Value\Prefix; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Runner options parameter object |
12
|
|
|
*/ |
13
|
|
|
class RunOpts |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
private $prefix; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var Options |
22
|
|
|
*/ |
23
|
|
|
private $options; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
private $binaryPackage; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var null|string of step expression or null if not set |
32
|
|
|
*/ |
33
|
|
|
private $steps; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var bool |
37
|
|
|
*/ |
38
|
|
|
private $noManual = false; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var null|string --user $(id -u):$(id -g) |
42
|
|
|
*/ |
43
|
|
|
private $user; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var null|true --ssh-auth |
47
|
|
|
*/ |
48
|
|
|
private $ssh; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Static factory method |
52
|
|
|
* |
53
|
|
|
* @param string $prefix [optional] |
54
|
|
|
* @param string $binaryPackage package name or path to binary (string) |
55
|
|
|
* |
56
|
|
|
* @return RunOpts |
57
|
|
|
*/ |
58
|
1 |
|
public static function create($prefix = null, $binaryPackage = null) |
59
|
|
|
{ |
60
|
1 |
|
return new self($prefix, Options::create(), $binaryPackage); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* RunOpts constructor. |
65
|
|
|
* |
66
|
|
|
* NOTE: All run options are optional by design (pass NULL). |
67
|
|
|
* |
68
|
|
|
* @param string $prefix |
69
|
|
|
* @param null|Options $options |
70
|
|
|
* @param string $binaryPackage package name or path to binary (string) |
71
|
|
|
* @param null|string $user user option, non-null (string) if set |
72
|
|
|
* @param null|true $ssh |
73
|
|
|
*/ |
74
|
2 |
|
public function __construct($prefix = null, Options $options = null, $binaryPackage = null, $user = null, $ssh = null) |
75
|
|
|
{ |
76
|
2 |
|
$this->prefix = null === $prefix ? $prefix : Prefix::verify($prefix); |
77
|
2 |
|
$this->options = $options; |
78
|
2 |
|
$this->binaryPackage = $binaryPackage; |
79
|
2 |
|
$this->user = $user; |
80
|
2 |
|
$this->ssh = $ssh; |
81
|
2 |
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $prefix |
85
|
|
|
* |
86
|
|
|
* @return void |
87
|
|
|
*/ |
88
|
1 |
|
public function setPrefix($prefix) |
89
|
|
|
{ |
90
|
1 |
|
$this->prefix = $prefix; |
91
|
1 |
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* The prefix is used when creating containers for the container name. |
95
|
|
|
* |
96
|
|
|
* See --prefix option. |
97
|
|
|
* |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
1 |
|
public function getPrefix() |
101
|
|
|
{ |
102
|
1 |
|
return $this->prefix; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param string $name |
107
|
|
|
* |
108
|
|
|
* @return null|string |
109
|
|
|
*/ |
110
|
2 |
|
public function getOption($name) |
111
|
|
|
{ |
112
|
2 |
|
if (!isset($this->options)) { |
113
|
1 |
|
return null; |
114
|
|
|
} |
115
|
|
|
|
116
|
1 |
|
return $this->options->get($name); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param string $binaryPackage |
121
|
|
|
* |
122
|
|
|
* @return void |
123
|
|
|
*/ |
124
|
1 |
|
public function setBinaryPackage($binaryPackage) |
125
|
|
|
{ |
126
|
1 |
|
$this->binaryPackage = $binaryPackage; |
127
|
1 |
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
1 |
|
public function getBinaryPackage() |
133
|
|
|
{ |
134
|
1 |
|
return $this->binaryPackage; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return null|string |
139
|
|
|
*/ |
140
|
1 |
|
public function getSteps() |
141
|
|
|
{ |
142
|
1 |
|
return $this->steps; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param null|string $steps |
147
|
|
|
* |
148
|
|
|
* @return void |
149
|
|
|
*/ |
150
|
1 |
|
public function setSteps($steps) |
151
|
|
|
{ |
152
|
1 |
|
$this->steps = $steps; |
153
|
1 |
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* @return bool |
157
|
|
|
*/ |
158
|
1 |
|
public function isNoManual() |
159
|
|
|
{ |
160
|
1 |
|
return $this->noManual; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param bool $noManual |
165
|
|
|
* |
166
|
|
|
* @return void |
167
|
|
|
*/ |
168
|
1 |
|
public function setNoManual($noManual) |
169
|
|
|
{ |
170
|
1 |
|
$this->noManual = (bool)$noManual; |
171
|
1 |
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @return null|string |
175
|
|
|
*/ |
176
|
1 |
|
public function getUser() |
177
|
|
|
{ |
178
|
1 |
|
return $this->user; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @param null|string $user |
183
|
|
|
*/ |
184
|
1 |
|
public function setUser($user) |
185
|
|
|
{ |
186
|
1 |
|
$this->user = $user; |
187
|
1 |
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @return null|true |
191
|
|
|
*/ |
192
|
1 |
|
public function getSsh() |
193
|
|
|
{ |
194
|
1 |
|
return $this->ssh; |
|
|
|
|
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* @param null|true $ssh |
199
|
|
|
*/ |
200
|
1 |
|
public function setSsh($ssh) |
201
|
|
|
{ |
202
|
1 |
|
$this->ssh = $ssh; |
203
|
1 |
|
} |
204
|
|
|
} |
205
|
|
|
|