kitchen-docker 2.11.0 → 2.12.0

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
  SHA256:
3
- metadata.gz: 5cb2a57e3f7074c1f3b07505f6931d9d742a2ff70d8908b97d9c69d27bb6b34b
4
- data.tar.gz: 863c64c9dac8d43c0db30bb5b83cb6eaf3448ae0b988f9809abbd882b8b12ac1
3
+ metadata.gz: bfc2ec595062530ef1a860930cb80cbdfd1f2d9b0f23f1bd7d261e769679b3a1
4
+ data.tar.gz: 51b9b8e5f65991cd5dfb26d719301ae55e90d94b2591671617396b993d0c614b
5
5
  SHA512:
6
- metadata.gz: b8639ed71230580894bc7daedd7c7efcaf09458e2e6c1cbf45e0617e16844a28d4c0015c251009e1e0fa0c741daf15715eed2a2bc6f1eada903a04fdb73a620a
7
- data.tar.gz: 779683f5e429eff27d8d68c3a19f8d01b1247d9699f283bde06f902ed6a8a0f03330e534568cac05114676f27434ba0aacb443ad57705b0bb6e0c5a77409aba0
6
+ metadata.gz: 2149ff5a8af75c70e88b93d03f5431e1586d7e0d69d117d742ec591e76fb9aca96b9d8c76e4e9d937c8c398daa4a641d0089c608a6bea9762a0c48b5b9708590
7
+ data.tar.gz: 6e235534cf2f6ec24dc9cc3e59c10048fe874684c0488dcd15c5ffe0c9409491b27c40683a5945ad5cd857b6c03c72d8d0b90b0446069a0583068aebb5ae5cce
data/.kitchen.yml CHANGED
@@ -14,28 +14,22 @@ provisioner:
14
14
 
15
15
  platforms:
16
16
  - name: amazonlinux-2
17
- - name: ubuntu-16.04
18
17
  - name: ubuntu-18.04
18
+ - name: ubuntu-20.04
19
19
  - name: fedora-latest
20
20
  driver:
21
21
  provision_command:
22
- - yum install libxcrypt-compat.x86_64 -y
22
+ - yum install libxcrypt-compat -y
23
23
  - curl -L https://www.chef.io/chef/install.sh | bash
24
- - name: centos-6
25
24
  - name: centos-7
26
- - name: oraclelinux-6
25
+ - name: centos-8
27
26
  - name: oraclelinux-7
28
- - name: debian-8
27
+ - name: rockylinux-8
29
28
  - name: debian-9
30
- # Removing opensuse CI tests temporarily due to an issue with the Chef install script not providing
31
- # the correct platform name for opensuse resulting in consistent failures for this platform
32
- #- name: opensuse-42.3
33
- # driver:
34
- # image: opensuse/leap:42.3
35
- - name: unknown
29
+ - name: debian-10
30
+ - name: opensuse-15
36
31
  driver:
37
- image: ubuntu:16.04
38
- platform: ubuntu
32
+ image: opensuse/leap:15
39
33
  - name: dockerfile
40
34
  driver:
41
35
  username: dockerfile
@@ -51,13 +45,20 @@ suites:
51
45
  driver:
52
46
  build_context: false
53
47
  - name: capabilities
54
- includes: [debian-8,debian-9,ubuntu-16.04,ubuntu-18.04]
48
+ includes: [debian-9,debian-10,ubuntu-18.04,ubuntu-20.04]
55
49
  driver:
56
50
  provision_command:
57
51
  - curl -L https://www.chef.io/chef/install.sh | bash
58
52
  - apt-get install -y net-tools
59
53
  cap_drop:
60
54
  - NET_ADMIN
55
+ - name: arm64
56
+ excludes: [debian-9]
57
+ driver:
58
+ docker_platform: linux/arm64
59
+ - name: amd64
60
+ driver:
61
+ docker_platform: linux/amd64
61
62
  - name: inspec
62
63
  driver:
63
64
  provision_command: true
data/CHANGELOG.md CHANGED
@@ -1,125 +1,114 @@
1
1
  # Kitchen-Docker Changelog
2
2
 
3
+ ## 2.12.0 - December 22, 2021
4
+
5
+ - Support Docker BuildKit - [@RulerOf](https://github.com/RulerOf)
6
+ - Add new `docker_platform` config to allow specifying architectures - [@RulerOf](https://github.com/RulerOf)
7
+
3
8
  ## 2.11.0 - July 2, 2021
4
9
 
5
- * Update the development dependency on kitchen-inspec to 2.x
6
- * Retrieve hostname state data after container is launched to avoid failures when `use_internal_docker_network` is set
7
- * Add a new option for setting container isolation. See the readme for additional details
8
- * Support GPUs in containers with a new `gpus` option that takes the same arguments that would be passed to `docker run --gpus`
9
- * suse platform: use system script for ssh key initialization
10
- * Add support for the `--mount` docker CLI option. See the readme for additional details
11
- * Use sudo.d files instead of directly editing the sudoers file
12
- * Allow passing `--tmpfs` entries to the docker run command. See the readme for additional details
13
- * Use less verbose and quicker setup on Gentoo
14
- * Lowercase the instance-name to avoid issues since docker does not allow instance with capital cases
15
- * Fix the error "Could not parse Docker build output for image ID" by improving the output line matching
16
- * Add support for `almalinux` & `rockylinux`
10
+ - Update the development dependency on kitchen-inspec to 2.x
11
+ - Retrieve hostname state data after container is launched to avoid failures when `use_internal_docker_network` is set
12
+ - Add a new option for setting container isolation. See the readme for additional details
13
+ - Support GPUs in containers with a new `gpus` option that takes the same arguments that would be passed to `docker run --gpus`
14
+ - suse platform: use system script for ssh key initialization
15
+ - Add support for the `--mount` docker CLI option. See the readme for additional details
16
+ - Use sudo.d files instead of directly editing the sudoers file
17
+ - Allow passing `--tmpfs` entries to the docker run command. See the readme for additional details
18
+ - Use less verbose and quicker setup on Gentoo
19
+ - Lowercase the instance-name to avoid issues since docker does not allow instance with capital cases
20
+ - Fix the error "Could not parse Docker build output for image ID" by improving the output line matching
21
+ - Add support for `almalinux` & `rockylinux`
17
22
 
18
23
  ## 2.10.0 - Mar 28, 2020
19
24
 
20
- * Switched from require to require_relative to slightly improve load time performance
21
- * Allow for train gem 3.x
22
- * Refactor driver to include Windows support (includes new transport for all supported platforms)
25
+ - Switched from require to require_relative to slightly improve load time performance
26
+ - Allow for train gem 3.x
27
+ - Refactor driver to include Windows support (includes new transport for all supported platforms)
23
28
 
24
29
  ## 2.9.0 - Mar 15, 2019
25
30
 
26
- * Add automatic OS detection for amazonlinux, opensuse/leap, and opensuse/tumbleweed
27
- * On Fedora containers uses dnf to setup the OS not yum
31
+ - Add automatic OS detection for amazonlinux, opensuse/leap, and opensuse/tumbleweed
32
+ - On Fedora containers uses dnf to setup the OS not yum
28
33
 
29
34
  ## 2.8.0 - Jan 18, 2019
30
35
 
31
- * Add new config option `use_internal_docker_network`, which allows running Docker within Docker. See readme for usage details.
32
- * Resolve errors while loading libraries on archlinux
33
- * Fix failures on Ubuntu 18.04
34
- * Check if image exists before attempting to remove it so we don't fail
35
- * Add oraclelinux platform support
36
- * Prevent `uninitialized constant Kitchen::Driver::Docker::Base64` error by requiring `base64`
36
+ - Add new config option `use_internal_docker_network`, which allows running Docker within Docker. See readme for usage details.
37
+ - Resolve errors while loading libraries on archlinux
38
+ - Fix failures on Ubuntu 18.04
39
+ - Check if image exists before attempting to remove it so we don't fail
40
+ - Add oraclelinux platform support
41
+ - Prevent `uninitialized constant Kitchen::Driver::Docker::Base64` error by requiring `base64`
37
42
 
38
43
  ## 2.7.0
39
44
 
40
- * Support for SUSE-based container images.
41
- * Improved support for build context shipping.
42
- * Changed `use_sudo` to default to `false` in keeping with modern Docker usage.
45
+ - Support for SUSE-based container images.
46
+ - Improved support for build context shipping.
47
+ - Changed `use_sudo` to default to `false` in keeping with modern Docker usage.
43
48
 
44
49
  ## 2.6.0
45
50
 
46
- * Set container name with information from the run so you can identify them
51
+ - Set container name with information from the run so you can identify them
47
52
  later on.
48
- * Upgrade to new driver base class structure.
53
+ - Upgrade to new driver base class structure.
49
54
 
50
55
  ## 2.5.0
51
56
 
52
- * [#209](https://github.com/portertech/kitchen-docker/pulls/209) Fix usage with Kitchen rake tasks.
53
- * Add `run_options` and `build_options` configuration.
54
- * [#195](https://github.com/portertech/kitchen-docker/pulls/195) Fix Arch Linux support.
55
- * Fix shell escaping for build paths and SSH keys.
57
+ - [#209](https://github.com/portertech/kitchen-docker/pulls/209) Fix usage with Kitchen rake tasks.
58
+ - Add `run_options` and `build_options` configuration.
59
+ - [#195](https://github.com/portertech/kitchen-docker/pulls/195) Fix Arch Linux support.
60
+ - Fix shell escaping for build paths and SSH keys.
56
61
 
57
62
  ## 2.4.0
58
63
 
59
- * [#148](https://github.com/portertech/kitchen-docker/issues/148) Restored support for older versions of Ruby.
60
- * [#149](https://github.com/portertech/kitchen-docker/pulls/149) Handle connecting to a container directly as root.
61
- * [#154](https://github.com/portertech/kitchen-docker/pulls/154) Improve container caching by reordering the build steps.
62
- * [#176](https://github.com/portertech/kitchen-docker/pulls/176) Expose proxy environment variables to the container automatically.
63
- * [#192](https://github.com/portertech/kitchen-docker/pulls/192) Set `$container=docker` for CentOS images.
64
- * [#196](https://github.com/portertech/kitchen-docker/pulls/196) Mutex SSH key generation for use with `kitchen -c`.
65
- * [#192](https://github.com/portertech/kitchen-docker/pulls/192) Don't wait when stopping a container.
64
+ - [#148](https://github.com/portertech/kitchen-docker/issues/148) Restored support for older versions of Ruby.
65
+ - [#149](https://github.com/portertech/kitchen-docker/pulls/149) Handle connecting to a container directly as root.
66
+ - [#154](https://github.com/portertech/kitchen-docker/pulls/154) Improve container caching by reordering the build steps.
67
+ - [#176](https://github.com/portertech/kitchen-docker/pulls/176) Expose proxy environment variables to the container automatically.
68
+ - [#192](https://github.com/portertech/kitchen-docker/pulls/192) Set `$container=docker` for CentOS images.
69
+ - [#196](https://github.com/portertech/kitchen-docker/pulls/196) Mutex SSH key generation for use with `kitchen -c`.
70
+ - [#192](https://github.com/portertech/kitchen-docker/pulls/192) Don't wait when stopping a container.
66
71
 
67
72
  ## 2.3.0
68
73
 
69
- * `build_context` option (boolean) to enable/disable sending the build
74
+ - `build_context` option (boolean) to enable/disable sending the build
70
75
  context to Docker.
71
76
 
72
77
  ## 2.2.0
73
78
 
74
- * Use a temporary file for each suite instance Docker container
79
+ - Use a temporary file for each suite instance Docker container
75
80
  Dockerfile, instead of passing their contents via STDIN. This allows for
76
81
  the use of commands like ADD and COPY. **Users must now use Docker >= 1.5.0**
77
-
78
- * Passwordless suite instance Docker container login (SSH), using a
82
+ - Passwordless suite instance Docker container login (SSH), using a
79
83
  generated key pair.
80
-
81
- * Support for sharing a host device with suite instance Docker containers.
82
-
83
- * README YAML highlighting.
84
+ - Support for sharing a host device with suite instance Docker containers.
85
+ - README YAML highlighting.
84
86
 
85
87
  ## 2.1.0
86
88
 
87
- * Use `NUL` instead of `/dev/null` on Windows for output redirection
89
+ - Use `NUL` instead of `/dev/null` on Windows for output redirection
88
90
 
89
91
  ## 2.0.0
90
92
 
91
- * Use Docker `top` and `port` instead of `inspect`
92
-
93
- * Don't create the kitchen user if it already exists
94
-
95
- * Docker container capabilities options: cap_add, cap_drop
96
-
97
- * Docker security profile option (SELinux/AppArmor): security_opt
98
-
99
- * wait_for_sshd option (boolean)
100
-
101
- * Create `/etc/sudoers.d` if missing
102
-
103
- * Fixed option deprecation warnings, require Docker >= 1.2
93
+ - Use Docker `top` and `port` instead of `inspect`
94
+ - Don't create the kitchen user if it already exists
95
+ - Docker container capabilities options: cap_add, cap_drop
96
+ - Docker security profile option (SELinux/AppArmor): security_opt
97
+ - wait_for_sshd option (boolean)
98
+ - Create `/etc/sudoers.d` if missing
99
+ - Fixed option deprecation warnings, require Docker >= 1.2
104
100
 
105
101
  ## 1.7.0
106
102
 
107
- * Ensure a container id is set before attempting to inspect a container
103
+ - Ensure a container id is set before attempting to inspect a container
108
104
 
109
105
  ## 1.6.0
110
106
 
111
- * `publish_all` option to publish all ports to the host interface
112
-
113
- * `instance_name` option to name the Docker container
114
-
115
- * `links` option to link suite instance Docker containers
116
-
117
- * `socket` option will now default to ENV `DOCKER_HOST` if set
118
-
119
- * Fixed verify dependencies output redirection
120
-
121
- * Added `fedora` to platform names
122
-
123
- * Support for `gentoo` and `gentoo-paludis` platforms
124
-
125
- * Adding sudo rule to `/etc/sudoers.d/#{username}` in addition to `/etc/sudoers`
107
+ - `publish_all` option to publish all ports to the host interface
108
+ - `instance_name` option to name the Docker container
109
+ - `links` option to link suite instance Docker containers
110
+ - `socket` option will now default to ENV `DOCKER_HOST` if set
111
+ - Fixed verify dependencies output redirection
112
+ - Added `fedora` to platform names
113
+ - Support for `gentoo` and `gentoo-paludis` platforms
114
+ - Adding sudo rule to `/etc/sudoers.d/#{username}` in addition to `/etc/sudoers`
data/README.md CHANGED
@@ -596,6 +596,20 @@ Examples:
596
596
  use_internal_docker_network: true
597
597
  ```
598
598
 
599
+ ### docker_platform
600
+
601
+ Configure the CPU platform (architecture) used by docker to build the image.
602
+
603
+ Examples:
604
+
605
+ ```yaml
606
+ docker_platform: linux/arm64
607
+ ```
608
+
609
+ ```yaml
610
+ docker_platform: linux/amd64
611
+ ```
612
+
599
613
  ## Development
600
614
 
601
615
  * Source hosted at [GitHub][repo]
@@ -16,6 +16,6 @@
16
16
  module Kitchen
17
17
  module Docker
18
18
  # Version string for Docker Kitchen driver
19
- DOCKER_VERSION = "2.11.0"
19
+ DOCKER_VERSION = "2.12.0"
20
20
  end
21
21
  end
@@ -36,6 +36,26 @@ module Kitchen
36
36
  run_command("#{docker} #{cmd}", docker_shell_opts(options))
37
37
  end
38
38
 
39
+ # Copied from kitchen because we need stderr
40
+ def run_command(cmd, options = {})
41
+ if options.fetch(:use_sudo, false)
42
+ cmd = "#{options.fetch(:sudo_command, "sudo -E")} #{cmd}"
43
+ end
44
+ subject = "[#{options.fetch(:log_subject, "local")} command]"
45
+
46
+ debug("#{subject} BEGIN (#{cmd})")
47
+ sh = Mixlib::ShellOut.new(cmd, shell_opts(options))
48
+ sh.run_command
49
+ debug("#{subject} END #{Util.duration(sh.execution_time)}")
50
+ sh.error!
51
+ sh.stdout + sh.stderr
52
+ rescue Mixlib::ShellOut::ShellCommandFailed => ex
53
+ raise ShellCommandFailed, ex.message
54
+ rescue Exception => error # rubocop:disable Lint/RescueException
55
+ error.extend(Kitchen::Error)
56
+ raise
57
+ end
58
+
39
59
  def build_run_command(image_id, transport_port = nil)
40
60
  cmd = 'run -d'
41
61
  cmd << ' -i' if config[:interactive]
@@ -64,6 +84,7 @@ module Kitchen
64
84
  Array(config[:cap_add]).each { |cap| cmd << " --cap-add=#{cap}"} if config[:cap_add]
65
85
  Array(config[:cap_drop]).each { |cap| cmd << " --cap-drop=#{cap}"} if config[:cap_drop]
66
86
  Array(config[:security_opt]).each { |opt| cmd << " --security-opt=#{opt}"} if config[:security_opt]
87
+ cmd << " --platform=#{config[:docker_platform]}" if config[:docker_platform]
67
88
  extra_run_options = config_to_options(config[:run_options])
68
89
  cmd << " #{extra_run_options}" unless extra_run_options.empty?
69
90
  cmd << " #{image_id} #{config[:run_command]}"
@@ -26,7 +26,11 @@ module Kitchen
26
26
 
27
27
  def parse_image_id(output)
28
28
  output.each_line do |line|
29
- if line =~ /image id|build successful|successfully built|writing image/i
29
+ if line =~ /writing image sha256:[[:xdigit:]]{64} done/i
30
+ img_id = line[/writing image (sha256:[[:xdigit:]]{64}) done/i,1]
31
+ return img_id
32
+ end
33
+ if line =~ /image id|build successful|successfully built/i
30
34
  img_id = line.split(/\s+/).last
31
35
  return img_id
32
36
  end
@@ -42,17 +46,19 @@ module Kitchen
42
46
  def build_image(state, dockerfile)
43
47
  cmd = 'build'
44
48
  cmd << ' --no-cache' unless config[:use_cache]
49
+ cmd << " --platform=#{config[:docker_platform]}" if config[:docker_platform]
45
50
  extra_build_options = config_to_options(config[:build_options])
46
51
  cmd << " #{extra_build_options}" unless extra_build_options.empty?
47
52
  dockerfile_contents = dockerfile
48
- build_context = config[:build_context] ? '.' : '-'
49
53
  file = Tempfile.new('Dockerfile-kitchen', Dir.pwd)
54
+ cmd << " -f #{Shellwords.escape(dockerfile_path(file))}" if config[:build_context]
55
+ build_context = config[:build_context] ? '.' : '-'
50
56
  output = begin
51
57
  file.write(dockerfile)
52
58
  file.close
53
- docker_command("#{cmd} -f #{Shellwords.escape(dockerfile_path(file))} #{build_context}",
59
+ docker_command("#{cmd} #{build_context}",
54
60
  input: dockerfile_contents,
55
- environment: { DOCKER_BUILDKIT: '0' })
61
+ environment: { BUILDKIT_PROGRESS: 'plain' })
56
62
  ensure
57
63
  file.close unless file.closed?
58
64
  file.unlink
data/test/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM centos:6
1
+ FROM centos:7
2
2
  RUN yum clean all
3
3
  RUN yum install -y sudo openssh-server openssh-clients which curl htop
4
4
  RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-docker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-02 00:00:00.000000000 Z
11
+ date: 2021-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -266,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
266
  - !ruby/object:Gem::Version
267
267
  version: '0'
268
268
  requirements: []
269
- rubygems_version: 3.2.15
269
+ rubygems_version: 3.2.32
270
270
  signing_key:
271
271
  specification_version: 4
272
272
  summary: A Docker Driver for Test Kitchen