test-kitchen 1.14.1 → 1.14.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +1 -1
  3. data/CHANGELOG.md +7 -0
  4. data/Gemfile +1 -1
  5. data/Guardfile +5 -5
  6. data/Rakefile +5 -5
  7. data/bin/kitchen +1 -1
  8. data/features/step_definitions/gem_steps.rb +6 -6
  9. data/features/support/env.rb +6 -7
  10. data/lib/kitchen.rb +5 -7
  11. data/lib/kitchen/base64_stream.rb +2 -8
  12. data/lib/kitchen/cli.rb +76 -80
  13. data/lib/kitchen/collection.rb +0 -2
  14. data/lib/kitchen/color.rb +7 -9
  15. data/lib/kitchen/command.rb +0 -4
  16. data/lib/kitchen/command/action.rb +0 -3
  17. data/lib/kitchen/command/console.rb +4 -7
  18. data/lib/kitchen/command/diagnose.rb +7 -14
  19. data/lib/kitchen/command/driver_discover.rb +1 -4
  20. data/lib/kitchen/command/exec.rb +0 -3
  21. data/lib/kitchen/command/list.rb +9 -12
  22. data/lib/kitchen/command/login.rb +0 -3
  23. data/lib/kitchen/command/package.rb +0 -3
  24. data/lib/kitchen/command/sink.rb +6 -9
  25. data/lib/kitchen/command/test.rb +1 -4
  26. data/lib/kitchen/config.rb +25 -27
  27. data/lib/kitchen/configurable.rb +26 -31
  28. data/lib/kitchen/data_munger.rb +34 -36
  29. data/lib/kitchen/diagnostic.rb +5 -7
  30. data/lib/kitchen/driver.rb +3 -5
  31. data/lib/kitchen/driver/base.rb +0 -3
  32. data/lib/kitchen/driver/dummy.rb +0 -3
  33. data/lib/kitchen/driver/proxy.rb +0 -3
  34. data/lib/kitchen/driver/ssh_base.rb +13 -16
  35. data/lib/kitchen/errors.rb +11 -16
  36. data/lib/kitchen/generator/driver_create.rb +18 -21
  37. data/lib/kitchen/generator/init.rb +21 -26
  38. data/lib/kitchen/instance.rb +19 -23
  39. data/lib/kitchen/lazy_hash.rb +1 -2
  40. data/lib/kitchen/loader/yaml.rb +22 -25
  41. data/lib/kitchen/logger.rb +9 -14
  42. data/lib/kitchen/logging.rb +0 -3
  43. data/lib/kitchen/login_command.rb +0 -2
  44. data/lib/kitchen/metadata_chopper.rb +0 -2
  45. data/lib/kitchen/platform.rb +1 -3
  46. data/lib/kitchen/provisioner.rb +3 -5
  47. data/lib/kitchen/provisioner/base.rb +2 -5
  48. data/lib/kitchen/provisioner/chef/berkshelf.rb +1 -5
  49. data/lib/kitchen/provisioner/chef/common_sandbox.rb +24 -29
  50. data/lib/kitchen/provisioner/chef/librarian.rb +2 -6
  51. data/lib/kitchen/provisioner/chef/policyfile.rb +4 -8
  52. data/lib/kitchen/provisioner/chef_apply.rb +14 -17
  53. data/lib/kitchen/provisioner/chef_base.rb +43 -46
  54. data/lib/kitchen/provisioner/chef_solo.rb +10 -13
  55. data/lib/kitchen/provisioner/chef_zero.rb +22 -29
  56. data/lib/kitchen/provisioner/dummy.rb +0 -3
  57. data/lib/kitchen/provisioner/shell.rb +6 -9
  58. data/lib/kitchen/rake_tasks.rb +4 -6
  59. data/lib/kitchen/shell_out.rb +3 -5
  60. data/lib/kitchen/ssh.rb +16 -22
  61. data/lib/kitchen/state_file.rb +3 -5
  62. data/lib/kitchen/suite.rb +0 -2
  63. data/lib/kitchen/thor_tasks.rb +2 -4
  64. data/lib/kitchen/transport.rb +3 -5
  65. data/lib/kitchen/transport/base.rb +1 -7
  66. data/lib/kitchen/transport/dummy.rb +0 -4
  67. data/lib/kitchen/transport/ssh.rb +41 -47
  68. data/lib/kitchen/transport/winrm.rb +41 -40
  69. data/lib/kitchen/util.rb +1 -3
  70. data/lib/kitchen/verifier.rb +3 -5
  71. data/lib/kitchen/verifier/base.rb +2 -5
  72. data/lib/kitchen/verifier/busser.rb +24 -24
  73. data/lib/kitchen/verifier/dummy.rb +0 -3
  74. data/lib/kitchen/verifier/shell.rb +1 -3
  75. data/lib/kitchen/version.rb +1 -1
  76. data/lib/vendor/hash_recursive_merge.rb +0 -2
  77. data/spec/kitchen/base64_stream_spec.rb +3 -6
  78. data/spec/kitchen/cli_spec.rb +0 -2
  79. data/spec/kitchen/collection_spec.rb +4 -8
  80. data/spec/kitchen/color_spec.rb +0 -3
  81. data/spec/kitchen/config_spec.rb +91 -106
  82. data/spec/kitchen/configurable_spec.rb +44 -76
  83. data/spec/kitchen/data_munger_spec.rb +1178 -1247
  84. data/spec/kitchen/diagnostic_spec.rb +37 -38
  85. data/spec/kitchen/driver/base_spec.rb +7 -14
  86. data/spec/kitchen/driver/dummy_spec.rb +1 -7
  87. data/spec/kitchen/driver/proxy_spec.rb +2 -7
  88. data/spec/kitchen/driver/ssh_base_spec.rb +128 -149
  89. data/spec/kitchen/driver_spec.rb +7 -13
  90. data/spec/kitchen/errors_spec.rb +50 -60
  91. data/spec/kitchen/instance_spec.rb +217 -294
  92. data/spec/kitchen/lazy_hash_spec.rb +14 -18
  93. data/spec/kitchen/loader/yaml_spec.rb +201 -227
  94. data/spec/kitchen/logger_spec.rb +7 -15
  95. data/spec/kitchen/logging_spec.rb +1 -4
  96. data/spec/kitchen/login_command_spec.rb +3 -4
  97. data/spec/kitchen/metadata_chopper_spec.rb +0 -3
  98. data/spec/kitchen/platform_spec.rb +31 -32
  99. data/spec/kitchen/provisioner/base_spec.rb +22 -41
  100. data/spec/kitchen/provisioner/chef/policyfile_spec.rb +15 -15
  101. data/spec/kitchen/provisioner/chef_apply_spec.rb +8 -13
  102. data/spec/kitchen/provisioner/chef_base_spec.rb +150 -182
  103. data/spec/kitchen/provisioner/chef_solo_spec.rb +58 -72
  104. data/spec/kitchen/provisioner/chef_zero_spec.rb +99 -125
  105. data/spec/kitchen/provisioner/dummy_spec.rb +8 -11
  106. data/spec/kitchen/provisioner/shell_spec.rb +86 -103
  107. data/spec/kitchen/provisioner_spec.rb +5 -11
  108. data/spec/kitchen/shell_out_spec.rb +15 -19
  109. data/spec/kitchen/ssh_spec.rb +16 -35
  110. data/spec/kitchen/state_file_spec.rb +6 -11
  111. data/spec/kitchen/suite_spec.rb +5 -6
  112. data/spec/kitchen/transport/base_spec.rb +6 -14
  113. data/spec/kitchen/transport/ssh_spec.rb +39 -64
  114. data/spec/kitchen/transport/winrm_spec.rb +99 -127
  115. data/spec/kitchen/transport_spec.rb +7 -13
  116. data/spec/kitchen/util_spec.rb +17 -26
  117. data/spec/kitchen/verifier/base_spec.rb +24 -40
  118. data/spec/kitchen/verifier/busser_spec.rb +38 -68
  119. data/spec/kitchen/verifier/dummy_spec.rb +8 -11
  120. data/spec/kitchen/verifier/shell_spec.rb +14 -17
  121. data/spec/kitchen/verifier_spec.rb +7 -13
  122. data/spec/kitchen_spec.rb +4 -6
  123. data/spec/spec_helper.rb +1 -1
  124. data/spec/support/powershell_max_size_spec.rb +1 -2
  125. data/support/chef-client-zero.rb +3 -4
  126. data/test-kitchen.gemspec +4 -6
  127. metadata +9 -9
@@ -20,17 +20,13 @@ require "kitchen/errors"
20
20
  require "kitchen/logging"
21
21
 
22
22
  module Kitchen
23
-
24
23
  module Provisioner
25
-
26
24
  module Chef
27
-
28
25
  # Chef cookbook resolver that uses Librarian-Chef and a Cheffile to
29
26
  # calculate dependencies.
30
27
  #
31
28
  # @author Fletcher Nichol <fnichol@nichol.ca>
32
29
  class Librarian
33
-
34
30
  include Logging
35
31
 
36
32
  # Creates a new cookbook resolver.
@@ -62,7 +58,7 @@ module Kitchen
62
58
  debug("Using Cheffile from #{cheffile}")
63
59
 
64
60
  env = ::Librarian::Chef::Environment.new(
65
- :project_path => File.dirname(cheffile))
61
+ project_path: File.dirname(cheffile))
66
62
  env.config_db.local["path"] = path
67
63
  ::Librarian::Action::Resolve.new(env).run
68
64
  ::Librarian::Action::Install.new(env).run
@@ -104,7 +100,7 @@ module Kitchen
104
100
  " `gem install librarian-chef` or add the following to your" \
105
101
  " Gemfile if you are using Bundler: `gem 'librarian-chef'`.")
106
102
  raise UserError,
107
- "Could not load or activate Librarian-Chef (#{e.message})"
103
+ "Could not load or activate Librarian-Chef (#{e.message})"
108
104
  end
109
105
  end
110
106
  end
@@ -24,16 +24,12 @@ require "kitchen/logging"
24
24
  require "kitchen/shell_out"
25
25
 
26
26
  module Kitchen
27
-
28
27
  module Provisioner
29
-
30
28
  module Chef
31
-
32
29
  # Chef cookbook resolver that uses Policyfiles to calculate dependencies.
33
30
  #
34
31
  # @author Fletcher Nichol <fnichol@nichol.ca>
35
32
  class Policyfile
36
-
37
33
  include Logging
38
34
  include ShellOut
39
35
 
@@ -113,15 +109,15 @@ module Kitchen
113
109
  # @raise [UserError] if the `chef` command is not in the PATH
114
110
  # @api private
115
111
  def self.detect_chef_command!(logger)
116
- unless ENV["PATH"].split(File::PATH_SEPARATOR).any? { |p|
112
+ unless ENV["PATH"].split(File::PATH_SEPARATOR).any? do |p|
117
113
  File.exist?(File.join(p, "chef"))
118
- }
114
+ end
119
115
  logger.fatal("The `chef` executable cannot be found in your " \
120
116
  "PATH. Ensure you have installed ChefDK from " \
121
117
  "https://downloads.chef.io and that your PATH " \
122
118
  "setting includes the path to the `chef` comand.")
123
119
  raise UserError,
124
- "Could not find the chef executable in your PATH."
120
+ "Could not find the chef executable in your PATH."
125
121
  end
126
122
  end
127
123
 
@@ -139,7 +135,7 @@ module Kitchen
139
135
  # Windows command line parsing libraries. This covers the 99% case of
140
136
  # spaces in the path without breaking other stuff.
141
137
  if path =~ /[ \t\n\v"]/
142
- "\"#{path.gsub(/[ \t\n\v\"\\]/) { |m| "\\" + m[0] }}\""
138
+ "\"#{path.gsub(/[ \t\n\v\"\\]/) { |m| '\\' + m[0] }}\""
143
139
  else
144
140
  path
145
141
  end
@@ -48,22 +48,19 @@
48
48
  require "kitchen/provisioner/chef_base"
49
49
 
50
50
  module Kitchen
51
-
52
51
  module Provisioner
53
-
54
52
  # Chef Apply provisioner.
55
53
  #
56
54
  # @author SAWANOBORI Yukihiko <sawanoboriyu@higanworks.com>)
57
55
  class ChefApply < ChefBase
58
-
59
56
  kitchen_provisioner_api_version 2
60
57
 
61
58
  plugin_version Kitchen::VERSION
62
59
 
63
60
  default_config :chef_apply_path do |provisioner|
64
- provisioner.
65
- remote_path_join(%W[#{provisioner[:chef_omnibus_root]} bin chef-apply]).
66
- tap { |path| path.concat(".bat") if provisioner.windows_os? }
61
+ provisioner
62
+ .remote_path_join(%W{#{provisioner[:chef_omnibus_root]} bin chef-apply})
63
+ .tap { |path| path.concat(".bat") if provisioner.windows_os? }
67
64
  end
68
65
 
69
66
  default_config :apply_path do |provisioner|
@@ -84,15 +81,15 @@ module Kitchen
84
81
 
85
82
  # (see ChefBase#init_command)
86
83
  def init_command
87
- dirs = %w[
84
+ dirs = %w{
88
85
  apply
89
- ].sort.map { |dir| remote_path_join(config[:root_path], dir) }
86
+ }.sort.map { |dir| remote_path_join(config[:root_path], dir) }
90
87
 
91
88
  vars = if powershell_shell?
92
- init_command_vars_for_powershell(dirs)
93
- else
94
- init_command_vars_for_bourne(dirs)
95
- end
89
+ init_command_vars_for_powershell(dirs)
90
+ else
91
+ init_command_vars_for_bourne(dirs)
92
+ end
96
93
 
97
94
  prefix_command(shell_code_from_file(vars, "chef_base_init_command"))
98
95
  end
@@ -102,18 +99,18 @@ module Kitchen
102
99
  level = config[:log_level]
103
100
  lines = []
104
101
  config[:run_list].map do |recipe|
105
- cmd = sudo(config[:chef_apply_path]).dup.
106
- tap { |str| str.insert(0, "& ") if powershell_shell? }
102
+ cmd = sudo(config[:chef_apply_path]).dup
103
+ .tap { |str| str.insert(0, "& ") if powershell_shell? }
107
104
  args = [
108
105
  "apply/#{recipe}.rb",
109
106
  "--log_level #{level}",
110
- "--no-color"
107
+ "--no-color",
111
108
  ]
112
109
  args << "--logfile #{config[:log_file]}" if config[:log_file]
113
110
 
114
111
  lines << wrap_shell_code(
115
- [cmd, *args].join(" ").
116
- tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
112
+ [cmd, *args].join(" ")
113
+ .tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
117
114
  )
118
115
  end
119
116
 
@@ -37,14 +37,11 @@ rescue LoadError # rubocop:disable Lint/HandleExceptions
37
37
  end
38
38
 
39
39
  module Kitchen
40
-
41
40
  module Provisioner
42
-
43
41
  # Common implementation details for Chef-related provisioners.
44
42
  #
45
43
  # @author Fletcher Nichol <fnichol@nichol.ca>
46
44
  class ChefBase < Base
47
-
48
45
  default_config :require_chef_omnibus, true
49
46
  default_config :chef_omnibus_url, "https://omnitruck.chef.io/install.sh"
50
47
  default_config :chef_omnibus_install_options, nil
@@ -62,11 +59,11 @@ module Kitchen
62
59
  # If set to true (which is the default from `chef generate`), try to update
63
60
  # backend cookbook downloader on every kitchen run.
64
61
  default_config :always_update_cookbooks, false
65
- default_config :cookbook_files_glob, %w[
62
+ default_config :cookbook_files_glob, %w(
66
63
  README.* metadata.{json,rb}
67
64
  attributes/**/* definitions/**/* files/**/* libraries/**/*
68
65
  providers/**/* recipes/**/* resources/**/* templates/**/*
69
- ].join(",")
66
+ ).join(",")
70
67
  # to ease upgrades, allow the user to turn deprecation warnings into errors
71
68
  default_config :deprecations_as_errors, false
72
69
 
@@ -101,7 +98,7 @@ module Kitchen
101
98
  expand_path_for :clients_path
102
99
 
103
100
  default_config :encrypted_data_bag_secret_key_path do |provisioner|
104
- provisioner.calculate_path("encrypted_data_bag_secret_key", :type => :file)
101
+ provisioner.calculate_path("encrypted_data_bag_secret_key", type: :file)
105
102
  end
106
103
  expand_path_for :encrypted_data_bag_secret_key_path
107
104
 
@@ -131,16 +128,16 @@ module Kitchen
131
128
 
132
129
  # (see Base#init_command)
133
130
  def init_command
134
- dirs = %w[
131
+ dirs = %w{
135
132
  cookbooks data data_bags environments roles clients
136
133
  encrypted_data_bag_secret
137
- ].sort.map { |dir| remote_path_join(config[:root_path], dir) }
134
+ }.sort.map { |dir| remote_path_join(config[:root_path], dir) }
138
135
 
139
136
  vars = if powershell_shell?
140
- init_command_vars_for_powershell(dirs)
141
- else
142
- init_command_vars_for_bourne(dirs)
143
- end
137
+ init_command_vars_for_powershell(dirs)
138
+ else
139
+ init_command_vars_for_bourne(dirs)
140
+ end
144
141
 
145
142
  prefix_command(shell_code_from_file(vars, "chef_base_init_command"))
146
143
  end
@@ -159,10 +156,10 @@ module Kitchen
159
156
  add_omnibus_directory_option if instance.driver.cache_directory
160
157
  project = /\s*-P (\w+)\s*/.match(config[:chef_omnibus_install_options])
161
158
  {
162
- :omnibus_url => config[:chef_omnibus_url],
163
- :project => project.nil? ? nil : project[1],
164
- :install_flags => config[:chef_omnibus_install_options],
165
- :sudo_command => sudo_command
159
+ omnibus_url: config[:chef_omnibus_url],
160
+ project: project.nil? ? nil : project[1],
161
+ install_flags: config[:chef_omnibus_install_options],
162
+ sudo_command: sudo_command,
166
163
  }.tap do |opts|
167
164
  opts[:root] = config[:chef_omnibus_root] if config.key? :chef_omnibus_root
168
165
  [:install_msi_url, :http_proxy, :https_proxy].each do |key|
@@ -215,27 +212,27 @@ module Kitchen
215
212
  root = config[:root_path].gsub("$env:TEMP", "\#{ENV['TEMP']\}")
216
213
 
217
214
  {
218
- :node_name => instance.name,
219
- :checksum_path => remote_path_join(root, "checksums"),
220
- :file_cache_path => remote_path_join(root, "cache"),
221
- :file_backup_path => remote_path_join(root, "backup"),
222
- :cookbook_path => [
215
+ node_name: instance.name,
216
+ checksum_path: remote_path_join(root, "checksums"),
217
+ file_cache_path: remote_path_join(root, "cache"),
218
+ file_backup_path: remote_path_join(root, "backup"),
219
+ cookbook_path: [
223
220
  remote_path_join(root, "cookbooks"),
224
- remote_path_join(root, "site-cookbooks")
221
+ remote_path_join(root, "site-cookbooks"),
225
222
  ],
226
- :data_bag_path => remote_path_join(root, "data_bags"),
227
- :environment_path => remote_path_join(root, "environments"),
228
- :node_path => remote_path_join(root, "nodes"),
229
- :role_path => remote_path_join(root, "roles"),
230
- :client_path => remote_path_join(root, "clients"),
231
- :user_path => remote_path_join(root, "users"),
232
- :validation_key => remote_path_join(root, "validation.pem"),
233
- :client_key => remote_path_join(root, "client.pem"),
234
- :chef_server_url => "http://127.0.0.1:8889",
235
- :encrypted_data_bag_secret => remote_path_join(
223
+ data_bag_path: remote_path_join(root, "data_bags"),
224
+ environment_path: remote_path_join(root, "environments"),
225
+ node_path: remote_path_join(root, "nodes"),
226
+ role_path: remote_path_join(root, "roles"),
227
+ client_path: remote_path_join(root, "clients"),
228
+ user_path: remote_path_join(root, "users"),
229
+ validation_key: remote_path_join(root, "validation.pem"),
230
+ client_key: remote_path_join(root, "client.pem"),
231
+ chef_server_url: "http://127.0.0.1:8889",
232
+ encrypted_data_bag_secret: remote_path_join(
236
233
  root, "encrypted_data_bag_secret"
237
234
  ),
238
- :treat_deprecation_warnings_as_errors => config[:deprecations_as_errors]
235
+ treat_deprecation_warnings_as_errors: config[:deprecations_as_errors],
239
236
  }
240
237
  end
241
238
 
@@ -246,9 +243,9 @@ module Kitchen
246
243
  # @return [String] a rendered Chef config file as a String
247
244
  # @api private
248
245
  def format_config_file(data)
249
- data.each.map { |attr, value|
246
+ data.each.map do |attr, value|
250
247
  [attr, format_value(value)].join(" ")
251
- }.join("\n")
248
+ end.join("\n")
252
249
  end
253
250
 
254
251
  # Converts a Ruby object to a String interpretation suitable for writing
@@ -261,9 +258,9 @@ module Kitchen
261
258
  if obj.is_a?(String) && obj =~ /^:/
262
259
  obj
263
260
  elsif obj.is_a?(String)
264
- %{"#{obj.gsub(/\\/, "\\\\\\\\")}"}
261
+ %{"#{obj.gsub(/\\/, '\\\\\\\\')}"}
265
262
  elsif obj.is_a?(Array)
266
- %{[#{obj.map { |i| format_value(i) }.join(", ")}]}
263
+ %{[#{obj.map { |i| format_value(i) }.join(', ')}]}
267
264
  else
268
265
  obj.inspect
269
266
  end
@@ -278,7 +275,7 @@ module Kitchen
278
275
  [
279
276
  shell_var("sudo_rm", sudo("rm")),
280
277
  shell_var("dirs", dirs.join(" ")),
281
- shell_var("root_path", config[:root_path])
278
+ shell_var("root_path", config[:root_path]),
282
279
  ].join("\n")
283
280
  end
284
281
 
@@ -289,8 +286,8 @@ module Kitchen
289
286
  # @api private
290
287
  def init_command_vars_for_powershell(dirs)
291
288
  [
292
- %{$dirs = @(#{dirs.map { |d| %{"#{d}"} }.join(", ")})},
293
- shell_var("root_path", config[:root_path])
289
+ %{$dirs = @(#{dirs.map { |d| %{"#{d}"} }.join(', ')})},
290
+ shell_var("root_path", config[:root_path]),
294
291
  ].join("\n")
295
292
  end
296
293
 
@@ -301,13 +298,13 @@ module Kitchen
301
298
  super
302
299
  if File.exist?(policyfile)
303
300
  debug("Policyfile found at #{policyfile}, using Policyfile to resolve dependencies")
304
- Chef::Policyfile.load!(:logger => logger)
301
+ Chef::Policyfile.load!(logger: logger)
305
302
  elsif File.exist?(berksfile)
306
303
  debug("Berksfile found at #{berksfile}, loading Berkshelf")
307
- Chef::Berkshelf.load!(:logger => logger)
304
+ Chef::Berkshelf.load!(logger: logger)
308
305
  elsif File.exist?(cheffile)
309
306
  debug("Cheffile found at #{cheffile}, loading Librarian-Chef")
310
- Chef::Librarian.load!(:logger => logger)
307
+ Chef::Librarian.load!(logger: logger)
311
308
  end
312
309
  end
313
310
 
@@ -327,9 +324,9 @@ module Kitchen
327
324
  # @api private
328
325
  def script_for_product
329
326
  installer = Mixlib::Install.new({
330
- :product_name => config[:product_name],
331
- :product_version => config[:product_version],
332
- :channel => (config[:channel] || :stable).to_sym
327
+ product_name: config[:product_name],
328
+ product_version: config[:product_version],
329
+ channel: (config[:channel] || :stable).to_sym,
333
330
  }.tap do |opts|
334
331
  opts[:shell_type] = :ps1 if powershell_shell?
335
332
  [:platform, :platform_version, :architecture].each do |key|
@@ -19,14 +19,11 @@
19
19
  require "kitchen/provisioner/chef_base"
20
20
 
21
21
  module Kitchen
22
-
23
22
  module Provisioner
24
-
25
23
  # Chef Solo provisioner.
26
24
  #
27
25
  # @author Fletcher Nichol <fnichol@nichol.ca>
28
26
  class ChefSolo < ChefBase
29
-
30
27
  kitchen_provisioner_api_version 2
31
28
 
32
29
  plugin_version Kitchen::VERSION
@@ -34,9 +31,9 @@ module Kitchen
34
31
  default_config :solo_rb, {}
35
32
 
36
33
  default_config :chef_solo_path do |provisioner|
37
- provisioner.
38
- remote_path_join(%W[#{provisioner[:chef_omnibus_root]} bin chef-solo]).
39
- tap { |path| path.concat(".bat") if provisioner.windows_os? }
34
+ provisioner
35
+ .remote_path_join(%W{#{provisioner[:chef_omnibus_root]} bin chef-solo})
36
+ .tap { |path| path.concat(".bat") if provisioner.windows_os? }
40
37
  end
41
38
 
42
39
  # (see Base#create_sandbox)
@@ -64,13 +61,13 @@ module Kitchen
64
61
  # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize
65
62
  def run_command
66
63
  config[:log_level] = "info" if !modern? && config[:log_level] = "auto"
67
- cmd = sudo(config[:chef_solo_path]).dup.
68
- tap { |str| str.insert(0, "& ") if powershell_shell? }
64
+ cmd = sudo(config[:chef_solo_path]).dup
65
+ .tap { |str| str.insert(0, "& ") if powershell_shell? }
69
66
  args = [
70
- "--config #{remote_path_join(config[:root_path], "solo.rb")}",
67
+ "--config #{remote_path_join(config[:root_path], 'solo.rb')}",
71
68
  "--log_level #{config[:log_level]}",
72
69
  "--no-color",
73
- "--json-attributes #{remote_path_join(config[:root_path], "dna.json")}"
70
+ "--json-attributes #{remote_path_join(config[:root_path], 'dna.json')}",
74
71
  ]
75
72
  args << " --force-formatter" if modern?
76
73
  args << "--logfile #{config[:log_file]}" if config[:log_file]
@@ -79,10 +76,10 @@ module Kitchen
79
76
 
80
77
  prefix_command(
81
78
  wrap_shell_code(
82
- [cmd, *args].join(" ").
83
- tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
79
+ [cmd, *args].join(" ")
80
+ .tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
81
+ )
84
82
  )
85
- )
86
83
  end
87
84
 
88
85
  private
@@ -19,14 +19,11 @@
19
19
  require "kitchen/provisioner/chef_base"
20
20
 
21
21
  module Kitchen
22
-
23
22
  module Provisioner
24
-
25
23
  # Chef Zero provisioner.
26
24
  #
27
25
  # @author Fletcher Nichol <fnichol@nichol.ca>
28
26
  class ChefZero < ChefBase
29
-
30
27
  kitchen_provisioner_api_version 2
31
28
 
32
29
  plugin_version Kitchen::VERSION
@@ -38,14 +35,14 @@ module Kitchen
38
35
  default_config :chef_zero_port, 8889
39
36
 
40
37
  default_config :chef_client_path do |provisioner|
41
- provisioner.
42
- remote_path_join(%W[#{provisioner[:chef_omnibus_root]} bin chef-client]).
43
- tap { |path| path.concat(".bat") if provisioner.windows_os? }
38
+ provisioner
39
+ .remote_path_join(%W{#{provisioner[:chef_omnibus_root]} bin chef-client})
40
+ .tap { |path| path.concat(".bat") if provisioner.windows_os? }
44
41
  end
45
42
 
46
43
  default_config :ruby_bindir do |provisioner|
47
- provisioner.
48
- remote_path_join(%W[#{provisioner[:chef_omnibus_root]} embedded bin])
44
+ provisioner
45
+ .remote_path_join(%W{#{provisioner[:chef_omnibus_root]} embedded bin})
49
46
  end
50
47
 
51
48
  # (see Base#create_sandbox)
@@ -60,11 +57,11 @@ module Kitchen
60
57
  def prepare_command
61
58
  return if modern?
62
59
 
63
- gem_bin = remote_path_join(config[:ruby_bindir], "gem").
64
- tap { |path| path.concat(".bat") if windows_os? }
60
+ gem_bin = remote_path_join(config[:ruby_bindir], "gem")
61
+ .tap { |path| path.concat(".bat") if windows_os? }
65
62
  vars = [
66
63
  chef_client_zero_env,
67
- shell_var("gem", sudo(gem_bin))
64
+ shell_var("gem", sudo(gem_bin)),
68
65
  ].join("\n").concat("\n")
69
66
 
70
67
  prefix_command(shell_code_from_file(vars, "chef_zero_prepare_command_legacy"))
@@ -76,8 +73,8 @@ module Kitchen
76
73
 
77
74
  prefix_command(
78
75
  wrap_shell_code(
79
- [cmd, *chef_client_args, last_exit_code].join(" ").
80
- tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
76
+ [cmd, *chef_client_args, last_exit_code].join(" ")
77
+ .tap { |str| str.insert(0, reload_ps1_path) if windows_os? }
81
78
  )
82
79
  )
83
80
  end
@@ -99,9 +96,7 @@ module Kitchen
99
96
  json = remote_path_join(config[:root_path], "dna.json")
100
97
  args << "--json-attributes #{json}"
101
98
  end
102
- if config[:log_file]
103
- args << "--logfile #{config[:log_file]}"
104
- end
99
+ args << "--logfile #{config[:log_file]}" if config[:log_file]
105
100
  return unless modern?
106
101
 
107
102
  # these flags are modern/chef-client local most only and will not work
@@ -112,9 +107,7 @@ module Kitchen
112
107
  if config[:chef_zero_port]
113
108
  args << "--chef-zero-port #{config[:chef_zero_port]}"
114
109
  end
115
- if config[:profile_ruby]
116
- args << "--profile-ruby"
117
- end
110
+ args << "--profile-ruby" if config[:profile_ruby]
118
111
  end
119
112
  # rubocop:enable Metrics/CyclomaticComplexity
120
113
 
@@ -125,10 +118,10 @@ module Kitchen
125
118
  def chef_client_args
126
119
  level = config[:log_level]
127
120
  args = [
128
- "--config #{remote_path_join(config[:root_path], "client.rb")}",
121
+ "--config #{remote_path_join(config[:root_path], 'client.rb')}",
129
122
  "--log_level #{level}",
130
123
  "--force-formatter",
131
- "--no-color"
124
+ "--no-color",
132
125
  ]
133
126
  add_optional_chef_client_args!(args)
134
127
 
@@ -149,7 +142,7 @@ module Kitchen
149
142
  shell_env_var("CHEF_REPO_PATH", root),
150
143
  shell_env_var("GEM_HOME", gem_home),
151
144
  shell_env_var("GEM_PATH", gem_path),
152
- shell_env_var("GEM_CACHE", gem_cache)
145
+ shell_env_var("GEM_CACHE", gem_cache),
153
146
  ].join("\n").concat("\n")
154
147
  end
155
148
 
@@ -159,8 +152,8 @@ module Kitchen
159
152
  # @return [String] the command string
160
153
  # @api private
161
154
  def local_mode_command
162
- "#{sudo(config[:chef_client_path])} --local-mode".
163
- tap { |str| str.insert(0, "& ") if powershell_shell? }
155
+ "#{sudo(config[:chef_client_path])} --local-mode"
156
+ .tap { |str| str.insert(0, "& ") if powershell_shell? }
164
157
  end
165
158
 
166
159
  # Determines whether or not local mode (a.k.a chef zero mode) is
@@ -203,7 +196,7 @@ module Kitchen
203
196
  debug("Using a vendored chef-client-zero.rb")
204
197
 
205
198
  source = File.join(File.dirname(__FILE__),
206
- %w[.. .. .. support chef-client-zero.rb])
199
+ %w{.. .. .. support chef-client-zero.rb})
207
200
  FileUtils.cp(source, File.join(sandbox_path, "chef-client-zero.rb"))
208
201
  end
209
202
 
@@ -212,7 +205,7 @@ module Kitchen
212
205
  # @api private
213
206
  def prepare_client_rb
214
207
  data = default_config_rb.merge(config[:client_rb])
215
- data = data.merge(:named_run_list => config[:named_run_list]) if config[:named_run_list]
208
+ data = data.merge(named_run_list: config[:named_run_list]) if config[:named_run_list]
216
209
 
217
210
  info("Preparing client.rb")
218
211
  debug("Creating client.rb from #{data.inspect}")
@@ -230,7 +223,7 @@ module Kitchen
230
223
  debug("Using a dummy validation.pem")
231
224
 
232
225
  source = File.join(File.dirname(__FILE__),
233
- %w[.. .. .. support dummy-validation.pem])
226
+ %w{.. .. .. support dummy-validation.pem})
234
227
  FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
235
228
  end
236
229
 
@@ -240,8 +233,8 @@ module Kitchen
240
233
  # @return [String] the command string
241
234
  # @api private
242
235
  def shim_command
243
- ruby = remote_path_join(config[:ruby_bindir], "ruby").
244
- tap { |path| path.concat(".exe") if windows_os? }
236
+ ruby = remote_path_join(config[:ruby_bindir], "ruby")
237
+ .tap { |path| path.concat(".exe") if windows_os? }
245
238
  shim = remote_path_join(config[:root_path], "chef-client-zero.rb")
246
239
 
247
240
  "#{chef_client_zero_env}\n#{sudo(ruby)} #{shim}"