kitchen-dokken 0.0.33 → 0.0.34

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: 1d2c56872e677b62fbf05ef40c34c09cce7563be
4
- data.tar.gz: 62d3932c0e1ad83526ea7ff40ee7007bb549ccd3
3
+ metadata.gz: df5fc9ab1a4677a9b159b88dd83550201402b1b3
4
+ data.tar.gz: 231e77bfb9af35a97d3ab0ab539d42f07c1b6378
5
5
  SHA512:
6
- metadata.gz: 3781d2441c8e0ce8330bb7ae87e0fff86b68d5779fe477fcdb909bda245eec3dfbf25656277c8775dea571d373ae663fa5daf2a1d27089c652f4baeac212305c
7
- data.tar.gz: 499b1cb0cecb49bad1459ca26ca037e31c1c8e6b16a33255897e7c0b1cc998af9ca92f2c0250afdf0e5f5e12b77b8042f8c34e557bc7edb25ede1bd695d2b5dd
6
+ metadata.gz: 50c08510ea829c301145272affec2fd5f053c674cad8dbf1e405344596d788ccb96190f722d386b2763a5232a5f9ec3a56a162a3bdfa0dc46207710d4da13b15
7
+ data.tar.gz: 97378652af596204da5a1ba946444f3a14051697bae1a0889585d12f5ebf367ff465f108c8f7acef2ef81781adfd77d90e9ffb87eb51a1346fcf868b6e2eb360
@@ -47,6 +47,7 @@ module Kitchen
47
47
  default_config :cap_add, nil
48
48
  default_config :cap_drop, nil
49
49
  default_config :security_opt, nil
50
+ default_config :forward, nil
50
51
  default_config :network_mode, 'bridge'
51
52
 
52
53
  # (see Base#create)
@@ -96,12 +97,17 @@ module Kitchen
96
97
  def delete_work_image
97
98
  return unless ::Docker::Image.exist?(work_image, docker_connection)
98
99
  with_retries { @work_image = ::Docker::Image.get(work_image, docker_connection) }
99
- with_retries { @work_image.remove(force: true) }
100
+
101
+ begin
102
+ with_retries { @work_image.remove(force: true) }
103
+ rescue ::Docker::Error::ConflictError
104
+ debug "driver - #{work_image} cannot be removed"
105
+ end
100
106
  end
101
107
 
102
108
  def build_work_image(state)
103
109
  # require 'pry' ; binding.pry
104
-
110
+
105
111
  return if ::Docker::Image.exist?(work_image, docker_connection)
106
112
 
107
113
  FileUtils.mkdir_p context_root
@@ -121,7 +127,7 @@ module Kitchen
121
127
  )
122
128
  end
123
129
  rescue Exception => e
124
- fail "work_image build failed: #{e}"
130
+ fail "work_image build failed: #{e}"
125
131
  end
126
132
  state[:work_image] = work_image
127
133
  end
@@ -195,6 +201,7 @@ module Kitchen
195
201
  'Cmd' => Shellwords.shellwords(config[:pid_one_command]),
196
202
  'Image' => "#{repo(work_image)}:#{tag(work_image)}",
197
203
  'Hostname' => config[:hostname],
204
+ 'ExposedPorts' => exposed_ports({}, config[:forward]),
198
205
  'HostConfig' => {
199
206
  'Privileged' => config[:privileged],
200
207
  'VolumesFrom' => [chef_container_name, data_container_name],
@@ -204,6 +211,7 @@ module Kitchen
204
211
  'CapDrop' => Array(config[:cap_drop]),
205
212
  'SecurityOpt' => Array(config[:security_opt]),
206
213
  'NetworkMode' => config[:network_mode],
214
+ 'PortBindings' => port_forwards({}, config[:forward]),
207
215
  }
208
216
  )
209
217
  state[:runner_container] = runner_container.json
@@ -214,11 +222,7 @@ module Kitchen
214
222
  data_container = run_container(
215
223
  'name' => data_container_name,
216
224
  'Image' => "#{repo(data_image)}:#{tag(data_image)}",
217
- 'PortBindings' => {
218
- '22/tcp' => [
219
- { 'HostPort' => '' }
220
- ]
221
- },
225
+ 'PortBindings' => port_forwards({}, "22"),
222
226
  'PublishAllPorts' => true
223
227
  )
224
228
  # require 'pry' ; binding.pry
@@ -245,7 +249,7 @@ module Kitchen
245
249
  )
246
250
  state[:chef_container] = chef_container.json
247
251
  rescue
248
- debug "driver - #{chef_container_name} alreay exists"
252
+ debug "driver - #{chef_container_name} already exists"
249
253
  end
250
254
  end
251
255
 
@@ -360,12 +364,30 @@ module Kitchen
360
364
  config[:image]
361
365
  end
362
366
 
367
+ def exposed_ports(config, rules)
368
+ Array(rules).each do |prt_string|
369
+ guest, host = prt_string.to_s.split(":").reverse
370
+ config["#{guest}/tcp"] = {}
371
+ end
372
+ config
373
+ end
374
+
375
+ def port_forwards(config, rules)
376
+ Array(rules).each do |prt_string|
377
+ guest, host = prt_string.to_s.split(":").reverse
378
+ config["#{guest}/tcp"] = [{
379
+ :HostPort => host || ''
380
+ }]
381
+ end
382
+ config
383
+ end
384
+
363
385
  def pull_if_missing(image)
364
386
  return if ::Docker::Image.exist?("#{repo(image)}:#{tag(image)}", docker_connection)
365
387
  pull_image image
366
388
  end
367
389
 
368
- def pull_image(image)
390
+ def pull_image(image)
369
391
  with_retries {
370
392
  ::Docker::Image.create({ 'fromImage' => "#{repo(image)}:#{tag(image)}" }, docker_connection)
371
393
  }
@@ -19,6 +19,6 @@
19
19
  module Kitchen
20
20
  module Driver
21
21
  # Version string for Dokken Kitchen driver
22
- DOKKEN_VERSION = '0.0.33'
22
+ DOKKEN_VERSION = '0.0.34'
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-dokken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean OMeara