1 | <?php |
||
11 | class Vacuum |
||
12 | { |
||
13 | /** |
||
14 | * @var \Docker\Docker Docker API Client |
||
15 | */ |
||
16 | private $docker; |
||
17 | |||
18 | /** |
||
19 | * @var Naming Service use to create name for image and project |
||
20 | */ |
||
21 | private $naming; |
||
22 | |||
23 | /** |
||
24 | * @var BuildStrategy\BuildStrategyInterface Strategy where we want to clean the builds |
||
25 | */ |
||
26 | private $strategy; |
||
27 | |||
28 | /** |
||
29 | * @var string Location where the build are |
||
30 | */ |
||
31 | private $buildPath; |
||
32 | |||
33 | /** |
||
34 | * @var \Joli\JoliCi\Filesystem\Filesystem |
||
35 | */ |
||
36 | private $filesystem; |
||
37 | |||
38 | /** |
||
39 | * @param Docker $docker Docker API Client |
||
40 | * @param Naming $naming Naming service |
||
41 | * @param BuildStrategyInterface $strategy Strategy used to create builds |
||
42 | * @param Filesystem $filesystem Filesystem service |
||
43 | * @param string $buildPath Directory where builds are created |
||
44 | */ |
||
45 | public function __construct(Docker $docker, Naming $naming, BuildStrategyInterface $strategy, Filesystem $filesystem, $buildPath) |
||
53 | |||
54 | /** |
||
55 | * Clean containers, images and directory from a project |
||
56 | * |
||
57 | * @param string $projectPath Location of the project |
||
58 | * @param int $keep How many versions does we need to keep (1 is the default in order to have cache for each test) |
||
59 | * @param boolean $force Force removal for images |
||
60 | */ |
||
61 | public function clean($projectPath, $keep = 1, $force = false) |
||
69 | |||
70 | /** |
||
71 | * Clean directories for given builds |
||
72 | * |
||
73 | * @param \Joli\JoliCi\Job[] $jobs A list of jobs to remove images from |
||
74 | */ |
||
75 | public function cleanDirectories($jobs = array()) |
||
81 | |||
82 | /** |
||
83 | * Clean images for given builds |
||
84 | * |
||
85 | * @param \Joli\JoliCi\Job[] $jobs A list of jobs to remove images from |
||
86 | */ |
||
87 | public function cleanContainers($jobs = array()) |
||
121 | |||
122 | /** |
||
123 | * Clean images for given builds |
||
124 | * |
||
125 | * @param \Joli\JoliCi\Job[] $jobs A list of jobs to remove images from |
||
126 | * @param boolean $force Force removal for images |
||
127 | */ |
||
128 | public function cleanImages($jobs = array(), $force = false) |
||
136 | |||
137 | /** |
||
138 | * Get all jobs to remove given a project and how many versions to keep |
||
139 | * |
||
140 | * @param string $projectPath The project path |
||
141 | * @param int $keep Number of project to keep |
||
142 | * |
||
143 | * @return \Joli\JoliCi\Job[] A list of jobs to remove |
||
144 | */ |
||
145 | public function getJobsToRemove($projectPath, $keep = 1) |
||
179 | |||
180 | /** |
||
181 | * Get all jobs related to a project |
||
182 | * |
||
183 | * @param string $projectPath Directory where the project is |
||
184 | * |
||
185 | * @return \Joli\JoliCi\Job[] |
||
186 | */ |
||
187 | protected function getJobs($projectPath) |
||
203 | |||
204 | /** |
||
205 | * Create a job from a docker image |
||
206 | * |
||
207 | * @param ImageItem $image |
||
208 | * @param string $strategy |
||
209 | * @param string $project |
||
210 | * |
||
211 | * @return \Joli\JoliCi\Job |
||
212 | */ |
||
213 | protected function getJobFromImage(ImageItem $image, $imageName, $strategy, $project) |
||
220 | } |
||
221 |