kitchen-dokken 2.23.2 → 2.23.3
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 +4 -4
- data/lib/kitchen/driver/dokken.rb +61 -13
- data/lib/kitchen/driver/dokken_version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9bbe79ca0ad5a4b71659c1359871a9e4c86f6e243d83d694ab76341f94a0e6c0
|
|
4
|
+
data.tar.gz: 2e6dd411ce0d408331cf312249d208c6b6345382cc94d2d83cba0cf7b407d0be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a14d2a57ab4bdb76e6192107fd2f0c185df2f1fab90522c1fa45546420c8a508e0adfb9b893a56c2c9ef6e84c4b7fd5cf1428f578b614f788659b523e6219753
|
|
7
|
+
data.tar.gz: df6506e366a8379682f5bbbfc3e3b1574d841a3da048d7ab35d61b944f4b28996277cf30907fa1b1de3b21aa36c52fd01521844344c51c0ec976cd93b396ed1e
|
|
@@ -81,7 +81,7 @@ module Kitchen
|
|
|
81
81
|
default_config :write_timeout, 3600
|
|
82
82
|
default_config :user_ns_mode, nil
|
|
83
83
|
default_config :creds_file, nil
|
|
84
|
-
default_config :docker_config_creds,
|
|
84
|
+
default_config :docker_config_creds, true
|
|
85
85
|
|
|
86
86
|
# (see Base#create)
|
|
87
87
|
def create(state)
|
|
@@ -513,20 +513,68 @@ module Kitchen
|
|
|
513
513
|
@docker_config_creds
|
|
514
514
|
end
|
|
515
515
|
|
|
516
|
+
# The `auths` key `docker login` itself writes for Docker Hub.
|
|
517
|
+
DOCKER_HUB_REGISTRY_KEY = "https://index.docker.io/v1/".freeze
|
|
518
|
+
|
|
519
|
+
# Registry hosts that all refer to Docker Hub. Docker writes the legacy
|
|
520
|
+
# v1 URL above, but hand-written and tool-generated configs use any of
|
|
521
|
+
# these. Listed in preference order.
|
|
522
|
+
DOCKER_HUB_HOSTS = %w{index.docker.io docker.io registry-1.docker.io}.freeze
|
|
523
|
+
|
|
524
|
+
# An explicit "no credentials" value. Returning nil here instead would let
|
|
525
|
+
# docker-api fall back to the process-global ::Docker.creds, which
|
|
526
|
+
# authenticate! populates from creds_file and never clears -- so another
|
|
527
|
+
# instance's private registry password would be sent to this registry,
|
|
528
|
+
# which is the very leak this scoping exists to prevent.
|
|
529
|
+
NO_DOCKER_CREDS = {}.freeze
|
|
530
|
+
|
|
531
|
+
# Return the registry host an image reference points at, or nil when the
|
|
532
|
+
# reference resolves to Docker Hub. The leading path component only names
|
|
533
|
+
# a registry when it contains a "." or a ":", or is exactly "localhost" --
|
|
534
|
+
# the same heuristic Docker uses to tell "quay.io/org/image" apart from
|
|
535
|
+
# the Hub shorthand "dokken/almalinux-8".
|
|
536
|
+
def image_registry_host(image)
|
|
537
|
+
first, remainder = image.split("/", 2)
|
|
538
|
+
return nil if remainder.nil?
|
|
539
|
+
return nil unless first.include?(".") || first.include?(":") || first == "localhost"
|
|
540
|
+
|
|
541
|
+
first
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
# Look up the ~/.docker/config.json entry that applies to an image's
|
|
545
|
+
# registry. Returns nil when that registry has no entry so the pull is
|
|
546
|
+
# attempted anonymously, rather than offering it another registry's
|
|
547
|
+
# credentials.
|
|
548
|
+
# Pick the config.json key that holds the Docker Hub credentials. A
|
|
549
|
+
# config may spell Hub several ways, so prefer the canonical key and then
|
|
550
|
+
# a fixed alias order rather than whichever happens to be listed first.
|
|
551
|
+
def docker_hub_creds_key
|
|
552
|
+
keys = docker_config_creds.keys.select { |k| DOCKER_HUB_HOSTS.include?(parse_registry_host(k)) }
|
|
553
|
+
return if keys.empty?
|
|
554
|
+
|
|
555
|
+
keys.find { |k| k == DOCKER_HUB_REGISTRY_KEY } ||
|
|
556
|
+
keys.min_by { |k| DOCKER_HUB_HOSTS.index(parse_registry_host(k)) }
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
def docker_config_creds_for_image(image)
|
|
560
|
+
host = image_registry_host(image)
|
|
561
|
+
|
|
562
|
+
key = if host.nil? || DOCKER_HUB_HOSTS.include?(host)
|
|
563
|
+
docker_hub_creds_key
|
|
564
|
+
else
|
|
565
|
+
docker_config_creds.keys.find { |k| parse_registry_host(k) == host }
|
|
566
|
+
end
|
|
567
|
+
return if key.nil?
|
|
568
|
+
|
|
569
|
+
c = docker_config_creds[key]
|
|
570
|
+
c.respond_to?(:call) ? c.call : c
|
|
571
|
+
end
|
|
572
|
+
|
|
516
573
|
def docker_creds_for_image(image)
|
|
517
574
|
return docker_creds if config[:creds_file]
|
|
575
|
+
return NO_DOCKER_CREDS unless config[:docker_config_creds]
|
|
518
576
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
# NOTE: Try to use DockerHub auth if exact registry match isn't found
|
|
522
|
-
default_registry = "https://index.docker.io/v1/"
|
|
523
|
-
if docker_config_creds.key?(image_registry)
|
|
524
|
-
c = docker_config_creds[image_registry]
|
|
525
|
-
c.respond_to?(:call) ? c.call : c
|
|
526
|
-
elsif docker_config_creds.key?(default_registry)
|
|
527
|
-
c = docker_config_creds[default_registry]
|
|
528
|
-
c.respond_to?(:call) ? c.call : c
|
|
529
|
-
end
|
|
577
|
+
docker_config_creds_for_image(image) || NO_DOCKER_CREDS
|
|
530
578
|
end
|
|
531
579
|
|
|
532
580
|
def pull_platform_image
|
|
@@ -758,7 +806,7 @@ module Kitchen
|
|
|
758
806
|
original_image = Docker::Image.get(path, { "platform" => oci_platform(config[:platform]) }, docker_connection)
|
|
759
807
|
end
|
|
760
808
|
|
|
761
|
-
new_image = Docker::Image.create({ "fromImage" => path, "platform" => config[:platform] }, docker_creds_for_image(
|
|
809
|
+
new_image = Docker::Image.create({ "fromImage" => path, "platform" => config[:platform] }, docker_creds_for_image(path), docker_connection)
|
|
762
810
|
|
|
763
811
|
!(original_image&.id&.start_with?(new_image.id))
|
|
764
812
|
end
|