kitchen-dokken 2.12.0 → 2.12.1

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
  SHA256:
3
- metadata.gz: 6e00103fefe2a49fd2630337f2a8d0bb0932484b770704b69c1fb31d9ddd0b42
4
- data.tar.gz: 0acea78f249845712be9d1f97094f190369a1e15707ac559de27be5fc6c29e31
3
+ metadata.gz: 517d0d0706aed8e8fc5889c874d6817fe65cfa571ba3a7a082d8256f707986cd
4
+ data.tar.gz: f5beb66dc47d9c4f58022c26af3ce8657c7fae40443eb2d3ee1b5ef2c01f5d0e
5
5
  SHA512:
6
- metadata.gz: 0d84bd393b040ef4bc771a5d5c4448dff1860a9244d0818341f06c834e8133cbd9a77b0b7a4f697c8873be24b567083556f4feb47a57723782fe6575ad7b2a1a
7
- data.tar.gz: b628d6bce7009efa94713c5c6032ec81e3258686c84f22ebd430e1710a1817cfaf3cb82420a8109e21f1506ff0e661c08da1e6fb2d5baedd6adbb216a0dedaa8
6
+ metadata.gz: fd3d097a36e249e21f88ea3a1999207f9e45e464a9eb649d10c870d24d4a0705766dfb57df3ced2c82cda4e6cee04d5b53587b36743dbdd887da036d00c5d7c8
7
+ data.tar.gz: 755b9671c1aa2cbf14a90ddb9c730e3d50d5326a6244f2d8ece875b5bf5b5e9567c3c5f9661cd6cb6a00e6e4ec0594efcd5aa2fe0daf56e0fca7bf78c6a76d61
@@ -169,8 +169,10 @@ module Kitchen
169
169
  end
170
170
 
171
171
  def work_image_dockerfile
172
+ from = registry_image_path(platform_image)
173
+ debug("driver - Building work image from #{from}")
172
174
  dockerfile_contents = [
173
- "FROM #{platform_image}",
175
+ "FROM #{from}",
174
176
  "LABEL X-Built-By=kitchen-dokken X-Built-From=#{platform_image}",
175
177
  ]
176
178
  Array(config[:intermediate_instructions]).each do |c|
@@ -287,7 +289,8 @@ module Kitchen
287
289
  config = {
288
290
  "name" => runner_container_name,
289
291
  "Cmd" => Shellwords.shellwords(self[:pid_one_command]),
290
- "Image" => "#{repo(work_image)}:#{tag(work_image)}",
292
+ # locally built image, must use short-name
293
+ "Image" => short_image_path(work_image),
291
294
  "Hostname" => self[:hostname],
292
295
  "Env" => self[:env],
293
296
  "ExposedPorts" => exposed_ports,
@@ -329,7 +332,8 @@ module Kitchen
329
332
  debug "driver - creating #{data_container_name}"
330
333
  config = {
331
334
  "name" => data_container_name,
332
- "Image" => "#{repo(data_image)}:#{tag(data_image)}",
335
+ # locally built image, must use short-name
336
+ "Image" => short_image_path(data_image),
333
337
  "HostConfig" => {
334
338
  "PortBindings" => port_bindings,
335
339
  "PublishAllPorts" => true,
@@ -352,7 +356,7 @@ module Kitchen
352
356
  begin
353
357
  lockfile.lock
354
358
  with_retries { ::Docker::Network.get("dokken", {}, docker_connection) }
355
- rescue
359
+ rescue ::Docker::Error::NotFoundError
356
360
  begin
357
361
  with_retries { ::Docker::Network.create("dokken", {}) }
358
362
  rescue ::Docker::Error => e
@@ -388,14 +392,14 @@ module Kitchen
388
392
  config = {
389
393
  "name" => chef_container_name,
390
394
  "Cmd" => "true",
391
- "Image" => "#{repo(chef_image)}:#{tag(chef_image)}",
395
+ "Image" => registry_image_path(chef_image),
392
396
  "HostConfig" => {
393
397
  "NetworkMode" => self[:network_mode],
394
398
  },
395
399
  }
396
400
  chef_container = create_container(config)
397
401
  state[:chef_container] = chef_container.json
398
- rescue ::Docker::Error => e
402
+ rescue ::Docker::Error, StandardError => e
399
403
  raise "driver - #{chef_container_name} failed to create #{e}"
400
404
  end
401
405
  ensure
@@ -404,12 +408,12 @@ module Kitchen
404
408
  end
405
409
 
406
410
  def pull_platform_image
407
- debug "driver - pulling #{chef_image} #{repo(platform_image)} #{tag(platform_image)}"
411
+ debug "driver - pulling #{short_image_path(platform_image)}"
408
412
  config[:pull_platform_image] ? pull_image(platform_image) : pull_if_missing(platform_image)
409
413
  end
410
414
 
411
415
  def pull_chef_image
412
- debug "driver - pulling #{chef_image} #{repo(chef_image)} #{tag(chef_image)}"
416
+ debug "driver - pulling #{short_image_path(chef_image)}"
413
417
  config[:pull_chef_image] ? pull_image(chef_image) : pull_if_missing(chef_image)
414
418
  end
415
419
 
@@ -422,7 +426,7 @@ module Kitchen
422
426
 
423
427
  def container_exist?(name)
424
428
  return true if ::Docker::Container.get(name, {}, docker_connection)
425
- rescue
429
+ rescue StandardError, ::Docker::Error::NotFoundError
426
430
  false
427
431
  end
428
432
 
@@ -440,10 +444,45 @@ module Kitchen
440
444
  [repo, tag]
441
445
  end
442
446
 
447
+ # Return the 'repo' half of a docker image path. Agnostic about if a
448
+ # registry is included, this effectively is just "before the colon"
449
+ #
450
+ # @param image [String] the docker image path to parse
451
+ # @return [String] the repo portion of `image`
443
452
  def repo(image)
444
453
  parse_image_name(image)[0]
445
454
  end
446
455
 
456
+ # Return the 'tag' of a docker image path. Will be `latest` if there
457
+ # is no explicit tag in the image path.
458
+ #
459
+ # @param image [String] the docker image path to parse
460
+ # @return [String] the tag of `image`
461
+ def tag(image)
462
+ parse_image_name(image)[1]
463
+ end
464
+
465
+ # Ensures an explicit tag on an image path.
466
+ #
467
+ # @param image [String] the docker image path to parse
468
+ # @return [String] `repo`:`tag`
469
+ def short_image_path(image)
470
+ "#{repo(image)}:#{tag(image)}"
471
+ end
472
+
473
+ # Qualifies the results of `short_image_path` with any registry the
474
+ # user has requested
475
+ #
476
+ # @param image [String] the docker image path to parse
477
+ # @return [String] The most fully-qualified registry path we cn make
478
+ def registry_image_path(image)
479
+ if config[:docker_registry]
480
+ "#{config[:docker_registry]}/#{short_image_path(image)}"
481
+ else
482
+ short_image_path(image)
483
+ end
484
+ end
485
+
447
486
  def create_container(args)
448
487
  with_retries { @container = ::Docker::Container.get(args["name"], {}, docker_connection) }
449
488
  rescue
@@ -511,10 +550,6 @@ module Kitchen
511
550
  end
512
551
  end
513
552
 
514
- def tag(image)
515
- parse_image_name(image)[1]
516
- end
517
-
518
553
  def chef_container_name
519
554
  "chef-#{chef_version}"
520
555
  end
@@ -547,7 +582,7 @@ module Kitchen
547
582
  end
548
583
 
549
584
  def pull_if_missing(image)
550
- return if ::Docker::Image.exist?("#{repo(image)}:#{tag(image)}", {}, docker_connection)
585
+ return if ::Docker::Image.exist?(registry_image_path(image), {}, docker_connection)
551
586
 
552
587
  pull_image image
553
588
  end
@@ -557,21 +592,14 @@ module Kitchen
557
592
  val.sub(%r{https?://}, "").split("/").first
558
593
  end
559
594
 
560
- def image_path(image)
561
- fqimage = "#{repo(image)}:#{tag(image)}"
562
- if config[:docker_registry]
563
- fqimage = "#{config[:docker_registry]}/#{fqimage}"
564
- end
565
- fqimage
566
- end
567
-
568
595
  def pull_image(image)
596
+ path = registry_image_path(image)
569
597
  with_retries do
570
- if Docker::Image.exist?(image_path(image), {}, docker_connection)
571
- original_image = Docker::Image.get(image_path(image), {}, docker_connection)
598
+ if Docker::Image.exist?(path, {}, docker_connection)
599
+ original_image = Docker::Image.get(path, {}, docker_connection)
572
600
  end
573
601
 
574
- new_image = Docker::Image.create({ "fromImage" => "#{repo(image)}:#{tag(image)}" }, docker_connection)
602
+ new_image = Docker::Image.create({ "fromImage" => path }, docker_connection)
575
603
 
576
604
  !(original_image && original_image.id.start_with?(new_image.id))
577
605
  end
@@ -18,6 +18,6 @@
18
18
  module Kitchen
19
19
  module Driver
20
20
  # Version string for Dokken Kitchen driver
21
- DOKKEN_VERSION = "2.12.0".freeze
21
+ DOKKEN_VERSION = "2.12.1".freeze
22
22
  end
23
23
  end
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: 2.12.0
4
+ version: 2.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean OMeara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-24 00:00:00.000000000 Z
11
+ date: 2021-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api