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 +4 -4
- data/lib/kitchen/driver/dokken.rb +32 -10
- data/lib/kitchen/driver/dokken_version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df5fc9ab1a4677a9b159b88dd83550201402b1b3
|
4
|
+
data.tar.gz: 231e77bfb9af35a97d3ab0ab539d42f07c1b6378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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}
|
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
|
}
|