kitchen-docker_cli 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +15 -0
- data/lib/kitchen/driver/docker_cli.rb +18 -6
- data/lib/kitchen/driver/docker_cli_version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cf7d32aaf8c8c0a88609685e0f7a0796c5f1dd4
|
4
|
+
data.tar.gz: 90bd2649a796053fd6f7a652849720134a73c785
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eb36eefabfac676adef52433aa4d944d41e8e81b772463f28a28d31898eda7a86415ebb9dd4659083ca8aab56d56456c3d64b49f697130b18243fd4b409277c
|
7
|
+
data.tar.gz: 0a066b16e595bb25bb68ba5729f306033d3305b3b4a60d75b820cd1fa81e0cabdd715e42f69a9566c1262561d314a496d2802067dcf833aa11b948eea239ca6c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -200,6 +200,21 @@ Examples:
|
|
200
200
|
instance_container_name: true
|
201
201
|
```
|
202
202
|
|
203
|
+
|
204
|
+
### destroy_container_name
|
205
|
+
|
206
|
+
Improve destroy action when containers have defined names.
|
207
|
+
|
208
|
+
When enabled, "kitchen destroy" will always try to remove suite containers with their name (if defined by container_name or instance_container_name options) in addition to with the id defined in the current state. This allows a clean removal of containers even if the state is corrupted or was removed.
|
209
|
+
|
210
|
+
The default value is `true`.
|
211
|
+
|
212
|
+
Examples:
|
213
|
+
|
214
|
+
```yml
|
215
|
+
destroy_container_name: false
|
216
|
+
```
|
217
|
+
|
203
218
|
### network
|
204
219
|
|
205
220
|
Set the Network mode for the container.
|
@@ -37,6 +37,7 @@ module Kitchen
|
|
37
37
|
default_config :transport, "docker_cli"
|
38
38
|
default_config :dockerfile_vars, {}
|
39
39
|
default_config :skip_preparation, false
|
40
|
+
default_config :destroy_container_name, true
|
40
41
|
|
41
42
|
default_config :image do |driver|
|
42
43
|
driver.default_image
|
@@ -66,7 +67,14 @@ module Kitchen
|
|
66
67
|
def destroy(state)
|
67
68
|
instance.transport.connection(state) do |conn|
|
68
69
|
begin
|
69
|
-
|
70
|
+
if state[:container_id]
|
71
|
+
output = conn.run_docker("ps -a -q -f id=#{state[:container_id]}").chomp
|
72
|
+
conn.run_docker("rm -f #{state[:container_id]}") unless output.empty?
|
73
|
+
end
|
74
|
+
if config[:destroy_container_name] && container_name
|
75
|
+
output = conn.run_docker("ps -a -q -f name=#{container_name}").chomp
|
76
|
+
conn.run_docker("rm -f #{container_name}") unless output.empty?
|
77
|
+
end
|
70
78
|
rescue => e
|
71
79
|
raise e unless conn.send(:options)[:lxc_driver]
|
72
80
|
end
|
@@ -101,11 +109,7 @@ module Kitchen
|
|
101
109
|
|
102
110
|
def docker_run_command(image)
|
103
111
|
cmd = String.new("run -d -t")
|
104
|
-
if
|
105
|
-
cmd << " --name #{config[:container_name]}"
|
106
|
-
elsif config[:instance_container_name]
|
107
|
-
cmd << " --name #{instance.name}"
|
108
|
-
end
|
112
|
+
cmd << " --name #{container_name}" if container_name
|
109
113
|
cmd << ' -P' if config[:publish_all]
|
110
114
|
cmd << " -m #{config[:memory_limit]}" if config[:memory_limit]
|
111
115
|
cmd << " -c #{config[:cpu_shares]}" if config[:cpu_shares]
|
@@ -127,6 +131,14 @@ module Kitchen
|
|
127
131
|
cmd << " #{image} #{config[:command]}"
|
128
132
|
end
|
129
133
|
|
134
|
+
def container_name
|
135
|
+
if config[:container_name]
|
136
|
+
config[:container_name]
|
137
|
+
elsif config[:instance_container_name]
|
138
|
+
instance.name
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
130
142
|
def parse_image_id(output)
|
131
143
|
unless output.chomp.match(/Successfully built ([0-9a-z]{12})$/)
|
132
144
|
raise ActionFailed, 'Could not parse IMAGE ID.'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-docker_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masashi Terui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|