kitchen-dokken 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df5fc9ab1a4677a9b159b88dd83550201402b1b3
4
- data.tar.gz: 231e77bfb9af35a97d3ab0ab539d42f07c1b6378
3
+ metadata.gz: 9bd5711a6236c9c2dc47a25a39f8ae501f1028bf
4
+ data.tar.gz: ec7bcf47d0e3fda4f7d8cf7acb2b244f988623ec
5
5
  SHA512:
6
- metadata.gz: 50c08510ea829c301145272affec2fd5f053c674cad8dbf1e405344596d788ccb96190f722d386b2763a5232a5f9ec3a56a162a3bdfa0dc46207710d4da13b15
7
- data.tar.gz: 97378652af596204da5a1ba946444f3a14051697bae1a0889585d12f5ebf367ff465f108c8f7acef2ef81781adfd77d90e9ffb87eb51a1346fcf868b6e2eb360
6
+ metadata.gz: 0b98109b62876a75718afbdc3dc69fcf14179ca1b6d5b2de194d70f301a1755e49196a96c530fd96c1001186b24e3f73ebf61e6abf9aa0676beb897adc279ce7
7
+ data.tar.gz: 3eb5d9079cb646069be4203954d69e2a94090b2c48a9cf57f343a3c834cb3ef5a5fd1ac69e11443d456658e2192a3e5ff91ed5651847767b88ff9464da1539b0
@@ -110,31 +110,26 @@ module Kitchen
110
110
 
111
111
  return if ::Docker::Image.exist?(work_image, docker_connection)
112
112
 
113
- FileUtils.mkdir_p context_root
114
- File.write("#{context_root}/Dockerfile", work_image_dockerfile)
115
-
116
- begin
117
- with_retries do
118
- @intermediate_image = ::Docker::Image.build_from_dir(
119
- context_root,
120
- {
121
- # 'nocache' => true,
122
- # 'forcerm' => true,
123
- # 'q' => true,
124
- 't' => work_image
125
- },
126
- docker_connection
127
- )
113
+ Dir.mktmpdir do |context_root|
114
+ File.write("#{context_root}/Dockerfile", work_image_dockerfile)
115
+ begin
116
+ with_retries do
117
+ @intermediate_image = ::Docker::Image.build_from_dir(
118
+ context_root,
119
+ {
120
+ # 'nocache' => true,
121
+ # 'forcerm' => true,
122
+ # 'q' => true,
123
+ 't' => work_image
124
+ },
125
+ docker_connection
126
+ )
127
+ end
128
+ rescue Exception => e
129
+ raise "work_image build failed: #{e}"
128
130
  end
129
- rescue Exception => e
130
- fail "work_image build failed: #{e}"
131
+ state[:work_image] = work_image
131
132
  end
132
- state[:work_image] = work_image
133
- end
134
-
135
- def context_root
136
- tmpdir = Dir.tmpdir
137
- "#{tmpdir}/dokken/#{instance_name}"
138
133
  end
139
134
 
140
135
  def work_image_dockerfile
@@ -211,7 +206,7 @@ module Kitchen
211
206
  'CapDrop' => Array(config[:cap_drop]),
212
207
  'SecurityOpt' => Array(config[:security_opt]),
213
208
  'NetworkMode' => config[:network_mode],
214
- 'PortBindings' => port_forwards({}, config[:forward]),
209
+ 'PortBindings' => port_forwards({}, config[:forward])
215
210
  }
216
211
  )
217
212
  state[:runner_container] = runner_container.json
@@ -222,7 +217,7 @@ module Kitchen
222
217
  data_container = run_container(
223
218
  'name' => data_container_name,
224
219
  'Image' => "#{repo(data_image)}:#{tag(data_image)}",
225
- 'PortBindings' => port_forwards({}, "22"),
220
+ 'PortBindings' => port_forwards({}, '22'),
226
221
  'PublishAllPorts' => true
227
222
  )
228
223
  # require 'pry' ; binding.pry
@@ -304,24 +299,20 @@ module Kitchen
304
299
  end
305
300
 
306
301
  def stop_container(name)
307
- begin
308
- with_retries { @container = ::Docker::Container.get(name, docker_connection) }
309
- with_retries do
310
- @container.stop(force: true)
311
- wait_running_state(name, false)
312
- end
313
- rescue ::Docker::Error::NotFoundError
314
- debug "Container #{name} not found. Nothing to stop."
302
+ with_retries { @container = ::Docker::Container.get(name, docker_connection) }
303
+ with_retries do
304
+ @container.stop(force: true)
305
+ wait_running_state(name, false)
315
306
  end
307
+ rescue ::Docker::Error::NotFoundError
308
+ debug "Container #{name} not found. Nothing to stop."
316
309
  end
317
310
 
318
311
  def delete_container(name)
319
- begin
320
- with_retries { @container = ::Docker::Container.get(name, docker_connection) }
321
- with_retries { @container.delete(force: true, v: true) }
322
- rescue ::Docker::Error::NotFoundError
323
- debug "Container #{name} not found. Nothing to delete."
324
- end
312
+ with_retries { @container = ::Docker::Container.get(name, docker_connection) }
313
+ with_retries { @container.delete(force: true, v: true) }
314
+ rescue ::Docker::Error::NotFoundError
315
+ debug "Container #{name} not found. Nothing to delete."
325
316
  end
326
317
 
327
318
  def wait_running_state(name, v)
@@ -366,7 +357,7 @@ module Kitchen
366
357
 
367
358
  def exposed_ports(config, rules)
368
359
  Array(rules).each do |prt_string|
369
- guest, host = prt_string.to_s.split(":").reverse
360
+ guest, host = prt_string.to_s.split(':').reverse
370
361
  config["#{guest}/tcp"] = {}
371
362
  end
372
363
  config
@@ -374,9 +365,9 @@ module Kitchen
374
365
 
375
366
  def port_forwards(config, rules)
376
367
  Array(rules).each do |prt_string|
377
- guest, host = prt_string.to_s.split(":").reverse
368
+ guest, host = prt_string.to_s.split(':').reverse
378
369
  config["#{guest}/tcp"] = [{
379
- :HostPort => host || ''
370
+ HostPort: host || ''
380
371
  }]
381
372
  end
382
373
  config
@@ -388,20 +379,20 @@ module Kitchen
388
379
  end
389
380
 
390
381
  def pull_image(image)
391
- with_retries {
382
+ with_retries do
392
383
  ::Docker::Image.create({ 'fromImage' => "#{repo(image)}:#{tag(image)}" }, docker_connection)
393
- }
384
+ end
394
385
  end
395
386
 
396
387
  def runner_container_name
397
- "#{instance_name}"
388
+ instance_name.to_s
398
389
  end
399
390
 
400
- def with_retries(&block)
391
+ def with_retries
401
392
  tries = api_retries
402
393
  begin
403
- block.call
404
- # Only catch errors that can be fixed with retries.
394
+ yield
395
+ # Only catch errors that can be fixed with retries.
405
396
  rescue ::Docker::Error::ServerError, # 404
406
397
  ::Docker::Error::UnexpectedResponseError, # 400
407
398
  ::Docker::Error::TimeoutError,
@@ -54,7 +54,7 @@ EOF
54
54
  File.write("#{tmpdir}/dokken/Dockerfile", data_dockerfile)
55
55
  File.write("#{tmpdir}/dokken/authorized_keys", insecure_ssh_public_key)
56
56
 
57
- i = ::Docker::Image.build_from_dir("#{tmpdir}/dokken", { 'nocache' => true, 'rm' => true })
57
+ i = ::Docker::Image.build_from_dir("#{tmpdir}/dokken", 'nocache' => true, 'rm' => true)
58
58
  i.tag('repo' => repo(data_image), 'tag' => tag(data_image), 'force' => true)
59
59
  end
60
60
  end
@@ -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.34'
22
+ DOKKEN_VERSION = '0.0.35'.freeze
23
23
  end
24
24
  end
@@ -59,7 +59,7 @@ module Kitchen
59
59
  end
60
60
 
61
61
  def runner_container_name
62
- "#{instance.name}"
62
+ instance.name.to_s
63
63
  end
64
64
  end
65
65
  end
@@ -65,13 +65,13 @@ module Kitchen
65
65
 
66
66
  with_retries { @runner = ::Docker::Container.get(instance_name, {}, docker_connection) }
67
67
  with_retries do
68
- o = @runner.exec(Shellwords.shellwords(command)) { |_stream, chunk| print "#{chunk}" }
68
+ o = @runner.exec(Shellwords.shellwords(command)) { |_stream, chunk| print chunk.to_s }
69
69
  @exit_code = o[2]
70
70
  end
71
71
 
72
72
  if @exit_code != 0
73
- fail Transport::DockerExecFailed,
74
- "Docker Exec (#{@exit_code}) for command: [#{command}]"
73
+ raise Transport::DockerExecFailed,
74
+ "Docker Exec (#{@exit_code}) for command: [#{command}]"
75
75
  end
76
76
 
77
77
  # Disabling this for now.. the Docker ZFS driver won't let us
@@ -93,7 +93,7 @@ module Kitchen
93
93
  elsif options[:docker_host_url] =~ /tcp:/
94
94
  ip = options[:docker_host_url].split('tcp://')[1].split(':')[0]
95
95
  else
96
- fail Kitchen::UserError, 'docker_host_url must be tcp:// or unix://'
96
+ raise Kitchen::UserError, 'docker_host_url must be tcp:// or unix://'
97
97
  end
98
98
 
99
99
  port = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostPort]
@@ -120,7 +120,7 @@ module Kitchen
120
120
  end
121
121
 
122
122
  def login_command
123
- @runner = "#{options[:instance_name]}"
123
+ @runner = options[:instance_name].to_s
124
124
  args = ['exec', '-it', @runner, '/bin/bash', '-login', '-i']
125
125
  LoginCommand.new('docker', args)
126
126
  end
@@ -140,10 +140,10 @@ module Kitchen
140
140
  options[:image_prefix]
141
141
  end
142
142
 
143
- def with_retries(&block)
143
+ def with_retries
144
144
  tries = 20
145
145
  begin
146
- block.call
146
+ yield
147
147
  # Only catch errors that can be fixed with retries.
148
148
  rescue ::Docker::Error::ServerError, # 404
149
149
  ::Docker::Error::UnexpectedResponseError, # 400
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-dokken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.34
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean OMeara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-09 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -55,7 +55,7 @@ files:
55
55
  - lib/kitchen/transport/dokken/helpers.rb
56
56
  homepage: https://github.com/someara/kitchen-dokken
57
57
  licenses:
58
- - Apache 2.0
58
+ - Apache-2.0
59
59
  metadata: {}
60
60
  post_install_message:
61
61
  rdoc_options: []