1 | <?php |
||
16 | class ComposeManager |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * Start service containers |
||
21 | * |
||
22 | * @param mixed $composeFiles The compose files names |
||
23 | */ |
||
24 | public function start($composeFiles = array()) |
||
32 | |||
33 | /** |
||
34 | * Stop service containers |
||
35 | * |
||
36 | * @param mixed $composeFiles The compose files names |
||
37 | */ |
||
38 | public function stop($composeFiles = array()) |
||
46 | |||
47 | /** |
||
48 | * Stop service containers |
||
49 | * |
||
50 | * @param mixed $composeFiles The compose files names |
||
51 | * @param boolean $force If the remove need to be force (default=false) |
||
52 | * @param boolean $removeVolumes If we need to remove the volumes (default=false) |
||
53 | */ |
||
54 | public function remove($composeFiles = array(), $force = false, $removeVolumes = false) |
||
71 | |||
72 | /** |
||
73 | * Build service images |
||
74 | */ |
||
75 | public function build($composeFiles = array()) |
||
83 | |||
84 | /** |
||
85 | * Run service with command |
||
86 | * |
||
87 | * @param string $service Service name |
||
88 | * @param string $command Command to pass to service |
||
89 | * @param mixed $composeFiles The compose files names |
||
90 | */ |
||
91 | public function run($service, $command, $composeFiles = array()) |
||
104 | |||
105 | /** |
||
106 | * Process result with returned code and output |
||
107 | * |
||
108 | * @param array $result The result of command with output and returnCode |
||
109 | * |
||
110 | * @throws DockerInstallationMissingException When returned code is 127 |
||
111 | * @throws ComposeFileNotFoundException When no compose file precise and docker-compose.yml not found |
||
112 | * @throws DockerHostConnexionErrorException When we can't connect to docker host |
||
113 | * @throws \Exception When an unknown error is returned |
||
114 | */ |
||
115 | private function processResult($result) |
||
135 | |||
136 | /** |
||
137 | * Create the composeFileCollection from the type of value given |
||
138 | * |
||
139 | * @param mixed $composeFiles The docker-compose files (can be array, string or ComposeFile) |
||
140 | * |
||
141 | * @return ComposeFileCollection |
||
142 | */ |
||
143 | private function createComposeFileCollection($composeFiles) |
||
155 | |||
156 | /** |
||
157 | * Format the command to execute |
||
158 | * |
||
159 | * @param string $subcommand The subcommand to pass to docker-compose command |
||
160 | * @param ComposeFileCollection $composeFiles The compose files to precise in the command |
||
161 | */ |
||
162 | private function formatCommand($subcommand, ComposeFileCollection $composeFiles) |
||
189 | |||
190 | /** |
||
191 | * Execute docker-compose commande |
||
192 | * @codeCoverageIgnore |
||
193 | * @param string $command The command to execute |
||
194 | */ |
||
195 | protected function execute($command) |
||
210 | } |
||
211 |