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
|
|
|
* Static factory method |
47
|
|
|
* |
48
|
|
|
* @param string $prefix [optional] |
49
|
|
|
* @param string $binaryPackage package name or path to binary (string) |
50
|
|
|
* |
51
|
|
|
* @return RunOpts |
52
|
|
|
*/ |
53
|
1 |
|
public static function create($prefix = null, $binaryPackage = null) |
54
|
|
|
{ |
55
|
1 |
|
return new self($prefix, Options::create(), $binaryPackage); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* RunOpts constructor. |
60
|
|
|
* |
61
|
|
|
* NOTE: All run options are optional by design (pass NULL). |
62
|
|
|
* |
63
|
|
|
* @param string $prefix |
64
|
|
|
* @param null|Options $options |
65
|
|
|
* @param string $binaryPackage package name or path to binary (string) |
66
|
|
|
* @param null|string $user user option, non-null (string) if set |
67
|
|
|
*/ |
68
|
2 |
|
public function __construct($prefix = null, Options $options = null, $binaryPackage = null, $user = null) |
69
|
|
|
{ |
70
|
2 |
|
$this->prefix = null === $prefix ? $prefix : Prefix::verify($prefix); |
71
|
2 |
|
$this->options = $options; |
72
|
2 |
|
$this->binaryPackage = $binaryPackage; |
73
|
2 |
|
$this->user = $user; |
74
|
2 |
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param string $prefix |
78
|
|
|
* |
79
|
|
|
* @return void |
80
|
|
|
*/ |
81
|
1 |
|
public function setPrefix($prefix) |
82
|
|
|
{ |
83
|
1 |
|
$this->prefix = $prefix; |
84
|
1 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* The prefix is used when creating containers for the container name. |
88
|
|
|
* |
89
|
|
|
* See --prefix option. |
90
|
|
|
* |
91
|
|
|
* @return string |
92
|
|
|
*/ |
93
|
1 |
|
public function getPrefix() |
94
|
|
|
{ |
95
|
1 |
|
return $this->prefix; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param string $name |
100
|
|
|
* |
101
|
|
|
* @return null|string |
102
|
|
|
*/ |
103
|
2 |
|
public function getOption($name) |
104
|
|
|
{ |
105
|
2 |
|
if (!isset($this->options)) { |
106
|
1 |
|
return null; |
107
|
|
|
} |
108
|
|
|
|
109
|
1 |
|
return $this->options->get($name); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param string $binaryPackage |
114
|
|
|
* |
115
|
|
|
* @return void |
116
|
|
|
*/ |
117
|
1 |
|
public function setBinaryPackage($binaryPackage) |
118
|
|
|
{ |
119
|
1 |
|
$this->binaryPackage = $binaryPackage; |
120
|
1 |
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @return string |
124
|
|
|
*/ |
125
|
1 |
|
public function getBinaryPackage() |
126
|
|
|
{ |
127
|
1 |
|
return $this->binaryPackage; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return null|string |
132
|
|
|
*/ |
133
|
1 |
|
public function getSteps() |
134
|
|
|
{ |
135
|
1 |
|
return $this->steps; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param null|string $steps |
140
|
|
|
* |
141
|
|
|
* @return void |
142
|
|
|
*/ |
143
|
1 |
|
public function setSteps($steps) |
144
|
|
|
{ |
145
|
1 |
|
$this->steps = $steps; |
146
|
1 |
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @return bool |
150
|
|
|
*/ |
151
|
1 |
|
public function isNoManual() |
152
|
|
|
{ |
153
|
1 |
|
return $this->noManual; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param bool $noManual |
158
|
|
|
* |
159
|
|
|
* @return void |
160
|
|
|
*/ |
161
|
1 |
|
public function setNoManual($noManual) |
162
|
|
|
{ |
163
|
1 |
|
$this->noManual = (bool)$noManual; |
164
|
1 |
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return null|string |
168
|
|
|
*/ |
169
|
1 |
|
public function getUser() |
170
|
|
|
{ |
171
|
1 |
|
return $this->user; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @param null|string $user |
176
|
|
|
*/ |
177
|
1 |
|
public function setUser($user) |
178
|
|
|
{ |
179
|
1 |
|
$this->user = $user; |
180
|
1 |
|
} |
181
|
|
|
} |
182
|
|
|
|