test-kitchen 2.10.0 → 2.11.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: 51ed51940914e0c4ffb30d1e11be2e3554289833261e0b418eaa2ebdb674cab9
4
- data.tar.gz: c3c9be7593e1c0c333102168228c84e217244c5071da0bfb2ba543edca7581ba
3
+ metadata.gz: 36e340a7aefc9e4512f05ded9b43003298a3466de705d7c6c6050dd07f433175
4
+ data.tar.gz: 310ae63b637cbd62a88cd5beef8effa437f0d1b2dec6bf9098ba3112e621c8ed
5
5
  SHA512:
6
- metadata.gz: 59633a6df2c274542ee3d4c649c55f8632077a98476ee655a1f59c0b39d42fad9077294b0e615d8e7f697feef4cbb027a9df7be81708832760d45eee72fbf159
7
- data.tar.gz: 34164cc7046bb2aa507fa33373c928d94be84284a99ba629562c585614c1818d032a42a1b2b83ab0b95382e984841be63a2dc32a05412dbf8d60a15839325146
6
+ metadata.gz: cc3e9bf0e55d519d757e4339b4e643f038216dedb573225aed9cc1ce2972ad121e7819db643e26e4038ebe5fc05e2bc0a57435588d462bf2d2a4a198cbd0b9b1
7
+ data.tar.gz: 48c9bc01e69691e4096f5ae219638b0d996f069852c3ac14ec143ce583c3f6f610263000e5b24256b3b969314c9903e95b570372c1d3a8d3298d3ba4c65885bd
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source "https://rubygems.org"
2
+
3
+ # Specify your gem"s dependencies in test-kitchen.gemspec
2
4
  gemspec
3
5
 
4
6
  group :integration do
@@ -8,10 +10,6 @@ group :integration do
8
10
  gem "kitchen-vagrant"
9
11
  end
10
12
 
11
- group :changelog do
12
- gem "github_changelog_generator", "1.15.2"
13
- end
14
-
15
13
  group :debug do
16
14
  gem "pry"
17
15
  gem "pry-byebug"
@@ -19,9 +17,5 @@ group :debug do
19
17
  end
20
18
 
21
19
  group :chefstyle do
22
- gem "chefstyle"
23
- end
24
-
25
- group :docs do
26
- gem "yard"
27
- end
20
+ gem "chefstyle", "1.6.2"
21
+ end
data/Rakefile CHANGED
@@ -41,30 +41,8 @@ end
41
41
  desc "Run all quality tasks"
42
42
  task quality: %i{style stats}
43
43
 
44
- begin
45
- require "yard" unless defined?(YARD)
46
- YARD::Rake::YardocTask.new
47
- rescue LoadError
48
- puts "yard is not available. (sudo) gem install yard to generate yard documentation."
49
- end
50
-
51
44
  task default: %i{test quality}
52
45
 
53
- begin
54
- require "github_changelog_generator/task"
55
- require "kitchen/version"
56
-
57
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
58
- config.future_release = "v#{Kitchen::VERSION}"
59
- config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature,Improvement".split(",")
60
- config.bug_labels = "bug,Bug".split(",")
61
- config.exclude_labels = %w{Duplicate Question Discussion No_Changelog}
62
- end
63
- rescue LoadError
64
- puts "github_changelog_generator is not available." \
65
- " (sudo) gem install github_changelog_generator to generate changelogs"
66
- end
67
-
68
46
  namespace :docs do
69
47
  desc "Deploy docs"
70
48
  task :deploy do
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
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
+
19
+ module Kitchen
20
+ # Common Dependency Injection wiring for ChefUtils-related modules
21
+ module ChefUtilsWiring
22
+ private
23
+
24
+ def __config
25
+ # this would need to be some kind of Chef::Config looking thing, which probably requires
26
+ # a translation object from t-k config to Chef::Config layout if that ever becomes necessary.
27
+ # this ISNT the t-k config.
28
+ {}
29
+ end
30
+
31
+ def __log
32
+ @logger
33
+ end
34
+
35
+ def __transport_connection
36
+ # this could be wired up to train at some point, but need to be careful because about local vs. remote
37
+ # uses of helpers with test-kitchen, right now we're using it for local.
38
+ end
39
+ end
40
+ end
@@ -74,7 +74,7 @@ module Kitchen
74
74
 
75
75
  instance.transport.connection(state) do |conn|
76
76
  config[:uploads].to_h.each do |locals, remote|
77
- debug("Uploading #{Array(locals).join(', ')} to #{remote}")
77
+ debug("Uploading #{Array(locals).join(", ")} to #{remote}")
78
78
  conn.upload(locals.to_s, remote)
79
79
  end
80
80
  conn.execute(install_command)
@@ -21,6 +21,7 @@ require "rbconfig" unless defined?(RbConfig)
21
21
  require_relative "../../errors"
22
22
  require_relative "../../logging"
23
23
  require_relative "../../shell_out"
24
+ require_relative "../../which"
24
25
 
25
26
  module Kitchen
26
27
  module Provisioner
@@ -31,6 +32,7 @@ module Kitchen
31
32
  class Policyfile
32
33
  include Logging
33
34
  include ShellOut
35
+ include Which
34
36
 
35
37
  # Creates a new cookbook resolver.
36
38
  #
@@ -40,9 +42,9 @@ module Kitchen
40
42
  # @param logger [Kitchen::Logger] a logger to use for output, defaults
41
43
  # to `Kitchen.logger`
42
44
  def initialize(policyfile, path, logger: Kitchen.logger, always_update: false)
43
- @policyfile = policyfile
44
- @path = path
45
- @logger = logger
45
+ @policyfile = policyfile
46
+ @path = path
47
+ @logger = logger
46
48
  @always_update = always_update
47
49
  end
48
50
 
@@ -51,30 +53,29 @@ module Kitchen
51
53
  # @param logger [Kitchen::Logger] a logger to use for output, defaults
52
54
  # to `Kitchen.logger`
53
55
  def self.load!(logger: Kitchen.logger)
54
- detect_chef_command!(logger)
56
+ # intentionally left blank
55
57
  end
56
58
 
57
59
  # Performs the cookbook resolution and vendors the resulting cookbooks
58
60
  # in the desired path.
59
61
  def resolve
60
- info("Exporting cookbook dependencies from Policyfile #{path}...")
61
- run_command("chef export #{escape_path(policyfile)} #{escape_path(path)} --force")
62
+ info("Exporting cookbook dependencies from Policyfile #{path} using `#{cli_path} export`...")
63
+ run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --force")
62
64
  end
63
65
 
64
66
  # Runs `chef install` to determine the correct cookbook set and
65
67
  # generate the policyfile lock.
66
68
  def compile
67
69
  if File.exist?(lockfile)
68
- info("Installing cookbooks for Policyfile #{policyfile} using `chef install`")
70
+ info("Installing cookbooks for Policyfile #{policyfile} using `#{cli_path} install`")
69
71
  else
70
- info("Policy lock file doesn't exist, running `chef install` for "\
71
- "Policyfile #{policyfile}...")
72
+ info("Policy lock file doesn't exist, running `#{cli_path} install` for Policyfile #{policyfile}...")
72
73
  end
73
- run_command("chef install #{escape_path(policyfile)}")
74
+ run_command("#{cli_path} install #{escape_path(policyfile)}")
74
75
 
75
76
  if always_update
76
- info("Updating policy lock using `chef update`")
77
- run_command("chef update #{escape_path(policyfile)}")
77
+ info("Updating policy lock using `#{cli_path} update`")
78
+ run_command("#{cli_path} update #{escape_path(policyfile)}")
78
79
  end
79
80
  end
80
81
 
@@ -126,33 +127,24 @@ module Kitchen
126
127
  end
127
128
  end
128
129
 
129
- class << self
130
- private
131
-
132
- # Ensure the `chef` command is in the path.
133
- #
134
- # @param logger [Kitchen::Logger] the logger to use
135
- # @raise [UserError] if the `chef` command is not in the PATH
136
- # @api private
137
- def detect_chef_command!(logger)
138
- unless ENV["PATH"].split(File::PATH_SEPARATOR).any? do |path|
139
- if /mswin|mingw/.match?(RbConfig::CONFIG["host_os"])
140
- # Windows could have different extentions: BAT, EXE or NONE
141
- %w{chef chef.exe chef.bat}.each do |bin|
142
- File.exist?(File.join(path, bin))
143
- end
144
- else
145
- File.exist?(File.join(path, "chef"))
146
- end
147
- end
148
- logger.fatal("The `chef` executable cannot be found in your " \
149
- "PATH. Ensure you have installed Chef Workstation " \
150
- "from https://downloads.chef.io and that your PATH " \
151
- "setting includes the path to the `chef` command.")
152
- raise UserError,
153
- "Could not find the chef executable in your PATH."
154
- end
155
- end
130
+ # Find the `chef` or `chef-cli` commands in the path or raise `chef` is present in
131
+ # ChefDK / Workstation releases, but is no longer shipped in any gems now that we
132
+ # use a Go based wrapper for the `chef` command in Workstation. The Ruby CLI has been
133
+ # renamed `chef-cli` under the hood and is shipped in the `chef-cli` gem.
134
+ #
135
+ # @api private
136
+ # @returns [String]
137
+ def cli_path
138
+ @cli_path ||= which("chef-cli") || which("chef") || no_cli_found_error
139
+ end
140
+
141
+ # @api private
142
+ def no_cli_found_error
143
+ @logger.fatal("The `chef` or `chef-cli` executables cannot be found in your " \
144
+ "PATH. Ensure you have installed Chef Workstation " \
145
+ "from https://downloads.chef.io and that your PATH " \
146
+ "setting includes the path to the `chef` or `chef-cli` commands.")
147
+ raise UserError, "Could not find the chef or chef-cli executables in your PATH."
156
148
  end
157
149
 
158
150
  end
@@ -195,18 +195,16 @@ module Kitchen
195
195
  FileUtils.mkdir_p(File.dirname(local))
196
196
 
197
197
  Array(remotes).each do |file|
198
+ logger.debug("Attempting to download '#{file}' as file")
199
+ session.scp.download!(file, local)
200
+ rescue Net::SCP::Error
198
201
  begin
199
- logger.debug("Attempting to download '#{file}' as file")
200
- session.scp.download!(file, local)
202
+ logger.debug("Attempting to download '#{file}' as directory")
203
+ session.scp.download!(file, local, recursive: true)
201
204
  rescue Net::SCP::Error
202
- begin
203
- logger.debug("Attempting to download '#{file}' as directory")
204
- session.scp.download!(file, local, recursive: true)
205
- rescue Net::SCP::Error
206
- logger.warn(
207
- "SCP download failed for file or directory '#{file}', perhaps it does not exist?"
208
- )
209
- end
205
+ logger.warn(
206
+ "SCP download failed for file or directory '#{file}', perhaps it does not exist?"
207
+ )
210
208
  end
211
209
  end
212
210
  rescue Net::SSH::Exception => ex
@@ -88,6 +88,7 @@ module Kitchen
88
88
  env_state[:environment]["KITCHEN_INSTANCE"] = instance.name
89
89
  env_state[:environment]["KITCHEN_PLATFORM"] = instance.platform.name
90
90
  env_state[:environment]["KITCHEN_SUITE"] = instance.suite.name
91
+ env_state[:environment]["KITCHEN_USERNAME"] = instance.transport[:username] if instance.respond_to?(:transport)
91
92
  state.each_pair do |key, value|
92
93
  env_state[:environment]["KITCHEN_" + key.to_s.upcase] = value.to_s
93
94
  end
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
 
18
18
  module Kitchen
19
- VERSION = "2.10.0".freeze
19
+ VERSION = "2.11.0".freeze
20
20
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
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 "chef-utils/dsl/which" unless defined?(ChefUtils::DSL::Which)
19
+ require_relative "chef_utils_wiring" unless defined?(Ohai::Mixin::ChefUtilsWiring)
20
+
21
+ module Kitchen
22
+ module Which
23
+ include ChefUtils::DSL::Which
24
+ include ChefUtilsWiring
25
+ end
26
+ end
data/test-kitchen.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.executables = %w{kitchen}
21
21
  gem.require_paths = ["lib"]
22
22
 
23
- gem.required_ruby_version = ">= 2.4"
23
+ gem.required_ruby_version = ">= 2.5"
24
24
 
25
25
  gem.add_dependency "mixlib-shellout", ">= 1.2", "< 4.0"
26
26
  gem.add_dependency "net-scp", ">= 1.1", "< 4.0" # pinning until we can confirm 4+ works
@@ -33,6 +33,7 @@ Gem::Specification.new do |gem|
33
33
  gem.add_dependency "winrm", "~> 2.0"
34
34
  gem.add_dependency "winrm-elevated", "~> 1.0"
35
35
  gem.add_dependency "winrm-fs", "~> 1.1"
36
+ gem.add_dependency "chef-utils", ">= 16.4.35"
36
37
  # Required to run the Chef provisioner local license check for remote systems
37
38
  # TK is not under Chef EULA
38
39
  gem.add_dependency "license-acceptance", ">= 1.0.11", "< 3.0" # pinning until we can confirm 3+ works
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: 2.10.0
4
+ version: 2.11.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: 2021-01-17 00:00:00.000000000 Z
11
+ date: 2021-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -194,6 +194,20 @@ dependencies:
194
194
  - - "~>"
195
195
  - !ruby/object:Gem::Version
196
196
  version: '1.1'
197
+ - !ruby/object:Gem::Dependency
198
+ name: chef-utils
199
+ requirement: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: 16.4.35
204
+ type: :runtime
205
+ prerelease: false
206
+ version_requirements: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: 16.4.35
197
211
  - !ruby/object:Gem::Dependency
198
212
  name: license-acceptance
199
213
  requirement: !ruby/object:Gem::Requirement
@@ -387,6 +401,7 @@ files:
387
401
  - bin/kitchen
388
402
  - lib/kitchen.rb
389
403
  - lib/kitchen/base64_stream.rb
404
+ - lib/kitchen/chef_utils_wiring.rb
390
405
  - lib/kitchen/cli.rb
391
406
  - lib/kitchen/collection.rb
392
407
  - lib/kitchen/color.rb
@@ -457,6 +472,7 @@ files:
457
472
  - lib/kitchen/verifier/dummy.rb
458
473
  - lib/kitchen/verifier/shell.rb
459
474
  - lib/kitchen/version.rb
475
+ - lib/kitchen/which.rb
460
476
  - lib/vendor/hash_recursive_merge.rb
461
477
  - support/busser_install_command.ps1
462
478
  - support/busser_install_command.sh
@@ -496,7 +512,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
496
512
  requirements:
497
513
  - - ">="
498
514
  - !ruby/object:Gem::Version
499
- version: '2.4'
515
+ version: '2.5'
500
516
  required_rubygems_version: !ruby/object:Gem::Requirement
501
517
  requirements:
502
518
  - - ">="