kitchen-dokken 0.0.2 → 0.0.3

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: 7b7c6e90633d7f197e5eba5b0f787cddb34278fe
4
- data.tar.gz: 7bb46d28bfb95681ef03a14e04ec8ad61ed7f45f
3
+ metadata.gz: 88d6029b483e226cbc957fe69b74ca84c82e4056
4
+ data.tar.gz: 807b3e3bc5eafc95bfecf839fcf1e1c0c9299b95
5
5
  SHA512:
6
- metadata.gz: 1aa4885d08709c86d31dde98a254aaabffae1aded7ed328fa2615a0f9b22cf86d3291590b59d249a14fe58a1eb751bb8b0c5c1f211f5fce0f808bd15a0a85ff8
7
- data.tar.gz: c328e1cc4f336024a7868a41832e954c06a68a501ca4a2cbc7615d32d797d11b30004c136a0add9ab8e1fda153617f7d18ebcfb9d5b1ea449f6816d7078440d4
6
+ metadata.gz: 82bae93221009e3db53506225c4b45ec0ecd4ccef1b6f506e48f219c2c6e5288269e1a5850f0f8df3d5a230e058d0244dbe84be1c00d7768d32ff8071b737eac
7
+ data.tar.gz: 528058ab13a004529bf4acc8f330f9c0eb2e1f2b79097bf5d18f02e66a72c38b321974dfb169f166f23ce7c5122549d8738a8a8005ccb63102ce567ba032d659
@@ -31,12 +31,14 @@ module Kitchen
31
31
  #
32
32
  # @author Sean OMeara <sean@chef.io>
33
33
  class Dokken < Kitchen::Driver::Base
34
- default_config :docker_host, ENV['DOCKER_HOST'] || 'unix:///var/run/docker.sock'
35
34
  default_config :pid_one_command, 'sh -c "trap exit 0 SIGTERM; while :; do sleep 1; done"'
36
35
  default_config :privileged, false
37
36
  default_config :image_prefix, nil
38
37
  default_config :chef_version, '12.5.1'
39
38
  default_config :data_image, 'someara/kitchen-cache:latest'
39
+ default_config :docker_host_url, ENV['DOCKER_HOST'] || 'unix:///var/run/docker.sock'
40
+ default_config :read_timeout, 3600
41
+ default_config :write_timeout, 3600
40
42
 
41
43
  # (see Base#create)
42
44
  def create(state)
@@ -69,28 +71,26 @@ module Kitchen
69
71
 
70
72
  private
71
73
 
72
- def connection
73
- @connection ||= begin
74
- opts = Docker.options
75
- opts[:read_timeout] = 3600
76
- opts[:write_timeout] = 3600
77
- Docker::Connection.new(config[:docker_host], opts)
78
- end
74
+ def docker_connection
75
+ opts = Docker.options
76
+ opts[:read_timeout] = config[:read_timeout]
77
+ opts[:write_timeout] = config[:write_timeout]
78
+ @docker_connection ||= Docker::Connection.new(config[:docker_host_url], opts)
79
79
  end
80
80
 
81
81
  def delete_work_image
82
- return unless Docker::Image.exist?(work_image, connection)
83
- i = Docker::Image.get(work_image, connection)
82
+ return unless Docker::Image.exist?(work_image, docker_connection)
83
+ i = Docker::Image.get(work_image, docker_connection)
84
84
  i.remove(force: true)
85
85
  end
86
86
 
87
87
  def build_work_image(state)
88
- return if Docker::Image.exist?(work_image, connection)
88
+ return if Docker::Image.exist?(work_image, docker_connection)
89
89
 
90
90
  FileUtils.mkdir_p context_root
91
91
  File.write("#{context_root}/Dockerfile", work_image_dockerfile)
92
92
 
93
- i = Docker::Image.build_from_dir(context_root, { 'nocache' => true, 'rm' => true }, connection)
93
+ i = Docker::Image.build_from_dir(context_root, { 'nocache' => true, 'rm' => true }, docker_connection)
94
94
  i.tag('repo' => repo(work_image), 'tag' => tag(work_image), 'force' => true)
95
95
  state[:work_image] = work_image
96
96
  end
@@ -210,7 +210,7 @@ module Kitchen
210
210
  end
211
211
 
212
212
  def delete_image(name)
213
- i = Docker::Image.get(name, connection)
213
+ i = Docker::Image.get(name, docker_connection)
214
214
  i.remove(force: true)
215
215
  rescue Docker::Error => e
216
216
  puts "Image #{name} not found. Nothing to delete."
@@ -229,7 +229,7 @@ module Kitchen
229
229
  end
230
230
 
231
231
  def delete_container(name)
232
- c = Docker::Container.get(name, connection)
232
+ c = Docker::Container.get(name, docker_connection)
233
233
  puts "Destroying container #{name}."
234
234
  c.stop
235
235
  c.delete(force: true, v: true)
@@ -244,7 +244,7 @@ module Kitchen
244
244
  end
245
245
 
246
246
  def create_container(args)
247
- c = Docker::Container.create(args.clone, connection)
247
+ c = Docker::Container.create(args.clone, docker_connection)
248
248
  rescue Docker::Error::ConflictError
249
249
  c = Docker::Container.get(args['name'])
250
250
  end
@@ -259,14 +259,14 @@ module Kitchen
259
259
 
260
260
  def pull_image(image)
261
261
  retries ||= 3
262
- Docker::Image.create({ 'fromImage' => repo(image), 'tag' => tag(image) }, connection)
262
+ Docker::Image.create({ 'fromImage' => repo(image), 'tag' => tag(image) }, docker_connection)
263
263
  rescue Docker::Error => e
264
264
  retry unless (tries -= 1).zero?
265
265
  raise e.message
266
266
  end
267
267
 
268
268
  def pull_if_missing(image)
269
- return if Docker::Image.exist?("#{repo(image)}:#{tag(image)}", connection)
269
+ return if Docker::Image.exist?("#{repo(image)}:#{tag(image)}", docker_connection)
270
270
  pull_image image
271
271
  end
272
272
 
@@ -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.2'
22
+ DOKKEN_VERSION = '0.0.3'
23
23
  end
24
24
  end
@@ -38,6 +38,7 @@ module Kitchen
38
38
 
39
39
  plugin_version Kitchen::VERSION
40
40
 
41
+ default_config :docker_host_url, ENV['DOCKER_HOST'] || 'unix:///var/run/docker.sock'
41
42
  default_config :read_timeout, 3600
42
43
  default_config :write_timeout, 3600
43
44
 
@@ -55,7 +56,7 @@ module Kitchen
55
56
  # @author Sean OMeara <sean@chef.io>
56
57
  class Connection < Kitchen::Transport::Dokken::Connection
57
58
  def docker_connection
58
- @docker_connection ||= Docker::Connection.new(Docker.url, options[:docker_host])
59
+ @docker_connection ||= Docker::Connection.new(options[:docker_host_url], options[:docker_host_options])
59
60
  end
60
61
 
61
62
  def execute(command)
@@ -82,8 +83,7 @@ module Kitchen
82
83
  end
83
84
 
84
85
  def upload(locals, remote)
85
- # require 'pry' ; binding.pry
86
- ip = ENV['DOCKER_HOST'].split('tcp://')[1].split(':')[0]
86
+ ip = options[:docker_host_url].split('://')[1].split(':')[0]
87
87
  port = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostPort]
88
88
 
89
89
  tmpdir = Dir.tmpdir
@@ -139,7 +139,8 @@ module Kitchen
139
139
  # @api private
140
140
  def connection_options(data) # rubocop:disable Metrics/MethodLength
141
141
  opts = {}
142
- opts[:docker_host] = Docker.options
142
+ opts[:docker_host_url] = config[:docker_host_url]
143
+ opts[:docker_host_options] = Docker.options
143
144
  opts[:data_container] = data[:data_container]
144
145
  opts[:instance_name] = data[:instance_name]
145
146
  opts
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean OMeara
@@ -14,14 +14,14 @@ dependencies:
14
14
  name: test-kitchen
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
27
  description: A Test Kitchen Driver for Dokken
@@ -31,8 +31,8 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".gitignore"
35
- - ".travis.yml"
34
+ - .gitignore
35
+ - .travis.yml
36
36
  - CHANGELOG.md
37
37
  - Gemfile
38
38
  - LICENSE
@@ -54,20 +54,19 @@ require_paths:
54
54
  - lib
55
55
  required_ruby_version: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ">="
57
+ - - '>='
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - ">="
62
+ - - '>='
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubyforge_project:
67
- rubygems_version: 2.4.8
67
+ rubygems_version: 2.0.14
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: A Test Kitchen Driver that talks to the Docker Remote API and uses Volumes
71
71
  to produce sparse container images
72
72
  test_files: []
73
- has_rdoc: