kitchen-dokken 0.0.29 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen/driver/dokken.rb +30 -30
- data/lib/kitchen/driver/dokken/helpers.rb +2 -2
- data/lib/kitchen/driver/dokken_version.rb +1 -1
- data/lib/kitchen/transport/dokken.rb +10 -9
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9494b26b4a405a8f38a883a42a7340e6f8be4575
|
4
|
+
data.tar.gz: 5ce379b166ddb53aa4cb15548cb8a607a90e8a43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f6677da46ac67196299b8a4b06e42ac4f8aef0a625d4d6fc153d8b2e3eaf04eac79ff9d36f42886eebe489f0fa90f61441c2f2f28f65253792e85ff7282caf6
|
7
|
+
data.tar.gz: 7f1197d71a32309814433ce1d611048e506b1055db5774c3ff07a2622fdd7282c6e0f552c5cfb7f694dd88b0a5d46a088f9e8631395e9b2beed5cdb64f5fe4f3
|
@@ -79,29 +79,29 @@ module Kitchen
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def docker_connection
|
82
|
-
opts = Docker.options
|
82
|
+
opts = ::Docker.options
|
83
83
|
opts[:read_timeout] = config[:read_timeout]
|
84
84
|
opts[:write_timeout] = config[:write_timeout]
|
85
|
-
@docker_connection ||= Docker::Connection.new(config[:docker_host_url], opts)
|
85
|
+
@docker_connection ||= ::Docker::Connection.new(config[:docker_host_url], opts)
|
86
86
|
end
|
87
87
|
|
88
88
|
def delete_work_image
|
89
|
-
return unless Docker::Image.exist?(work_image, docker_connection)
|
90
|
-
with_retries { @work_image = Docker::Image.get(work_image, docker_connection) }
|
89
|
+
return unless ::Docker::Image.exist?(work_image, docker_connection)
|
90
|
+
with_retries { @work_image = ::Docker::Image.get(work_image, docker_connection) }
|
91
91
|
with_retries { @work_image.remove(force: true) }
|
92
92
|
end
|
93
93
|
|
94
94
|
def build_work_image(state)
|
95
95
|
# require 'pry' ; binding.pry
|
96
96
|
|
97
|
-
return if Docker::Image.exist?(work_image, docker_connection)
|
97
|
+
return if ::Docker::Image.exist?(work_image, docker_connection)
|
98
98
|
|
99
99
|
FileUtils.mkdir_p context_root
|
100
100
|
File.write("#{context_root}/Dockerfile", work_image_dockerfile)
|
101
101
|
|
102
102
|
begin
|
103
103
|
with_retries do
|
104
|
-
@intermediate_image = Docker::Image.build_from_dir(
|
104
|
+
@intermediate_image = ::Docker::Image.build_from_dir(
|
105
105
|
context_root,
|
106
106
|
{
|
107
107
|
# 'nocache' => true,
|
@@ -112,8 +112,8 @@ module Kitchen
|
|
112
112
|
docker_connection
|
113
113
|
)
|
114
114
|
end
|
115
|
-
rescue
|
116
|
-
fail
|
115
|
+
rescue Exception => e
|
116
|
+
fail "work_image build failed: #{e}"
|
117
117
|
end
|
118
118
|
state[:work_image] = work_image
|
119
119
|
end
|
@@ -218,8 +218,8 @@ module Kitchen
|
|
218
218
|
end
|
219
219
|
|
220
220
|
def create_chef_container(state)
|
221
|
-
c = Docker::Container.get(chef_container_name)
|
222
|
-
rescue Docker::Error::NotFoundError
|
221
|
+
c = ::Docker::Container.get(chef_container_name)
|
222
|
+
rescue ::Docker::Error::NotFoundError
|
223
223
|
begin
|
224
224
|
debug "driver - creating volume container #{chef_container_name} from #{chef_image}"
|
225
225
|
chef_container = create_container(
|
@@ -244,14 +244,14 @@ module Kitchen
|
|
244
244
|
end
|
245
245
|
|
246
246
|
def delete_image(name)
|
247
|
-
with_retries { @image = Docker::Image.get(name, docker_connection) }
|
247
|
+
with_retries { @image = ::Docker::Image.get(name, docker_connection) }
|
248
248
|
with_retries { @image.remove(force: true) }
|
249
|
-
rescue Docker::Error => e
|
249
|
+
rescue ::Docker::Error => e
|
250
250
|
puts "Image #{name} not found. Nothing to delete."
|
251
251
|
end
|
252
252
|
|
253
253
|
def container_exist?(name)
|
254
|
-
return true if Docker::Container.get(name)
|
254
|
+
return true if ::Docker::Container.get(name)
|
255
255
|
rescue
|
256
256
|
false
|
257
257
|
end
|
@@ -262,18 +262,18 @@ module Kitchen
|
|
262
262
|
|
263
263
|
def create_container(args)
|
264
264
|
with_retries do
|
265
|
-
@container = Docker::Container.create(args.clone, docker_connection)
|
266
|
-
@container = Docker::Container.get(args['name'])
|
265
|
+
@container = ::Docker::Container.create(args.clone, docker_connection)
|
266
|
+
@container = ::Docker::Container.get(args['name'])
|
267
267
|
end
|
268
|
-
rescue Docker::Error::ConflictError
|
269
|
-
with_retries { @container = Docker::Container.get(args['name']) }
|
268
|
+
rescue ::Docker::Error::ConflictError
|
269
|
+
with_retries { @container = ::Docker::Container.get(args['name']) }
|
270
270
|
end
|
271
271
|
|
272
272
|
def run_container(args)
|
273
273
|
create_container(args)
|
274
274
|
with_retries do
|
275
275
|
@container.start
|
276
|
-
@container = Docker::Container.get(args['name'])
|
276
|
+
@container = ::Docker::Container.get(args['name'])
|
277
277
|
wait_running_state(args['name'], true)
|
278
278
|
end
|
279
279
|
@container
|
@@ -285,34 +285,34 @@ module Kitchen
|
|
285
285
|
|
286
286
|
def stop_container(name)
|
287
287
|
begin
|
288
|
-
with_retries { @container = Docker::Container.get(name, docker_connection) }
|
288
|
+
with_retries { @container = ::Docker::Container.get(name, docker_connection) }
|
289
289
|
with_retries do
|
290
290
|
@container.stop(force: true)
|
291
291
|
wait_running_state(name, false)
|
292
292
|
end
|
293
|
-
rescue Docker::Error::NotFoundError
|
293
|
+
rescue ::Docker::Error::NotFoundError
|
294
294
|
debug "Container #{name} not found. Nothing to stop."
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
298
|
def delete_container(name)
|
299
299
|
begin
|
300
|
-
with_retries { @container = Docker::Container.get(name, docker_connection) }
|
300
|
+
with_retries { @container = ::Docker::Container.get(name, docker_connection) }
|
301
301
|
with_retries { @container.delete(force: true, v: true) }
|
302
|
-
rescue Docker::Error::NotFoundError
|
302
|
+
rescue ::Docker::Error::NotFoundError
|
303
303
|
debug "Container #{name} not found. Nothing to delete."
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
307
307
|
def wait_running_state(name, v)
|
308
|
-
@container = Docker::Container.get(name)
|
308
|
+
@container = ::Docker::Container.get(name)
|
309
309
|
i = 0
|
310
310
|
tries = 20
|
311
311
|
until container_state['Running'] == v || container_state['FinishedAt'] != '0001-01-01T00:00:00Z'
|
312
312
|
i += 1
|
313
313
|
break if i == tries
|
314
314
|
sleep 0.1
|
315
|
-
@container = Docker::Container.get(name)
|
315
|
+
@container = ::Docker::Container.get(name)
|
316
316
|
end
|
317
317
|
end
|
318
318
|
|
@@ -345,13 +345,13 @@ module Kitchen
|
|
345
345
|
end
|
346
346
|
|
347
347
|
def pull_if_missing(image)
|
348
|
-
return if Docker::Image.exist?("#{repo(image)}:#{tag(image)}", docker_connection)
|
348
|
+
return if ::Docker::Image.exist?("#{repo(image)}:#{tag(image)}", docker_connection)
|
349
349
|
pull_image image
|
350
350
|
end
|
351
351
|
|
352
352
|
def pull_image(image)
|
353
353
|
with_retries {
|
354
|
-
Docker::Image.create({ 'fromImage' => "#{repo(image)}:#{tag(image)}" }, docker_connection)
|
354
|
+
::Docker::Image.create({ 'fromImage' => "#{repo(image)}:#{tag(image)}" }, docker_connection)
|
355
355
|
}
|
356
356
|
end
|
357
357
|
|
@@ -364,10 +364,10 @@ module Kitchen
|
|
364
364
|
begin
|
365
365
|
block.call
|
366
366
|
# Only catch errors that can be fixed with retries.
|
367
|
-
rescue Docker::Error::ServerError, # 404
|
368
|
-
Docker::Error::UnexpectedResponseError, # 400
|
369
|
-
Docker::Error::TimeoutError,
|
370
|
-
Docker::Error::IOError => e
|
367
|
+
rescue ::Docker::Error::ServerError, # 404
|
368
|
+
::Docker::Error::UnexpectedResponseError, # 400
|
369
|
+
::Docker::Error::TimeoutError,
|
370
|
+
::Docker::Error::IOError => e
|
371
371
|
tries -= 1
|
372
372
|
retry if tries > 0
|
373
373
|
raise e
|
@@ -47,14 +47,14 @@ EOF
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def create_data_image
|
50
|
-
return if Docker::Image.exist?(data_image)
|
50
|
+
return if ::Docker::Image.exist?(data_image)
|
51
51
|
|
52
52
|
tmpdir = Dir.tmpdir
|
53
53
|
FileUtils.mkdir_p "#{tmpdir}/dokken"
|
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
|
@@ -56,13 +56,13 @@ module Kitchen
|
|
56
56
|
# @author Sean OMeara <sean@chef.io>
|
57
57
|
class Connection < Kitchen::Transport::Dokken::Connection
|
58
58
|
def docker_connection
|
59
|
-
@docker_connection ||= Docker::Connection.new(options[:docker_host_url], options[:docker_host_options])
|
59
|
+
@docker_connection ||= ::Docker::Connection.new(options[:docker_host_url], options[:docker_host_options])
|
60
60
|
end
|
61
61
|
|
62
62
|
def execute(command)
|
63
63
|
return if command.nil?
|
64
64
|
|
65
|
-
with_retries { @runner = Docker::Container.get(instance_name, {}, docker_connection) }
|
65
|
+
with_retries { @runner = ::Docker::Container.get(instance_name, {}, docker_connection) }
|
66
66
|
with_retries do
|
67
67
|
o = @runner.exec(Shellwords.shellwords(command)) { |_stream, chunk| print "#{chunk}" }
|
68
68
|
@exit_code = o[2]
|
@@ -76,7 +76,7 @@ module Kitchen
|
|
76
76
|
# Disabling this for now.. the Docker ZFS driver won't let us
|
77
77
|
# commit running containers.
|
78
78
|
#
|
79
|
-
# with_retries { @old_image = Docker::Image.get(work_image, {}, docker_connection) }
|
79
|
+
# with_retries { @old_image = ::Docker::Image.get(work_image, {}, docker_connection) }
|
80
80
|
# with_retries { @new_image = @runner.commit }
|
81
81
|
# with_retries { @new_image.tag('repo' => work_image, 'tag' => 'latest', 'force' => 'true') }
|
82
82
|
# with_retries { @old_image.remove }
|
@@ -84,7 +84,8 @@ module Kitchen
|
|
84
84
|
|
85
85
|
def upload(locals, remote)
|
86
86
|
if options[:docker_host_url] =~ /unix:/
|
87
|
-
ip
|
87
|
+
# we should read the proper mapped ip, since this allows us to upload the files
|
88
|
+
ip = options[:data_container][:NetworkSettings][:Ports][:"22/tcp"][0][:HostIp]
|
88
89
|
elsif options[:docker_host_url] =~ /tcp:/
|
89
90
|
ip = options[:docker_host_url].split('tcp://')[1].split(':')[0]
|
90
91
|
else
|
@@ -140,10 +141,10 @@ module Kitchen
|
|
140
141
|
begin
|
141
142
|
block.call
|
142
143
|
# Only catch errors that can be fixed with retries.
|
143
|
-
rescue Docker::Error::ServerError, # 404
|
144
|
-
Docker::Error::UnexpectedResponseError, # 400
|
145
|
-
Docker::Error::TimeoutError,
|
146
|
-
Docker::Error::IOError => e
|
144
|
+
rescue ::Docker::Error::ServerError, # 404
|
145
|
+
::Docker::Error::UnexpectedResponseError, # 400
|
146
|
+
::Docker::Error::TimeoutError,
|
147
|
+
::Docker::Error::IOError => e
|
147
148
|
tries -= 1
|
148
149
|
retry if tries > 0
|
149
150
|
raise e
|
@@ -162,7 +163,7 @@ module Kitchen
|
|
162
163
|
def connection_options(data) # rubocop:disable Metrics/MethodLength
|
163
164
|
opts = {}
|
164
165
|
opts[:docker_host_url] = config[:docker_host_url]
|
165
|
-
opts[:docker_host_options] = Docker.options
|
166
|
+
opts[:docker_host_options] = ::Docker.options
|
166
167
|
opts[:data_container] = data[:data_container]
|
167
168
|
opts[:instance_name] = data[:instance_name]
|
168
169
|
opts
|
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.
|
4
|
+
version: 0.0.30
|
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-
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: '1.28'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: '1.28'
|
41
41
|
description: A Test Kitchen Driver for Dokken
|
42
42
|
email:
|
43
43
|
- sean@chef.io
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.6.4
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: A Test Kitchen Driver that talks to the Docker Remote API and uses Volumes
|