test-kitchen 3.6.0 → 3.7.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: ecd483d58546fb48da8bb5a4e5c448b7cc2f8b7d2c0082d0df4b023c380a2594
4
- data.tar.gz: cb42f2dae4d33d84ff8515a7412d7e1d14c358504f66429b21465bef7714e48b
3
+ metadata.gz: 78dcb8180d72d9ce32f3cf860d2dbb90d4c66ba2920cdf03252717bd4674a3f5
4
+ data.tar.gz: fc68fb60b6fa811425c3079a317946414cfca980198e4e668fbcc0e4c507841a
5
5
  SHA512:
6
- metadata.gz: 8adf00afe37d4b31dec9b6acca4aee2aa858b265db0fee4f0c0fac8407691f452e7d487d45ec5f72e816d0799060affcaf31d8885597ade1a9d40dc59f6056bc
7
- data.tar.gz: bc82343bf133cbce4c9c5096d1d88a9bb7ab56cf619d289f71008388757d553c43432f3188d72ddc87c917212ce6a6278ee0d81a64b8f7d688341e387da2949f
6
+ metadata.gz: 04e4ddf2b8c612db3a71ef7a7d720c5f586813f8ba3263415d56385f41e90b89663e2c4091fbbd03f60ff4c8922413988df086c71a93fbf7a396f903303b03d9
7
+ data.tar.gz: 93131c18cdc7889dd9c2e477c598a409ae4d1b47a865fdf4bba6ae54da6b48de59bfc1c7b57015b0dc011a311762e18b13c13955e8e45cc95f852807845d4073
data/Gemfile CHANGED
@@ -7,15 +7,15 @@ group :test do
7
7
  gem "rb-readline"
8
8
  gem "aruba", ">= 0.11", "< 3.0"
9
9
  gem "countloc", "~> 0.4"
10
- gem "cucumber", ">= 2.1", "< 8.1"
10
+ gem "cucumber", ">= 9.2", "< 10"
11
11
  gem "fakefs", "~> 2.0"
12
12
  gem "maruku", "~> 0.6"
13
- gem "minitest", "~> 5.3", "< 5.16"
13
+ gem "minitest", "~> 5.3", "< 6.0"
14
14
  gem "mocha", "~> 2.0"
15
15
  end
16
16
 
17
17
  group :integration do
18
- gem "berkshelf"
18
+ gem "chef-cli"
19
19
  gem "kitchen-dokken"
20
20
  gem "kitchen-inspec"
21
21
  gem "kitchen-vagrant"
@@ -244,6 +244,7 @@ module Kitchen
244
244
  end
245
245
 
246
246
  def doctor(state)
247
+ deprecated_config = instance.driver.instance_variable_get(:@deprecated_config)
247
248
  deprecated_config.each do |attr, msg|
248
249
  info("**** #{attr} deprecated\n#{msg}")
249
250
  end
@@ -0,0 +1,130 @@
1
+ #
2
+ # Author:: Thomas Heinen (<thomas.heinen@gmail.com>)
3
+ #
4
+ # Copyright (C) 2023, Thomas Heinen
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ require_relative "chef_infra"
19
+
20
+ module Kitchen
21
+ module Provisioner
22
+ # Chef Target provisioner.
23
+ #
24
+ # @author Thomas Heinen <thomas.heinen@gmail.com>
25
+ class ChefTarget < ChefInfra
26
+ MIN_VERSION_REQUIRED = "19.0.0".freeze
27
+ class ChefVersionTooLow < UserError; end
28
+ class ChefClientNotFound < UserError; end
29
+ class RequireTrainTransport < UserError; end
30
+
31
+ default_config :install_strategy, "none"
32
+ default_config :sudo, true
33
+
34
+ def install_command; ""; end
35
+ def init_command; ""; end
36
+ def prepare_command; ""; end
37
+
38
+ def chef_args(client_rb_filename)
39
+ # Dummy execution to initialize and test remote connection
40
+ connection = instance.remote_exec("echo Connection established")
41
+
42
+ check_transport(connection)
43
+ check_local_chef_client
44
+
45
+ instance_name = instance.name
46
+ credentials_file = File.join(kitchen_basepath, ".kitchen", instance_name + ".ini")
47
+ File.write(credentials_file, connection.credentials_file)
48
+
49
+ super.concat([
50
+ "--target #{instance_name}",
51
+ "--credentials #{credentials_file}",
52
+ ])
53
+ end
54
+
55
+ def check_transport(connection)
56
+ debug("Checking for active transport")
57
+
58
+ unless connection.respond_to? "train_uri"
59
+ error("Chef Target Mode provisioner requires a Train-based transport like kitchen-transport-train")
60
+ raise RequireTrainTransport.new("No Train transport")
61
+ end
62
+
63
+ debug("Kitchen transport responds to train_uri function call, as required")
64
+ end
65
+
66
+ def check_local_chef_client
67
+ debug("Checking for chef-client version")
68
+
69
+ begin
70
+ client_version = `chef-client -v`.chop.split(":")[-1]
71
+ rescue Errno::ENOENT => e
72
+ error("Error determining Chef Infra version: #{e.exception.message}")
73
+ raise ChefClientNotFound.new("Need chef-client installed locally")
74
+ end
75
+
76
+ minimum_version = Gem::Version.new(MIN_VERSION_REQUIRED)
77
+ installed_version = Gem::Version.new(client_version)
78
+
79
+ if installed_version < minimum_version
80
+ error("Found Chef Infra version #{installed_version}, but require #{minimum_version} for Target Mode")
81
+ raise ChefVersionTooLow.new("Need version #{MIN_VERSION_REQUIRED} or higher")
82
+ end
83
+
84
+ debug("Chef Infra found and version constraints match")
85
+ end
86
+
87
+ def kitchen_basepath
88
+ instance.driver.config[:kitchen_root]
89
+ end
90
+
91
+ def create_sandbox
92
+ super
93
+
94
+ # Change config.rb to point to the local sandbox path, not to /tmp/kitchen
95
+ config[:root_path] = sandbox_path
96
+ prepare_config_rb
97
+ end
98
+
99
+ def call(state)
100
+ remote_connection = instance.transport.connection(state)
101
+
102
+ config[:uploads].to_h.each do |locals, remote|
103
+ debug("Uploading #{Array(locals).join(", ")} to #{remote}")
104
+ remote_connection.upload(locals.to_s, remote)
105
+ end
106
+
107
+ # no installation
108
+ create_sandbox
109
+ # no prepare command
110
+
111
+ # Stream output to logger
112
+ require "open3"
113
+ Open3.popen2e(run_command) do |_stdin, output, _thread|
114
+ output.each { |line| logger << line }
115
+ end
116
+
117
+ info("Downloading files from #{instance.to_str}")
118
+ config[:downloads].to_h.each do |remotes, local|
119
+ debug("Downloading #{Array(remotes).join(", ")} to #{local}")
120
+ remote_connection.download(remotes, local)
121
+ end
122
+ debug("Download complete")
123
+ rescue Kitchen::Transport::TransportFailed => ex
124
+ raise ActionFailed, ex.message
125
+ ensure
126
+ cleanup_sandbox
127
+ end
128
+ end
129
+ end
130
+ end
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
 
18
18
  module Kitchen
19
- VERSION = "3.6.0".freeze
19
+ VERSION = "3.7.0".freeze
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-27 00:00:00.000000000 Z
11
+ date: 2024-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt_pbkdf
@@ -294,6 +294,7 @@ files:
294
294
  - lib/kitchen/provisioner/chef_base.rb
295
295
  - lib/kitchen/provisioner/chef_infra.rb
296
296
  - lib/kitchen/provisioner/chef_solo.rb
297
+ - lib/kitchen/provisioner/chef_target.rb
297
298
  - lib/kitchen/provisioner/chef_zero.rb
298
299
  - lib/kitchen/provisioner/dummy.rb
299
300
  - lib/kitchen/provisioner/shell.rb