test-kitchen 2.12.0 → 3.0.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 +4 -4
- data/Gemfile +1 -1
- data/Rakefile +1 -1
- data/lib/kitchen/configurable.rb +1 -1
- data/lib/kitchen/data_munger.rb +2 -0
- data/lib/kitchen/provisioner.rb +3 -1
- data/lib/kitchen/provisioner/chef/common_sandbox.rb +15 -10
- data/lib/kitchen/provisioner/chef/policyfile.rb +14 -4
- data/lib/kitchen/provisioner/chef_base.rb +3 -2
- data/lib/kitchen/provisioner/chef_infra.rb +167 -0
- data/lib/kitchen/provisioner/chef_zero.rb +3 -158
- data/lib/kitchen/version.rb +1 -1
- data/test-kitchen.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cff7935683511121e07b20e636078776ae80c20fc007b5b08a922ce76e0ce94
|
4
|
+
data.tar.gz: 8207e168e7faf42b8239438753c58f2a9a37fc4f4f2dcd9728948f67b4a5afb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46356119baf46a5ec115cc036c81778e8f17ac2dca6a21733d7bb4ef8779d7d23724ef295cd1f0557083abe577578ff28eec2bb5d9a4596359d8c5c34ea0379b
|
7
|
+
data.tar.gz: 7770f0e415279795ecf2106a6005f7b1514bd692be9a5839d24e992ad4e03dcbbe33dd86892904b1dd87a73473a3484d3f44518f7b87211d1c340c3f94abd6a3
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ begin
|
|
11
11
|
require "cucumber"
|
12
12
|
require "cucumber/rake/task"
|
13
13
|
Cucumber::Rake::Task.new(:features) do |t|
|
14
|
-
t.cucumber_opts = ["features", "-x", "--format progress", "--no-color", "--tags
|
14
|
+
t.cucumber_opts = ["features", "-x", "--format progress", "--no-color", "--tags 'not @ignore'"]
|
15
15
|
end
|
16
16
|
rescue LoadError
|
17
17
|
puts "cucumber is not available. (sudo) gem install cucumber to run tests."
|
data/lib/kitchen/configurable.rb
CHANGED
@@ -149,7 +149,7 @@ module Kitchen
|
|
149
149
|
# @return [String] joined path for instance's os_type
|
150
150
|
def remote_path_join(*parts)
|
151
151
|
path = File.join(*parts)
|
152
|
-
windows_os? ? path.tr("/",
|
152
|
+
windows_os? ? path.tr("/", "\\") : path.tr("\\", "/")
|
153
153
|
end
|
154
154
|
|
155
155
|
# @return [TrueClass,FalseClass] true if `:os_type` is `"unix"` (or
|
data/lib/kitchen/data_munger.rb
CHANGED
@@ -720,12 +720,14 @@ module Kitchen
|
|
720
720
|
move_data_to!(:provisioner, suite, :attributes)
|
721
721
|
move_data_to!(:provisioner, suite, :run_list)
|
722
722
|
move_data_to!(:provisioner, suite, :named_run_list)
|
723
|
+
move_data_to!(:provisioner, suite, :policy_group)
|
723
724
|
end
|
724
725
|
|
725
726
|
data.fetch(:platforms, []).each do |platform|
|
726
727
|
move_data_to!(:provisioner, platform, :attributes)
|
727
728
|
move_data_to!(:provisioner, platform, :run_list)
|
728
729
|
move_data_to!(:provisioner, platform, :named_run_list)
|
730
|
+
move_data_to!(:provisioner, platform, :policy_group)
|
729
731
|
end
|
730
732
|
end
|
731
733
|
|
data/lib/kitchen/provisioner.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
3
3
|
#
|
4
4
|
# Copyright (C) 2013, Fletcher Nichol
|
5
|
+
# Copyright (C) Chef Software Inc.
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
8
|
# you may not use this file except in compliance with the License.
|
@@ -25,7 +26,7 @@ module Kitchen
|
|
25
26
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
26
27
|
module Provisioner
|
27
28
|
# Default provisioner to use
|
28
|
-
DEFAULT_PLUGIN = "
|
29
|
+
DEFAULT_PLUGIN = "chef_infra".freeze
|
29
30
|
|
30
31
|
# Returns an instance of a provisioner given a plugin type string.
|
31
32
|
#
|
@@ -34,6 +35,7 @@ module Kitchen
|
|
34
35
|
# @return [Provisioner::Base] a provisioner instance
|
35
36
|
# @raise [ClientError] if a provisioner instance could not be created
|
36
37
|
def self.for_plugin(plugin, config)
|
38
|
+
plugin, config[:name] = "chef_infra", "chef_infra" if plugin == "chef_zero"
|
37
39
|
Kitchen::Plugin.load(self, plugin, config)
|
38
40
|
end
|
39
41
|
end
|
@@ -73,6 +73,10 @@ module Kitchen
|
|
73
73
|
# @api private
|
74
74
|
attr_reader :sandbox_path
|
75
75
|
|
76
|
+
# @return [String] name of the policy_group, nil results in "local"
|
77
|
+
# @api private
|
78
|
+
attr_reader :policy_group
|
79
|
+
|
76
80
|
# Generates a list of all files in the cookbooks directory in the
|
77
81
|
# sandbox path.
|
78
82
|
#
|
@@ -281,19 +285,17 @@ module Kitchen
|
|
281
285
|
end
|
282
286
|
|
283
287
|
def update_dna_for_policyfile
|
284
|
-
|
285
|
-
|
286
|
-
"kitchen config. The run_list in your config will be ignored.")
|
287
|
-
warn("Ignored run_list: #{config[:run_list].inspect}")
|
288
|
-
end
|
289
|
-
policy = Chef::Policyfile.new(policyfile, sandbox_path,
|
288
|
+
policy = Chef::Policyfile.new(
|
289
|
+
policyfile, sandbox_path,
|
290
290
|
logger: logger,
|
291
|
-
always_update: config[:always_update_cookbooks]
|
291
|
+
always_update: config[:always_update_cookbooks],
|
292
|
+
policy_group: policy_group
|
293
|
+
)
|
292
294
|
Kitchen.mutex.synchronize do
|
293
295
|
policy.compile
|
294
296
|
end
|
295
297
|
policy_name = JSON.parse(IO.read(policy.lockfile))["name"]
|
296
|
-
policy_group = "local"
|
298
|
+
policy_group = config[:policy_group] || "local"
|
297
299
|
config[:attributes].merge(policy_name: policy_name, policy_group: policy_group)
|
298
300
|
end
|
299
301
|
|
@@ -302,9 +304,12 @@ module Kitchen
|
|
302
304
|
# @api private
|
303
305
|
def resolve_with_policyfile
|
304
306
|
Kitchen.mutex.synchronize do
|
305
|
-
Chef::Policyfile.new(
|
307
|
+
Chef::Policyfile.new(
|
308
|
+
policyfile, sandbox_path,
|
306
309
|
logger: logger,
|
307
|
-
always_update: config[:always_update_cookbooks]
|
310
|
+
always_update: config[:always_update_cookbooks],
|
311
|
+
policy_group: config[:policy_group]
|
312
|
+
).resolve
|
308
313
|
end
|
309
314
|
end
|
310
315
|
|
@@ -41,11 +41,12 @@ module Kitchen
|
|
41
41
|
# cookbooks
|
42
42
|
# @param logger [Kitchen::Logger] a logger to use for output, defaults
|
43
43
|
# to `Kitchen.logger`
|
44
|
-
def initialize(policyfile, path, logger: Kitchen.logger, always_update: false)
|
44
|
+
def initialize(policyfile, path, logger: Kitchen.logger, always_update: false, policy_group: nil)
|
45
45
|
@policyfile = policyfile
|
46
46
|
@path = path
|
47
47
|
@logger = logger
|
48
48
|
@always_update = always_update
|
49
|
+
@policy_group = policy_group
|
49
50
|
end
|
50
51
|
|
51
52
|
# Loads the library code required to use the resolver.
|
@@ -59,8 +60,13 @@ module Kitchen
|
|
59
60
|
# Performs the cookbook resolution and vendors the resulting cookbooks
|
60
61
|
# in the desired path.
|
61
62
|
def resolve
|
62
|
-
|
63
|
-
|
63
|
+
if policy_group
|
64
|
+
info("Exporting cookbook dependencies from Policyfile #{path} with policy_group #{policy_group} using `#{cli_path} export`...")
|
65
|
+
run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --policy_group #{policy_group} --force")
|
66
|
+
else
|
67
|
+
info("Exporting cookbook dependencies from Policyfile #{path} using `#{cli_path} export`...")
|
68
|
+
run_command("#{cli_path} export #{escape_path(policyfile)} #{escape_path(path)} --force")
|
69
|
+
end
|
64
70
|
end
|
65
71
|
|
66
72
|
# Runs `chef install` to determine the correct cookbook set and
|
@@ -104,6 +110,10 @@ module Kitchen
|
|
104
110
|
# @api private
|
105
111
|
attr_reader :always_update
|
106
112
|
|
113
|
+
# @return [String] name of the policy_group, nil results in "local"
|
114
|
+
# @api private
|
115
|
+
attr_reader :policy_group
|
116
|
+
|
107
117
|
# Escape spaces in a path in way that works with both Sh (Unix) and
|
108
118
|
# Windows.
|
109
119
|
#
|
@@ -118,7 +128,7 @@ module Kitchen
|
|
118
128
|
# Windows command line parsing libraries. This covers the 99% case of
|
119
129
|
# spaces in the path without breaking other stuff.
|
120
130
|
if /[ \t\n\v"]/.match?(path)
|
121
|
-
"\"#{path.gsub(/[ \t\n\v\"\\]/) { |m|
|
131
|
+
"\"#{path.gsub(/[ \t\n\v\"\\]/) { |m| "\\" + m[0] }}\""
|
122
132
|
else
|
123
133
|
path
|
124
134
|
end
|
@@ -46,6 +46,7 @@ module Kitchen
|
|
46
46
|
default_config :chef_omnibus_install_options, nil
|
47
47
|
default_config :chef_license, nil
|
48
48
|
default_config :run_list, []
|
49
|
+
default_config :policy_group, nil
|
49
50
|
default_config :attributes, {}
|
50
51
|
default_config :config_path, nil
|
51
52
|
default_config :log_file, nil
|
@@ -63,7 +64,7 @@ module Kitchen
|
|
63
64
|
default_config :berksfile_path, nil
|
64
65
|
# If set to true (which is the default from `chef generate`), try to update
|
65
66
|
# backend cookbook downloader on every kitchen run.
|
66
|
-
default_config :always_update_cookbooks,
|
67
|
+
default_config :always_update_cookbooks, true
|
67
68
|
default_config :cookbook_files_glob, %w(
|
68
69
|
README.* VERSION metadata.{json,rb} attributes.rb recipe.rb
|
69
70
|
attributes/**/* definitions/**/* files/**/* libraries/**/*
|
@@ -441,7 +442,7 @@ module Kitchen
|
|
441
442
|
if obj.is_a?(String) && obj =~ /^:/
|
442
443
|
obj
|
443
444
|
elsif obj.is_a?(String)
|
444
|
-
%{"#{obj.gsub(/\\/,
|
445
|
+
%{"#{obj.gsub(/\\/, "\\\\\\\\")}"}
|
445
446
|
elsif obj.is_a?(Array)
|
446
447
|
%{[#{obj.map { |i| format_value(i) }.join(", ")}]}
|
447
448
|
else
|
@@ -0,0 +1,167 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
3
|
+
#
|
4
|
+
# Copyright (C) 2013, Fletcher Nichol
|
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_base"
|
19
|
+
|
20
|
+
module Kitchen
|
21
|
+
module Provisioner
|
22
|
+
# Chef Zero provisioner.
|
23
|
+
#
|
24
|
+
# @author Fletcher Nichol <fnichol@nichol.ca>
|
25
|
+
class ChefInfra < ChefBase
|
26
|
+
kitchen_provisioner_api_version 2
|
27
|
+
|
28
|
+
plugin_version Kitchen::VERSION
|
29
|
+
|
30
|
+
default_config :client_rb, {}
|
31
|
+
default_config :named_run_list, {}
|
32
|
+
default_config :json_attributes, true
|
33
|
+
default_config :chef_zero_host, nil
|
34
|
+
default_config :chef_zero_port, 8889
|
35
|
+
|
36
|
+
default_config :chef_client_path do |provisioner|
|
37
|
+
provisioner
|
38
|
+
.remote_path_join(%W{#{provisioner[:chef_omnibus_root]} bin chef-client})
|
39
|
+
.tap { |path| path.concat(".bat") if provisioner.windows_os? }
|
40
|
+
end
|
41
|
+
|
42
|
+
default_config :ruby_bindir do |provisioner|
|
43
|
+
provisioner
|
44
|
+
.remote_path_join(%W{#{provisioner[:chef_omnibus_root]} embedded bin})
|
45
|
+
end
|
46
|
+
|
47
|
+
# (see Base#create_sandbox)
|
48
|
+
def create_sandbox
|
49
|
+
super
|
50
|
+
prepare_validation_pem
|
51
|
+
prepare_config_rb
|
52
|
+
end
|
53
|
+
|
54
|
+
def run_command
|
55
|
+
cmd = "#{sudo(config[:chef_client_path])} --local-mode".tap { |str| str.insert(0, "& ") if powershell_shell? }
|
56
|
+
|
57
|
+
chef_cmd(cmd)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
# Adds optional flags to a chef-client command, depending on
|
63
|
+
# configuration data. Note that this method mutates the incoming Array.
|
64
|
+
#
|
65
|
+
# @param args [Array<String>] array of flags
|
66
|
+
# @api private
|
67
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
68
|
+
def add_optional_chef_client_args!(args)
|
69
|
+
if config[:json_attributes]
|
70
|
+
json = remote_path_join(config[:root_path], "dna.json")
|
71
|
+
args << "--json-attributes #{json}"
|
72
|
+
end
|
73
|
+
|
74
|
+
args << "--logfile #{config[:log_file]}" if config[:log_file]
|
75
|
+
|
76
|
+
# these flags are chef-client local mode only and will not work
|
77
|
+
# on older versions of chef-client
|
78
|
+
if config[:chef_zero_host]
|
79
|
+
args << "--chef-zero-host #{config[:chef_zero_host]}"
|
80
|
+
end
|
81
|
+
|
82
|
+
if config[:chef_zero_port]
|
83
|
+
args << "--chef-zero-port #{config[:chef_zero_port]}"
|
84
|
+
end
|
85
|
+
|
86
|
+
args << "--profile-ruby" if config[:profile_ruby]
|
87
|
+
|
88
|
+
if config[:slow_resource_report]
|
89
|
+
if config[:slow_resource_report].is_a?(Integer)
|
90
|
+
args << "--slow-report #{config[:slow_resource_report]}"
|
91
|
+
else
|
92
|
+
args << "--slow-report"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
97
|
+
|
98
|
+
# Returns an Array of command line arguments for the chef client.
|
99
|
+
#
|
100
|
+
# @return [Array<String>] an array of command line arguments
|
101
|
+
# @api private
|
102
|
+
def chef_args(client_rb_filename)
|
103
|
+
level = config[:log_level]
|
104
|
+
args = [
|
105
|
+
"--config #{remote_path_join(config[:root_path], client_rb_filename)}",
|
106
|
+
"--log_level #{level}",
|
107
|
+
"--force-formatter",
|
108
|
+
"--no-color",
|
109
|
+
]
|
110
|
+
add_optional_chef_client_args!(args)
|
111
|
+
|
112
|
+
args
|
113
|
+
end
|
114
|
+
|
115
|
+
# Generates a string of shell environment variables needed for the
|
116
|
+
# chef-client-zero.rb shim script to properly function.
|
117
|
+
#
|
118
|
+
# @return [String] a shell script string
|
119
|
+
# @api private
|
120
|
+
def chef_client_zero_env
|
121
|
+
root = config[:root_path]
|
122
|
+
gem_home = gem_path = remote_path_join(root, "chef-client-zero-gems")
|
123
|
+
gem_cache = remote_path_join(gem_home, "cache")
|
124
|
+
|
125
|
+
[
|
126
|
+
shell_env_var("CHEF_REPO_PATH", root),
|
127
|
+
shell_env_var("GEM_HOME", gem_home),
|
128
|
+
shell_env_var("GEM_PATH", gem_path),
|
129
|
+
shell_env_var("GEM_CACHE", gem_cache),
|
130
|
+
].join("\n").concat("\n")
|
131
|
+
end
|
132
|
+
|
133
|
+
# Writes a fake (but valid) validation.pem into the sandbox directory.
|
134
|
+
#
|
135
|
+
# @api private
|
136
|
+
def prepare_validation_pem
|
137
|
+
info("Preparing validation.pem")
|
138
|
+
debug("Using a dummy validation.pem")
|
139
|
+
|
140
|
+
source = File.join(File.dirname(__FILE__),
|
141
|
+
%w{.. .. .. support dummy-validation.pem})
|
142
|
+
FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns the command that will run a backwards compatible shim script
|
146
|
+
# that approximates local mode in a modern chef-client run.
|
147
|
+
#
|
148
|
+
# @return [String] the command string
|
149
|
+
# @api private
|
150
|
+
def shim_command
|
151
|
+
ruby = remote_path_join(config[:ruby_bindir], "ruby")
|
152
|
+
.tap { |path| path.concat(".exe") if windows_os? }
|
153
|
+
shim = remote_path_join(config[:root_path], "chef-client-zero.rb")
|
154
|
+
|
155
|
+
"#{chef_client_zero_env}\n#{sudo(ruby)} #{shim}"
|
156
|
+
end
|
157
|
+
|
158
|
+
# This provisioner supports policyfiles, so override the default (which
|
159
|
+
# is false)
|
160
|
+
# @return [true] always returns true
|
161
|
+
# @api private
|
162
|
+
def supports_policyfile?
|
163
|
+
true
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -1,167 +1,12 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (C) 2013, Fletcher Nichol
|
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_base"
|
1
|
+
# Deprecated AS PER THE PR - https://github.com/test-kitchen/test-kitchen/pull/1730
|
2
|
+
require_relative "chef_infra"
|
19
3
|
|
20
4
|
module Kitchen
|
21
5
|
module Provisioner
|
22
6
|
# Chef Zero provisioner.
|
23
7
|
#
|
24
8
|
# @author Fletcher Nichol <fnichol@nichol.ca>
|
25
|
-
class ChefZero <
|
26
|
-
kitchen_provisioner_api_version 2
|
27
|
-
|
28
|
-
plugin_version Kitchen::VERSION
|
29
|
-
|
30
|
-
default_config :client_rb, {}
|
31
|
-
default_config :named_run_list, {}
|
32
|
-
default_config :json_attributes, true
|
33
|
-
default_config :chef_zero_host, nil
|
34
|
-
default_config :chef_zero_port, 8889
|
35
|
-
|
36
|
-
default_config :chef_client_path do |provisioner|
|
37
|
-
provisioner
|
38
|
-
.remote_path_join(%W{#{provisioner[:chef_omnibus_root]} bin chef-client})
|
39
|
-
.tap { |path| path.concat(".bat") if provisioner.windows_os? }
|
40
|
-
end
|
41
|
-
|
42
|
-
default_config :ruby_bindir do |provisioner|
|
43
|
-
provisioner
|
44
|
-
.remote_path_join(%W{#{provisioner[:chef_omnibus_root]} embedded bin})
|
45
|
-
end
|
46
|
-
|
47
|
-
# (see Base#create_sandbox)
|
48
|
-
def create_sandbox
|
49
|
-
super
|
50
|
-
prepare_validation_pem
|
51
|
-
prepare_config_rb
|
52
|
-
end
|
53
|
-
|
54
|
-
def run_command
|
55
|
-
cmd = "#{sudo(config[:chef_client_path])} --local-mode".tap { |str| str.insert(0, "& ") if powershell_shell? }
|
56
|
-
|
57
|
-
chef_cmd(cmd)
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
# Adds optional flags to a chef-client command, depending on
|
63
|
-
# configuration data. Note that this method mutates the incoming Array.
|
64
|
-
#
|
65
|
-
# @param args [Array<String>] array of flags
|
66
|
-
# @api private
|
67
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
68
|
-
def add_optional_chef_client_args!(args)
|
69
|
-
if config[:json_attributes]
|
70
|
-
json = remote_path_join(config[:root_path], "dna.json")
|
71
|
-
args << "--json-attributes #{json}"
|
72
|
-
end
|
73
|
-
|
74
|
-
args << "--logfile #{config[:log_file]}" if config[:log_file]
|
75
|
-
|
76
|
-
# these flags are chef-client local mode only and will not work
|
77
|
-
# on older versions of chef-client
|
78
|
-
if config[:chef_zero_host]
|
79
|
-
args << "--chef-zero-host #{config[:chef_zero_host]}"
|
80
|
-
end
|
81
|
-
|
82
|
-
if config[:chef_zero_port]
|
83
|
-
args << "--chef-zero-port #{config[:chef_zero_port]}"
|
84
|
-
end
|
85
|
-
|
86
|
-
args << "--profile-ruby" if config[:profile_ruby]
|
87
|
-
|
88
|
-
if config[:slow_resource_report]
|
89
|
-
if config[:slow_resource_report].is_a?(Integer)
|
90
|
-
args << "--slow-report #{config[:slow_resource_report]}"
|
91
|
-
else
|
92
|
-
args << "--slow-report"
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
97
|
-
|
98
|
-
# Returns an Array of command line arguments for the chef client.
|
99
|
-
#
|
100
|
-
# @return [Array<String>] an array of command line arguments
|
101
|
-
# @api private
|
102
|
-
def chef_args(client_rb_filename)
|
103
|
-
level = config[:log_level]
|
104
|
-
args = [
|
105
|
-
"--config #{remote_path_join(config[:root_path], client_rb_filename)}",
|
106
|
-
"--log_level #{level}",
|
107
|
-
"--force-formatter",
|
108
|
-
"--no-color",
|
109
|
-
]
|
110
|
-
add_optional_chef_client_args!(args)
|
111
|
-
|
112
|
-
args
|
113
|
-
end
|
114
|
-
|
115
|
-
# Generates a string of shell environment variables needed for the
|
116
|
-
# chef-client-zero.rb shim script to properly function.
|
117
|
-
#
|
118
|
-
# @return [String] a shell script string
|
119
|
-
# @api private
|
120
|
-
def chef_client_zero_env
|
121
|
-
root = config[:root_path]
|
122
|
-
gem_home = gem_path = remote_path_join(root, "chef-client-zero-gems")
|
123
|
-
gem_cache = remote_path_join(gem_home, "cache")
|
124
|
-
|
125
|
-
[
|
126
|
-
shell_env_var("CHEF_REPO_PATH", root),
|
127
|
-
shell_env_var("GEM_HOME", gem_home),
|
128
|
-
shell_env_var("GEM_PATH", gem_path),
|
129
|
-
shell_env_var("GEM_CACHE", gem_cache),
|
130
|
-
].join("\n").concat("\n")
|
131
|
-
end
|
132
|
-
|
133
|
-
# Writes a fake (but valid) validation.pem into the sandbox directory.
|
134
|
-
#
|
135
|
-
# @api private
|
136
|
-
def prepare_validation_pem
|
137
|
-
info("Preparing validation.pem")
|
138
|
-
debug("Using a dummy validation.pem")
|
139
|
-
|
140
|
-
source = File.join(File.dirname(__FILE__),
|
141
|
-
%w{.. .. .. support dummy-validation.pem})
|
142
|
-
FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
|
143
|
-
end
|
144
|
-
|
145
|
-
# Returns the command that will run a backwards compatible shim script
|
146
|
-
# that approximates local mode in a modern chef-client run.
|
147
|
-
#
|
148
|
-
# @return [String] the command string
|
149
|
-
# @api private
|
150
|
-
def shim_command
|
151
|
-
ruby = remote_path_join(config[:ruby_bindir], "ruby")
|
152
|
-
.tap { |path| path.concat(".exe") if windows_os? }
|
153
|
-
shim = remote_path_join(config[:root_path], "chef-client-zero.rb")
|
154
|
-
|
155
|
-
"#{chef_client_zero_env}\n#{sudo(ruby)} #{shim}"
|
156
|
-
end
|
157
|
-
|
158
|
-
# This provisioner supports policyfiles, so override the default (which
|
159
|
-
# is false)
|
160
|
-
# @return [true] always returns true
|
161
|
-
# @api private
|
162
|
-
def supports_policyfile?
|
163
|
-
true
|
164
|
-
end
|
9
|
+
class ChefZero < ChefInfra
|
165
10
|
end
|
166
11
|
end
|
167
12
|
end
|
data/lib/kitchen/version.rb
CHANGED
data/test-kitchen.gemspec
CHANGED
@@ -44,7 +44,7 @@ Gem::Specification.new do |gem|
|
|
44
44
|
|
45
45
|
gem.add_development_dependency "aruba", "~> 0.11", "< 1.0"
|
46
46
|
gem.add_development_dependency "fakefs", "~> 1.0"
|
47
|
-
gem.add_development_dependency "minitest", "~> 5.3", "< 5.
|
47
|
+
gem.add_development_dependency "minitest", "~> 5.3", "< 5.15"
|
48
48
|
gem.add_development_dependency "mocha", "~> 1.1"
|
49
49
|
gem.add_development_dependency "cucumber", ">= 2.1", "< 4.0" # we just need to validate 4.0 when it comes out
|
50
50
|
gem.add_development_dependency "countloc", "~> 0.4"
|
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:
|
4
|
+
version: 3.0.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-
|
11
|
+
date: 2021-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -313,7 +313,7 @@ dependencies:
|
|
313
313
|
version: '5.3'
|
314
314
|
- - "<"
|
315
315
|
- !ruby/object:Gem::Version
|
316
|
-
version: '5.
|
316
|
+
version: '5.15'
|
317
317
|
type: :development
|
318
318
|
prerelease: false
|
319
319
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -323,7 +323,7 @@ dependencies:
|
|
323
323
|
version: '5.3'
|
324
324
|
- - "<"
|
325
325
|
- !ruby/object:Gem::Version
|
326
|
-
version: '5.
|
326
|
+
version: '5.15'
|
327
327
|
- !ruby/object:Gem::Dependency
|
328
328
|
name: mocha
|
329
329
|
requirement: !ruby/object:Gem::Requirement
|
@@ -449,6 +449,7 @@ files:
|
|
449
449
|
- lib/kitchen/provisioner/chef/policyfile.rb
|
450
450
|
- lib/kitchen/provisioner/chef_apply.rb
|
451
451
|
- lib/kitchen/provisioner/chef_base.rb
|
452
|
+
- lib/kitchen/provisioner/chef_infra.rb
|
452
453
|
- lib/kitchen/provisioner/chef_solo.rb
|
453
454
|
- lib/kitchen/provisioner/chef_zero.rb
|
454
455
|
- lib/kitchen/provisioner/dummy.rb
|