test-kitchen 3.6.0 → 3.7.2

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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -6
  3. data/LICENSE +1 -1
  4. data/Rakefile +2 -2
  5. data/lib/kitchen/base64_stream.rb +5 -5
  6. data/lib/kitchen/chef_utils_wiring.rb +2 -2
  7. data/lib/kitchen/cli.rb +1 -1
  8. data/lib/kitchen/collection.rb +1 -1
  9. data/lib/kitchen/color.rb +2 -2
  10. data/lib/kitchen/command/action.rb +1 -1
  11. data/lib/kitchen/command/console.rb +1 -1
  12. data/lib/kitchen/command/diagnose.rb +1 -1
  13. data/lib/kitchen/command/doctor.rb +1 -1
  14. data/lib/kitchen/command/exec.rb +1 -1
  15. data/lib/kitchen/command/list.rb +3 -3
  16. data/lib/kitchen/command/login.rb +1 -1
  17. data/lib/kitchen/command/package.rb +1 -1
  18. data/lib/kitchen/command/sink.rb +1 -1
  19. data/lib/kitchen/command/test.rb +1 -1
  20. data/lib/kitchen/command.rb +6 -6
  21. data/lib/kitchen/config.rb +2 -2
  22. data/lib/kitchen/configurable.rb +3 -3
  23. data/lib/kitchen/data_munger.rb +3 -3
  24. data/lib/kitchen/diagnostic.rb +2 -2
  25. data/lib/kitchen/driver/base.rb +1 -1
  26. data/lib/kitchen/driver/dummy.rb +1 -1
  27. data/lib/kitchen/driver/exec.rb +1 -1
  28. data/lib/kitchen/driver/proxy.rb +1 -1
  29. data/lib/kitchen/driver/ssh_base.rb +1 -1
  30. data/lib/kitchen/driver.rb +1 -1
  31. data/lib/kitchen/errors.rb +1 -1
  32. data/lib/kitchen/generator/init.rb +2 -2
  33. data/lib/kitchen/instance.rb +9 -9
  34. data/lib/kitchen/lazy_hash.rb +1 -1
  35. data/lib/kitchen/lifecycle_hooks.rb +1 -1
  36. data/lib/kitchen/loader/yaml.rb +5 -5
  37. data/lib/kitchen/logger.rb +1 -1
  38. data/lib/kitchen/logging.rb +1 -1
  39. data/lib/kitchen/login_command.rb +2 -2
  40. data/lib/kitchen/metadata_chopper.rb +1 -1
  41. data/lib/kitchen/platform.rb +1 -1
  42. data/lib/kitchen/platform_filter.rb +4 -2
  43. data/lib/kitchen/plugin.rb +1 -1
  44. data/lib/kitchen/plugin_base.rb +1 -1
  45. data/lib/kitchen/provisioner/base.rb +1 -1
  46. data/lib/kitchen/provisioner/chef/berkshelf.rb +2 -2
  47. data/lib/kitchen/provisioner/chef/common_sandbox.rb +2 -2
  48. data/lib/kitchen/provisioner/chef/policyfile.rb +11 -5
  49. data/lib/kitchen/provisioner/chef_apply.rb +3 -3
  50. data/lib/kitchen/provisioner/chef_base.rb +7 -6
  51. data/lib/kitchen/provisioner/chef_infra.rb +2 -2
  52. data/lib/kitchen/provisioner/chef_solo.rb +1 -1
  53. data/lib/kitchen/provisioner/chef_target.rb +130 -0
  54. data/lib/kitchen/provisioner/dummy.rb +1 -1
  55. data/lib/kitchen/provisioner/shell.rb +1 -1
  56. data/lib/kitchen/provisioner.rb +1 -1
  57. data/lib/kitchen/rake_tasks.rb +1 -1
  58. data/lib/kitchen/shell_out.rb +2 -2
  59. data/lib/kitchen/ssh.rb +3 -3
  60. data/lib/kitchen/state_file.rb +2 -2
  61. data/lib/kitchen/suite.rb +1 -1
  62. data/lib/kitchen/thor_tasks.rb +1 -1
  63. data/lib/kitchen/transport/base.rb +1 -1
  64. data/lib/kitchen/transport/dummy.rb +1 -1
  65. data/lib/kitchen/transport/exec.rb +2 -2
  66. data/lib/kitchen/transport/ssh.rb +2 -2
  67. data/lib/kitchen/transport/winrm.rb +2 -2
  68. data/lib/kitchen/transport.rb +2 -2
  69. data/lib/kitchen/util.rb +2 -2
  70. data/lib/kitchen/verifier/base.rb +2 -2
  71. data/lib/kitchen/verifier/busser.rb +1 -1
  72. data/lib/kitchen/verifier/dummy.rb +1 -1
  73. data/lib/kitchen/verifier/shell.rb +1 -1
  74. data/lib/kitchen/verifier.rb +1 -1
  75. data/lib/kitchen/version.rb +2 -2
  76. data/lib/kitchen/which.rb +1 -1
  77. data/lib/kitchen.rb +1 -1
  78. data/lib/vendor/hash_recursive_merge.rb +1 -1
  79. data/templates/driver/license_apachev2.erb +1 -1
  80. data/templates/driver/license_lgplv3.erb +1 -1
  81. data/templates/init/kitchen.yml.erb +2 -2
  82. data/test-kitchen.gemspec +1 -1
  83. metadata +6 -5
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -23,7 +23,7 @@ require "yaml" unless defined?(YAML)
23
23
  module Kitchen
24
24
  module Loader
25
25
  # YAML file loader for Test Kitchen configuration. This class is
26
- # responisble for parsing the main YAML file and the local YAML if it
26
+ # responsible for parsing the main YAML file and the local YAML if it
27
27
  # exists. Local file configuration will win over the default configuration.
28
28
  # The client of this class should not require any YAML loading or parsing
29
29
  # logic.
@@ -156,7 +156,7 @@ module Kitchen
156
156
  @process_erb ? process_erb(string, file) : string
157
157
  end
158
158
 
159
- # Passes a string through ERb to evaulate any ERb blocks.
159
+ # Passes a string through ERb to evaluate any ERb blocks.
160
160
  #
161
161
  # @param string [String] the string to process
162
162
  # @param file [String] an absolute path to the file represented as the
@@ -242,7 +242,7 @@ module Kitchen
242
242
  File.join(File.expand_path(ENV["HOME"]), ".kitchen", "config.yml")
243
243
  end
244
244
 
245
- # Generate a diganose Hash for a particular YAML file Hash. If an error
245
+ # Generate a diagnose Hash for a particular YAML file Hash. If an error
246
246
  # occurs when loading the data, then a failure hash will be inserted
247
247
  # into the `:raw_data` sub-hash.
248
248
  #
@@ -263,7 +263,7 @@ module Kitchen
263
263
  { filename: file, raw_data: hash }
264
264
  end
265
265
 
266
- # Generates a Hash respresenting a failure, given an Exception object.
266
+ # Generates a Hash representing a failure, given an Exception object.
267
267
  #
268
268
  # @param e [Exception] an exception
269
269
  # @param file [String] the absolute path to a file (default: `nil`)
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -35,7 +35,7 @@ module Kitchen
35
35
  # @param command [String] command
36
36
  # @param arguments [Array] array of arguments to the command
37
37
  # @param options [Hash] options hash, passed to `Kernel#exec`
38
- # @see http://www.ruby-doc.org/core-2.1.2/Kernel.html#method-i-exec
38
+ # @see https://ruby-doc.org/core-2.1.2/Kernel.html#method-i-exec
39
39
  def initialize(command, arguments, options = {})
40
40
  @command = command
41
41
  @arguments = Array(arguments)
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -50,7 +50,9 @@ module Kitchen
50
50
  #
51
51
  # @param [Regexp,String] value of the filter
52
52
  def initialize(value)
53
- raise ::ArgumentError, "PlatformFilter#new requires value to be a String or a Regexp" unless value.is_a?(::Regexp) || value.is_a?(::String)
53
+ unless value.is_a?(::Regexp) || value.is_a?(::String)
54
+ raise ::ArgumentError, "PlatformFilter#new requires value to be a String or a Regexp"
55
+ end
54
56
 
55
57
  @value = value
56
58
  end
@@ -8,7 +8,7 @@
8
8
  # you may not use this file except in compliance with the License.
9
9
  # You may obtain a copy of the License at
10
10
  #
11
- # http://www.apache.org/licenses/LICENSE-2.0
11
+ # https://www.apache.org/licenses/LICENSE-2.0
12
12
  #
13
13
  # Unless required by applicable law or agreed to in writing, software
14
14
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -87,7 +87,7 @@ module Kitchen
87
87
  class << self
88
88
  private
89
89
 
90
- # Load the Berkshelf-specific libary code.
90
+ # Load the Berkshelf-specific library code.
91
91
  #
92
92
  # @param logger [Kitchen::Logger] the logger to use
93
93
  # @raise [UserError] if the library couldn't be loaded
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -162,7 +162,7 @@ module Kitchen
162
162
  info("Removing non-cookbook files before transfer")
163
163
  FileUtils.rm(all_files_in_cookbooks - only_cookbook_files)
164
164
  Util.list_directory(tmpbooks_dir, recurse: true)
165
- .reverse_each { |fn| FileUtils.rmdir(fn) if File.directory?(fn) && Dir.entries(fn).size == 2 }
165
+ .reverse_each { |fn| FileUtils.rmdir(fn) if File.directory?(fn) && Dir.empty?(fn) }
166
166
  end
167
167
 
168
168
  # @return [Logger] the instance's logger or Test Kitchen's common
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -63,10 +63,10 @@ module Kitchen
63
63
  def resolve
64
64
  if policy_group
65
65
  info("Exporting cookbook dependencies from Policyfile #{path} with policy_group #{policy_group} using `#{cli_path} export`...")
66
- run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --policy_group #{policy_group} --force --chef-license #{license}")
66
+ run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --policy_group #{policy_group} --force #{chef_license(license)}")
67
67
  else
68
68
  info("Exporting cookbook dependencies from Policyfile #{path} using `#{cli_path} export`...")
69
- run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --force --chef-license #{license}")
69
+ run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --force #{chef_license(license)}")
70
70
  end
71
71
  end
72
72
 
@@ -78,11 +78,11 @@ module Kitchen
78
78
  else
79
79
  info("Policy lock file doesn't exist, running `#{cli_path} install` for Policyfile #{policyfile}...")
80
80
  end
81
- run_command("#{cli_path} install #{escape_path(policyfile)} --chef-license #{license}")
81
+ run_command("#{cli_path} install #{escape_path(policyfile)} #{chef_license(license)}")
82
82
 
83
83
  if always_update
84
84
  info("Updating policy lock using `#{cli_path} update`")
85
- run_command("#{cli_path} update #{escape_path(policyfile)} --chef-license #{license}")
85
+ run_command("#{cli_path} update #{escape_path(policyfile)} #{chef_license(license)}")
86
86
  end
87
87
  end
88
88
 
@@ -161,6 +161,12 @@ module Kitchen
161
161
  "setting includes the path to the `chef` or `chef-cli` commands.")
162
162
  raise UserError, "Could not find the chef or chef-cli executables in your PATH."
163
163
  end
164
+
165
+ # Return `"--chef-license #{license}"` when `license` is not nil or empty and the empty string otherwise.
166
+ def chef_license(license)
167
+ (license.nil? || license.empty?) ? "" : "--chef-license #{license}"
168
+ end
169
+
164
170
  end
165
171
  end
166
172
  end
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,8 +29,8 @@
29
29
  # name: chef_apply
30
30
  #
31
31
  # platforms:
32
- # - name: ubuntu-20.04
33
- # - name: centos-8
32
+ # - name: ubuntu-24.04
33
+ # - name: almalinux-10
34
34
  #
35
35
  # suites:
36
36
  # - name: default
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -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
@@ -272,7 +273,7 @@ module Kitchen
272
273
  # @return [String] license id to prompt for acceptance
273
274
  def license_acceptance_id
274
275
  case
275
- when File.exist?(policyfile)
276
+ when File.exist?(policyfile) && (config[:product_name].nil? || config[:product_name].start_with?("chef"))
276
277
  "chef-workstation"
277
278
  when config[:product_name]
278
279
  config[:product_name]
@@ -391,7 +392,7 @@ module Kitchen
391
392
  # @return [Hash] a configuration hash
392
393
  # @api private
393
394
  def default_config_rb # rubocop:disable Metrics/MethodLength
394
- root = config[:root_path].gsub("$env:TEMP", "\#{ENV['TEMP']\}")
395
+ root = config[:root_path].gsub("$env:TEMP", "\#{ENV['TEMP']}")
395
396
 
396
397
  config_rb = {
397
398
  node_name: instance.name,
@@ -442,7 +443,7 @@ module Kitchen
442
443
  if obj.is_a?(String) && obj =~ /^:/
443
444
  obj
444
445
  elsif obj.is_a?(String)
445
- %{"#{obj.gsub(/\\/, "\\\\\\\\")}"}
446
+ %{"#{obj.gsub("\\", "\\\\\\\\")}"}
446
447
  elsif obj.is_a?(Array)
447
448
  %{[#{obj.map { |i| format_value(i) }.join(", ")}]}
448
449
  else
@@ -600,12 +601,12 @@ module Kitchen
600
601
  # @api private
601
602
  def sanity_check_sandbox_options!
602
603
  if (config[:policyfile_path] || config[:policyfile]) && !File.exist?(policyfile)
603
- raise UserError, "policyfile_path set in config "\
604
+ raise UserError, "policyfile_path set in config " \
604
605
  "(#{config[:policyfile_path]} could not be found. " \
605
606
  "Expected to find it at full path #{policyfile}."
606
607
  end
607
608
  if config[:berksfile_path] && !File.exist?(berksfile)
608
- raise UserError, "berksfile_path set in config "\
609
+ raise UserError, "berksfile_path set in config " \
609
610
  "(#{config[:berksfile_path]} could not be found. " \
610
611
  "Expected to find it at full path #{berksfile}."
611
612
  end
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -138,7 +138,7 @@ module Kitchen
138
138
  debug("Using a dummy validation.pem")
139
139
 
140
140
  source = File.join(File.dirname(__FILE__),
141
- %w{.. .. .. support dummy-validation.pem})
141
+ %w{.. .. .. support dummy-validation.pem})
142
142
  FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
143
143
  end
144
144
 
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -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
+ # https://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.push(
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
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -8,7 +8,7 @@
8
8
  # you may not use this file except in compliance with the License.
9
9
  # You may obtain a copy of the License at
10
10
  #
11
- # http://www.apache.org/licenses/LICENSE-2.0
11
+ # https://www.apache.org/licenses/LICENSE-2.0
12
12
  #
13
13
  # Unless required by applicable law or agreed to in writing, software
14
14
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -78,7 +78,7 @@ module Kitchen
78
78
  # Returns a hash of MixLib::ShellOut options for the command.
79
79
  #
80
80
  # @param options [Hash] a Hash of options
81
- # @return [Hash] a new Hash of options, filterd and merged with defaults
81
+ # @return [Hash] a new Hash of options, filtered and merged with defaults
82
82
  # @api private
83
83
  def shell_opts(options)
84
84
  filtered_opts = options.reject do |key, _value|
data/lib/kitchen/ssh.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -92,7 +92,7 @@ module Kitchen
92
92
  # @param remote [String] path to remote file destination
93
93
  # @param options [Hash] configuration options that are passed to
94
94
  # `Net::SCP.upload`
95
- # @see http://net-ssh.github.io/net-scp/classes/Net/SCP.html#method-i-upload
95
+ # @see https://net-ssh.github.io/net-scp/classes/Net/SCP.html#method-i-upload
96
96
  def upload!(local, remote, options = {}, &progress)
97
97
  require "net/scp" unless defined?(Net::SCP)
98
98
  if progress.nil?
@@ -124,7 +124,7 @@ module Kitchen
124
124
  # @param options [Hash] configuration options that are passed to
125
125
  # `Net::SCP.upload`
126
126
  # @option options [true,false] :recursive recursive copy (default: `true`)
127
- # @see http://net-ssh.github.io/net-scp/classes/Net/SCP.html#method-i-upload
127
+ # @see https://net-ssh.github.io/net-scp/classes/Net/SCP.html#method-i-upload
128
128
  def upload_path!(local, remote, options = {}, &progress)
129
129
  options = { recursive: true }.merge(options)
130
130
 
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -43,7 +43,7 @@ module Kitchen
43
43
  # @raise [StateFileLoadError] if there is a problem loading the state file
44
44
  # from disk and loading it into a Hash
45
45
  def read
46
- if File.exist?(file_name) && !File.zero?(file_name)
46
+ if File.exist?(file_name) && !File.empty?(file_name)
47
47
  Util.symbolized_hash(deserialize_string(read_file))
48
48
  else
49
49
  {}
data/lib/kitchen/suite.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -8,7 +8,7 @@
8
8
  # you may not use this file except in compliance with the License.
9
9
  # You may obtain a copy of the License at
10
10
  #
11
- # http://www.apache.org/licenses/LICENSE-2.0
11
+ # https://www.apache.org/licenses/LICENSE-2.0
12
12
  #
13
13
  # Unless required by applicable law or agreed to in writing, software
14
14
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -7,7 +7,7 @@
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
9
  #
10
- # http://www.apache.org/licenses/LICENSE-2.0
10
+ # https://www.apache.org/licenses/LICENSE-2.0
11
11
  #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
6
+ # https://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
9
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -59,7 +59,7 @@ module Kitchen
59
59
  # @see Base#upload
60
60
  def upload(locals, remote)
61
61
  # evaluate $env:temp on Windows
62
- real_remote = remote.to_s == "\$env:TEMP\\kitchen" ? kitchen_temp : remote
62
+ real_remote = remote.to_s == "$env:TEMP\\kitchen" ? kitchen_temp : remote
63
63
  FileUtils.mkdir_p(real_remote)
64
64
  Array(locals).each do |local|
65
65
  FileUtils.cp_r(local, real_remote)