302f1920ed9620f1f667c2b9834d70b8f55438bb
[yaffs-website] / vendor / consolidation / robo / src / Task / Docker / Commit.php
1 <?php
2 namespace Robo\Task\Docker;
3
4 /**
5  * Commits docker container to an image
6  *
7  * ```
8  * $this->taskDockerCommit($containerId)
9  *      ->name('my/database')
10  *      ->run();
11  *
12  * // alternatively you can take the result from DockerRun task:
13  *
14  * $result = $this->taskDockerRun('db')
15  *      ->exec('./prepare_database.sh')
16  *      ->run();
17  *
18  * $task->dockerCommit($result)
19  *      ->name('my/database')
20  *      ->run();
21  * ```
22  */
23 class Commit extends Base
24 {
25     /**
26      * @var string
27      */
28     protected $command = "docker commit";
29
30     /**
31      * @var string
32      */
33     protected $name;
34
35     /**
36      * @var string
37      */
38     protected $cid;
39
40     /**
41      * @param string|\Robo\Task\Docker\Result $cidOrResult
42      */
43     public function __construct($cidOrResult)
44     {
45         $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult;
46     }
47
48     /**
49      * {@inheritdoc}
50      */
51     public function getCommand()
52     {
53         return $this->command . ' ' . $this->cid . ' ' . $this->name . ' ' . $this->arguments;
54     }
55
56     /**
57      * @param $name
58      *
59      * @return $this
60      */
61     public function name($name)
62     {
63         $this->name = $name;
64         return $this;
65     }
66 }