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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8dceb30441238af20e54085bd05246412ab6998
4
- data.tar.gz: ae5298feb43f10dc1cc88f93d261eba51c21abee
3
+ metadata.gz: 4cf7d32aaf8c8c0a88609685e0f7a0796c5f1dd4
4
+ data.tar.gz: 90bd2649a796053fd6f7a652849720134a73c785
5
5
  SHA512:
6
- metadata.gz: 0ac22c3ec44a358a8df46775fb2e333a31a3f9ef31b25eeaade96d3516ad2e4bcef3ea4ee742df8bd4c51152642e23fa95ca99fa9ef97726501365874b2c1df3
7
- data.tar.gz: 6a0300dd26598046315f2cf8b68d9c26de76d26ae29892b4fb7804d0d86e5ec3556b3cf139cea0ee055fe0560e8ed714317d4d8576057653d525c2a3a7ef6421
6
+ metadata.gz: 4eb36eefabfac676adef52433aa4d944d41e8e81b772463f28a28d31898eda7a86415ebb9dd4659083ca8aab56d56456c3d64b49f697130b18243fd4b409277c
7
+ data.tar.gz: 0a066b16e595bb25bb68ba5729f306033d3305b3b4a60d75b820cd1fa81e0cabdd715e42f69a9566c1262561d314a496d2802067dcf833aa11b948eea239ca6c
@@ -1,3 +1,8 @@
1
+ ## 0.18.0
2
+
3
+ * Pull request [#33][]: Strengthen destroy ([@s-bernard][])
4
+ * Pull request [#33][]: Add `destroy_container_name` option ([@s-bernard][])
5
+
1
6
  ## 0.17.0
2
7
 
3
8
  * Pull request [#32][]: Add ability to configure security options ([@fphilippon][])
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
- conn.run_docker("rm -f #{state[:container_id]}") if state[:container_id]
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 config[:container_name]
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.'
@@ -21,6 +21,6 @@ module Kitchen
21
21
  module Driver
22
22
 
23
23
  # Version string for DockerCli Kitchen driver
24
- DOCKER_CLI_VERSION = '0.17.0'
24
+ DOCKER_CLI_VERSION = '0.18.0'
25
25
  end
26
26
  end
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.17.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-07-04 00:00:00.000000000 Z
11
+ date: 2016-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen