kitchen-docker 3.2.3 → 3.3.0

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: 7c9d06e9cc15a17fcaa0658c0cb33719baf0bbe46211269975ae66dbf5bfed4c
4
- data.tar.gz: 367a618236ccbcb315dbe8d69cec049f7f26b5bcd35c640f7dea6d5c5528aed5
3
+ metadata.gz: bffcdd4042f9756abb662c1b2aa0bc19d6a7651687a1872db254f664da282ee2
4
+ data.tar.gz: fb6c25bcc54d6f8a46dbec8c62066183867a8ebc728c2e55d735313964e29c3a
5
5
  SHA512:
6
- metadata.gz: b17b6a8042a54d09b0e77ef0955d41d3e7b4574e1c634429b1a8a5c06dfed9d02ad86b03d86588f11f328897ae028e0925fbcf4b30b014d3ad81f0670017b80e
7
- data.tar.gz: 4821086d0078af8b2919010e7373646922cb17e2549be27537572004f4c95ff7ac39c7fd39a61e1607bbff50e8090d564f309dd168f11b0d3560b242bbd7e1c9
6
+ metadata.gz: baa8f6f4df650a981a5cfe265359484f799580d56a23227a3f139240cd83ac1ec5e6a9f705cf9d0aab255481fc94f48660d040b51d1b13656b413718e9df9a62
7
+ data.tar.gz: 5e53bd5e0418b900412615d0455eb1cdd6746dc18e558a2b13f7300c02d46c9ababb5a93a7bf998ea9c073e3b8687db9fa504ab8ada2595380f33035bfa80a86
data/.gitignore CHANGED
@@ -20,3 +20,5 @@ tmp
20
20
  Dockerfile
21
21
  .DS_Store
22
22
  vendor/
23
+ bin/*
24
+ .idea/*
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "3.2.3"
2
+ ".": "3.3.0"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  Future CHANGELOG notes will be in GitHub release notes
4
4
 
5
+ ## [3.3.0](https://github.com/test-kitchen/kitchen-docker/compare/v3.2.4...v3.3.0) (2026-08-22)
6
+
7
+
8
+ ### Features
9
+
10
+ * Support `kitchen login` with the Docker transport ([#462](https://github.com/test-kitchen/kitchen-docker/issues/462)) ([ba9b75e](https://github.com/test-kitchen/kitchen-docker/commit/ba9b75e8187eea72316dc91dbe3aec41221055bf))
11
+
12
+ ## [3.2.4](https://github.com/test-kitchen/kitchen-docker/compare/v3.2.3...v3.2.4) (2026-07-28)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * Avoid curl conflict with RHEL ubi in dockerfile helper ([#458](https://github.com/test-kitchen/kitchen-docker/issues/458)) ([028ce4c](https://github.com/test-kitchen/kitchen-docker/commit/028ce4c6ebdde7727f0e8aea7ae1a998f73f6eb8))
18
+
5
19
  ## [3.2.3](https://github.com/test-kitchen/kitchen-docker/compare/v3.2.2...v3.2.3) (2026-06-25)
6
20
 
7
21
 
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec
4
-
3
+ gemspec development_group: :test
5
4
  group :development do
6
5
  # Integration testing gems.
7
6
  gem "kitchen-cinc-auditor", git: "https://github.com/test-kitchen/kitchen-cinc-auditor.git"
@@ -11,7 +10,6 @@ group :development do
11
10
  end
12
11
 
13
12
  group :test do
14
- gem "bundler"
15
13
  gem "rake"
16
14
  gem "rspec", "~> 3.2"
17
15
  gem "rspec-its", "~> 2.0"
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # Kitchen-Docker
2
2
 
3
- [![Build Status](https://travis-ci.org/test-kitchen/kitchen-docker.svg?branch=master)](https://travis-ci.org/test-kitchen/kitchen-docker)
4
3
  [![Gem Version](https://img.shields.io/gem/v/kitchen-docker.svg)](https://rubygems.org/gems/kitchen-docker)
5
4
  [![Coverage](https://img.shields.io/codecov/c/github/test-kitchen/kitchen-docker.svg)](https://codecov.io/github/test-kitchen/kitchen-docker)
6
5
  [![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
@@ -628,6 +627,22 @@ Examples:
628
627
  docker_platform: linux/amd64
629
628
  ```
630
629
 
630
+ ## Logging into a container
631
+
632
+ `kitchen login` opens an interactive shell inside a running container using the
633
+ Docker transport, so you do not need to look up the container ID and run
634
+ `docker exec` by hand:
635
+
636
+ ```bash
637
+ kitchen login default-ubuntu-2404
638
+ ```
639
+
640
+ The session runs `docker exec` against the instance's container. On Linux
641
+ platforms it starts `/bin/bash --login -i`; on Windows platforms it starts
642
+ `powershell`. The transport's `username`, `working_dir`, `env_variables` and
643
+ `privileged` settings are honoured, so the shell matches the environment that
644
+ Test Kitchen uses when it runs the provisioner.
645
+
631
646
  ## Development
632
647
 
633
648
  * Source hosted at [GitHub][repo]
@@ -667,6 +682,6 @@ limitations under the License.
667
682
  [docker_installation]: https://docs.docker.com/installation/#installation
668
683
  [docker_index]: https://index.docker.io/
669
684
  [test_kitchen_docs]: https://kitchen.ci/docs/getting-started/introduction/
670
- [chef_omnibus_dl]: https://downloads.chef.io/chef-client/
685
+ [chef_omnibus_dl]: https://downloads.chef.io/tools/infra-client
671
686
  [cpu_shares]: https://docs.fedoraproject.org/en-US/Fedora/17/html/Resource_Management_Guide/sec-cpu.html
672
687
  [memory_limit]: https://docs.fedoraproject.org/en-US/Fedora/17/html/Resource_Management_Guide/sec-memory.html
@@ -3,14 +3,15 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require "kitchen/docker/docker_version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "kitchen-docker"
6
+ spec.name = "kitchen-docker"
7
+ spec.required_ruby_version = ">= 3.1"
7
8
  spec.version = Kitchen::Docker::DOCKER_VERSION
8
9
  spec.authors = ["Sean Porter"]
9
10
  spec.email = ["portertech@gmail.com"]
10
11
  spec.description = %q{A Docker Driver for Test Kitchen}
11
12
  spec.summary = spec.description
12
13
  spec.homepage = "https://github.com/test-kitchen/kitchen-docker"
13
- spec.license = "Apache 2.0"
14
+ spec.license = "Apache-2.0"
14
15
 
15
16
  spec.files = `git ls-files`.split($/)
16
17
  spec.require_paths = ["lib"]
@@ -16,6 +16,6 @@
16
16
  module Kitchen
17
17
  module Docker
18
18
  # Version string for Docker Kitchen driver
19
- DOCKER_VERSION = "3.2.3".freeze
19
+ DOCKER_VERSION = "3.3.0".freeze
20
20
  end
21
21
  end
@@ -111,7 +111,8 @@ module Kitchen
111
111
  <<-CODE
112
112
  ENV container=docker
113
113
  RUN yum clean all
114
- RUN yum install -y sudo openssh-server openssh-clients which curl
114
+ RUN yum install -y sudo openssh-server openssh-clients which
115
+ RUN which curl || yum install -y curl
115
116
  RUN [ -f "/etc/ssh/ssh_host_rsa_key" ] || ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
116
117
  CODE
117
118
  end
@@ -97,13 +97,62 @@ module Kitchen
97
97
  end
98
98
 
99
99
  def container
100
- @container ||= if @options[:platform].include?("windows")
100
+ @container ||= if windows_container?
101
101
  Kitchen::Docker::Container::Windows.new(@options)
102
102
  else
103
103
  Kitchen::Docker::Container::Linux.new(@options)
104
104
  end
105
105
  @container
106
106
  end
107
+
108
+ # (see Base::Connection#login_command)
109
+ def login_command
110
+ argv = build_login_command
111
+ LoginCommand.new(argv.first, argv.drop(1))
112
+ end
113
+
114
+ private
115
+
116
+ def windows_container?
117
+ @options[:platform].to_s.include?("windows")
118
+ end
119
+
120
+ # Builds the argv array for an interactive `docker exec` session.
121
+ #
122
+ # Kitchen hands the result to `Kernel.exec` in its multi-argument form,
123
+ # which bypasses the shell entirely. Every flag and its value therefore
124
+ # has to be its own token -- a packed "-H unix:///var/run/docker.sock"
125
+ # would reach Docker as a single argument -- and values must not be
126
+ # quoted, since there is no shell to strip the quotes back off.
127
+ #
128
+ # @return [Array<String>] the docker command and its arguments
129
+ def build_login_command
130
+ docker = [@options[:binary]]
131
+ docker.push("-H", @options[:socket]) if @options[:socket]
132
+ docker << "--tls" if @options[:tls]
133
+ docker << "--tlsverify" if @options[:tls_verify]
134
+ docker << "--tlscacert=#{@options[:tls_cacert]}" if @options[:tls_cacert]
135
+ docker << "--tlscert=#{@options[:tls_cert]}" if @options[:tls_cert]
136
+ docker << "--tlskey=#{@options[:tls_key]}" if @options[:tls_key]
137
+
138
+ # Always attached, always a TTY: a detached or non-interactive exec
139
+ # would hand back a session the user cannot type into.
140
+ cmd = ["exec"]
141
+ cmd << "--privileged" if @options[:privileged]
142
+ cmd.push("-t", "-i")
143
+ Hash(@options[:env_variables]).each { |key, value| cmd.push("-e", "#{key}=#{value}") }
144
+ cmd.push("-u", @options[:username]) if @options[:username]
145
+ cmd.push("-w", @options[:working_dir]) if @options[:working_dir]
146
+ cmd << @options[:container_id]
147
+ cmd.concat(login_shell)
148
+
149
+ logger.debug("build_login_command: #{(docker + cmd).join(" ")}")
150
+ docker + cmd
151
+ end
152
+
153
+ def login_shell
154
+ windows_container? ? ["powershell"] : ["/bin/bash", "--login", "-i"]
155
+ end
107
156
  end
108
157
  end
109
158
  end
@@ -61,9 +61,10 @@ describe Kitchen::Docker::Helpers::DockerfileHelper do
61
61
  expect(result).not_to include("--allowerasing")
62
62
  end
63
63
 
64
- it "installs required packages including curl" do
64
+ it "installs required packages including curl if needed" do
65
65
  result = helper.rhel_platform
66
- expect(result).to include("sudo openssh-server openssh-clients which curl")
66
+ expect(result).to include("sudo openssh-server openssh-clients which")
67
+ expect(result).to include("which curl || yum install -y curl")
67
68
  end
68
69
  end
69
70
 
@@ -7,12 +7,15 @@ RSpec.describe "inspec_helper patches" do
7
7
  describe "kitchen-inspec patch" do
8
8
  # Test actual post-load state rather than trying to stub Kernel.require,
9
9
  # which does not intercept require calls made inside a load'd file in Ruby 3.4.
10
- if defined?(Kitchen::Verifier::Inspec)
11
- it "adds runner_options_for_docker to Kitchen::Verifier::Inspec" do
10
+ # The availability check has to happen inside the example: RSpec loads every
11
+ # spec file before running any example, so a load-time `defined?` would be
12
+ # decided by whichever spec file happened to require the verifier first.
13
+ it "patches Kitchen::Verifier::Inspec when the gem is available" do
14
+ load helper_path
15
+
16
+ if defined?(Kitchen::Verifier::Inspec)
12
17
  expect(Kitchen::Verifier::Inspec.method_defined?(:runner_options_for_docker)).to be true
13
- end
14
- else
15
- it "Kitchen::Verifier::Inspec not available — patch correctly skipped" do
18
+ else
16
19
  expect(defined?(Kitchen::Verifier::Inspec)).to be_falsy
17
20
  end
18
21
  end
@@ -32,13 +35,13 @@ RSpec.describe "inspec_helper patches" do
32
35
 
33
36
  describe "kitchen-cinc-auditor patch" do
34
37
  # Test actual post-load state rather than trying to stub Kernel.require.
35
- if defined?(Kitchen::Verifier::CincAuditor) &&
36
- defined?(Kitchen::Verifier::CincAuditor::TransportOptions)
37
- it "adds build_docker to Kitchen::Verifier::CincAuditor::TransportOptions" do
38
+ # Checked inside the example for the same load-order reason as above.
39
+ it "patches Kitchen::Verifier::CincAuditor::TransportOptions when the gem is available" do
40
+ load helper_path
41
+
42
+ if defined?(Kitchen::Verifier::CincAuditor::TransportOptions)
38
43
  expect(Kitchen::Verifier::CincAuditor::TransportOptions.method_defined?(:build_docker)).to be true
39
- end
40
- else
41
- it "Kitchen::Verifier::CincAuditor not available — patch correctly skipped" do
44
+ else
42
45
  expect(defined?(Kitchen::Verifier::CincAuditor)).to be_falsy
43
46
  end
44
47
  end
data/spec/spec_helper.rb CHANGED
@@ -21,7 +21,7 @@ require "rspec/its"
21
21
  require "kitchen/driver/docker"
22
22
 
23
23
  RSpec.configure do |config|
24
- # Basic configuraiton
24
+ # Basic configuration
25
25
  config.run_all_when_everything_filtered = true
26
26
  config.filter_run(:focus)
27
27
 
@@ -0,0 +1,123 @@
1
+ #
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ #
14
+
15
+ require "spec_helper"
16
+ require "kitchen/transport/docker"
17
+
18
+ describe Kitchen::Transport::Docker::Connection do
19
+ let(:options) do
20
+ {
21
+ binary: "docker",
22
+ container_id: "abc123",
23
+ platform: "ubuntu-24.04",
24
+ socket: "unix:///var/run/docker.sock",
25
+ username: "kitchen",
26
+ }
27
+ end
28
+
29
+ subject(:connection) { described_class.new(options) }
30
+
31
+ describe "#login_command" do
32
+ subject(:login_command) { connection.login_command }
33
+
34
+ it "returns a Kitchen::LoginCommand" do
35
+ expect(login_command).to be_a(Kitchen::LoginCommand)
36
+ end
37
+
38
+ it "execs the docker binary" do
39
+ expect(login_command.command).to eq "docker"
40
+ end
41
+
42
+ it "opens an interactive login shell on a Linux container" do
43
+ expect(login_command.arguments).to eq %w{
44
+ -H unix:///var/run/docker.sock
45
+ exec -t -i -u kitchen abc123 /bin/bash --login -i
46
+ }
47
+ end
48
+
49
+ it "passes each flag and its value as separate argv tokens" do
50
+ expect(login_command.arguments).to include("-H", "unix:///var/run/docker.sock")
51
+ expect(login_command.arguments).not_to include("-H unix:///var/run/docker.sock")
52
+ end
53
+
54
+ context "on a Windows container" do
55
+ let(:options) do
56
+ {
57
+ binary: "docker",
58
+ container_id: "abc123",
59
+ platform: "windows-2022",
60
+ socket: "tcp://localhost:2375",
61
+ username: nil,
62
+ }
63
+ end
64
+
65
+ it "opens a PowerShell session instead of bash" do
66
+ expect(login_command.arguments).to eq %w{
67
+ -H tcp://localhost:2375
68
+ exec -t -i abc123 powershell
69
+ }
70
+ end
71
+ end
72
+
73
+ context "with TLS configured" do
74
+ before do
75
+ options.merge!(
76
+ tls: true,
77
+ tls_verify: true,
78
+ tls_cacert: "/certs/ca.pem",
79
+ tls_cert: "/certs/cert.pem",
80
+ tls_key: "/certs/key.pem"
81
+ )
82
+ end
83
+
84
+ it "includes the TLS flags before the exec subcommand" do
85
+ expect(login_command.arguments.take(8)).to eq %w{
86
+ -H unix:///var/run/docker.sock
87
+ --tls --tlsverify
88
+ --tlscacert=/certs/ca.pem
89
+ --tlscert=/certs/cert.pem
90
+ --tlskey=/certs/key.pem
91
+ exec
92
+ }
93
+ end
94
+ end
95
+
96
+ context "with a working directory and environment variables" do
97
+ before do
98
+ options.merge!(working_dir: "/opt/kitchen", env_variables: { FOO: "bar" })
99
+ end
100
+
101
+ it "passes them through to docker exec" do
102
+ expect(login_command.arguments).to include("-w", "/opt/kitchen")
103
+ expect(login_command.arguments).to include("-e", "FOO=bar")
104
+ end
105
+ end
106
+
107
+ context "when the transport is configured to detach" do
108
+ before { options.merge!(detach: true) }
109
+
110
+ it "still runs attached so the session is usable" do
111
+ expect(login_command.arguments).not_to include("-d")
112
+ end
113
+ end
114
+
115
+ context "when the transport is configured as privileged" do
116
+ before { options.merge!(privileged: true) }
117
+
118
+ it "keeps the privileged flag" do
119
+ expect(login_command.arguments).to include("--privileged")
120
+ end
121
+ end
122
+ end
123
+ end
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: 3.2.3
4
+ version: 3.3.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: 2026-06-25 00:00:00.000000000 Z
11
+ date: 2026-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -74,20 +74,18 @@ files:
74
74
  - spec/dockerfile_helper_spec.rb
75
75
  - spec/inspec_helper_spec.rb
76
76
  - spec/spec_helper.rb
77
+ - spec/transport_docker_spec.rb
77
78
  - test/Dockerfile
78
79
  - test/cookbooks/cinc_test/metadata.rb
79
80
  - test/cookbooks/cinc_test/recipes/default.rb
80
81
  - test/cookbooks/docker_test/attributes/default.rb
81
82
  - test/cookbooks/docker_test/metadata.rb
82
83
  - test/cookbooks/docker_test/recipes/default.rb
83
- - test/integration/capabilities/disabled/capabilities_drop_spec.rb
84
84
  - test/integration/cinc/inspec/cinc_spec.rb
85
- - test/integration/default/disabled/default_spec.rb
86
- - test/integration/default/disabled/spec_helper.rb
87
85
  - test/integration/inspec/inspec_spec.rb
88
86
  homepage: https://github.com/test-kitchen/kitchen-docker
89
87
  licenses:
90
- - Apache 2.0
88
+ - Apache-2.0
91
89
  metadata: {}
92
90
  post_install_message:
93
91
  rdoc_options: []
@@ -97,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
95
  requirements:
98
96
  - - ">="
99
97
  - !ruby/object:Gem::Version
100
- version: '0'
98
+ version: '3.1'
101
99
  required_rubygems_version: !ruby/object:Gem::Requirement
102
100
  requirements:
103
101
  - - ">="
@@ -1,24 +0,0 @@
1
- #
2
- # Copyright 2016, Noah Kantrowitz
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- # Disable now busser-serever is gone.
18
- # require 'serverspec'
19
- # set :backend, :exec
20
-
21
- # describe command('/sbin/ifconfig eth0 multicast') do
22
- # its(:exit_status) { is_expected.to_not eq 0 }
23
- # its(:stderr) { is_expected.to match /Operation not permitted/ }
24
- # end
@@ -1,24 +0,0 @@
1
- #
2
- # Copyright 2016, Noah Kantrowitz
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- # Disable now busser-server is gone.
18
- # require "serverspec"
19
- # require "spec_helper"
20
- #
21
- # Just make sure the image launched and is reachable.
22
- # describe command("true") do
23
- # its(:exit_status) { is_expected.to eq 0 }
24
- # end
@@ -1,21 +0,0 @@
1
- #
2
- # Licensed under the Apache License, Version 2.0 (the "License");
3
- # you may not use this file except in compliance with the License.
4
- # You may obtain a copy of the License at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an "AS IS" BASIS,
10
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- # See the License for the specific language governing permissions and
12
- # limitations under the License.
13
- #
14
-
15
- # case RbConfig::CONFIG['host_os']
16
- # when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
17
- # set :backend, :cmd
18
- # set :os, :family => 'windows'
19
- # else
20
- # set :backend, :exec
21
- # end