test-kitchen 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.cane +1 -1
  3. data/.rubocop.yml +3 -0
  4. data/.travis.yml +20 -9
  5. data/CHANGELOG.md +219 -108
  6. data/Gemfile +10 -6
  7. data/Guardfile +38 -9
  8. data/README.md +11 -1
  9. data/Rakefile +21 -37
  10. data/bin/kitchen +4 -4
  11. data/features/kitchen_action_commands.feature +161 -0
  12. data/features/kitchen_console_command.feature +34 -0
  13. data/features/kitchen_diagnose_command.feature +64 -0
  14. data/features/kitchen_init_command.feature +29 -17
  15. data/features/kitchen_list_command.feature +2 -2
  16. data/features/kitchen_login_command.feature +56 -0
  17. data/features/{sink_command.feature → kitchen_sink_command.feature} +0 -0
  18. data/features/kitchen_test_command.feature +88 -0
  19. data/features/step_definitions/gem_steps.rb +8 -6
  20. data/features/step_definitions/git_steps.rb +4 -2
  21. data/features/step_definitions/output_steps.rb +5 -0
  22. data/features/support/env.rb +12 -9
  23. data/lib/kitchen.rb +60 -38
  24. data/lib/kitchen/base64_stream.rb +55 -0
  25. data/lib/kitchen/busser.rb +124 -58
  26. data/lib/kitchen/cli.rb +121 -38
  27. data/lib/kitchen/collection.rb +3 -3
  28. data/lib/kitchen/color.rb +4 -4
  29. data/lib/kitchen/command.rb +78 -11
  30. data/lib/kitchen/command/action.rb +3 -2
  31. data/lib/kitchen/command/console.rb +12 -5
  32. data/lib/kitchen/command/diagnose.rb +17 -3
  33. data/lib/kitchen/command/driver_discover.rb +26 -7
  34. data/lib/kitchen/command/exec.rb +41 -0
  35. data/lib/kitchen/command/list.rb +44 -14
  36. data/lib/kitchen/command/login.rb +2 -1
  37. data/lib/kitchen/command/sink.rb +2 -1
  38. data/lib/kitchen/command/test.rb +5 -4
  39. data/lib/kitchen/config.rb +146 -14
  40. data/lib/kitchen/configurable.rb +314 -0
  41. data/lib/kitchen/data_munger.rb +522 -18
  42. data/lib/kitchen/diagnostic.rb +43 -4
  43. data/lib/kitchen/driver.rb +4 -4
  44. data/lib/kitchen/driver/base.rb +80 -115
  45. data/lib/kitchen/driver/dummy.rb +34 -6
  46. data/lib/kitchen/driver/proxy.rb +14 -3
  47. data/lib/kitchen/driver/ssh_base.rb +61 -7
  48. data/lib/kitchen/errors.rb +109 -9
  49. data/lib/kitchen/generator/driver_create.rb +39 -5
  50. data/lib/kitchen/generator/init.rb +130 -45
  51. data/lib/kitchen/instance.rb +162 -28
  52. data/lib/kitchen/lazy_hash.rb +79 -7
  53. data/lib/kitchen/loader/yaml.rb +159 -27
  54. data/lib/kitchen/logger.rb +267 -21
  55. data/lib/kitchen/logging.rb +30 -3
  56. data/lib/kitchen/login_command.rb +11 -2
  57. data/lib/kitchen/metadata_chopper.rb +2 -2
  58. data/lib/kitchen/provisioner.rb +4 -4
  59. data/lib/kitchen/provisioner/base.rb +107 -103
  60. data/lib/kitchen/provisioner/chef/berkshelf.rb +36 -8
  61. data/lib/kitchen/provisioner/chef/librarian.rb +40 -11
  62. data/lib/kitchen/provisioner/chef_base.rb +206 -167
  63. data/lib/kitchen/provisioner/chef_solo.rb +25 -7
  64. data/lib/kitchen/provisioner/chef_zero.rb +105 -29
  65. data/lib/kitchen/provisioner/dummy.rb +1 -1
  66. data/lib/kitchen/provisioner/shell.rb +21 -6
  67. data/lib/kitchen/rake_tasks.rb +8 -3
  68. data/lib/kitchen/shell_out.rb +15 -18
  69. data/lib/kitchen/ssh.rb +122 -27
  70. data/lib/kitchen/state_file.rb +24 -7
  71. data/lib/kitchen/thor_tasks.rb +9 -4
  72. data/lib/kitchen/util.rb +43 -118
  73. data/lib/kitchen/version.rb +1 -1
  74. data/lib/vendor/hash_recursive_merge.rb +10 -2
  75. data/spec/kitchen/base64_stream_spec.rb +77 -0
  76. data/spec/kitchen/busser_spec.rb +490 -0
  77. data/spec/kitchen/collection_spec.rb +10 -10
  78. data/spec/kitchen/color_spec.rb +2 -2
  79. data/spec/kitchen/config_spec.rb +234 -62
  80. data/spec/kitchen/configurable_spec.rb +490 -0
  81. data/spec/kitchen/data_munger_spec.rb +1070 -862
  82. data/spec/kitchen/diagnostic_spec.rb +79 -0
  83. data/spec/kitchen/driver/base_spec.rb +80 -85
  84. data/spec/kitchen/driver/dummy_spec.rb +43 -14
  85. data/spec/kitchen/driver/proxy_spec.rb +134 -0
  86. data/spec/kitchen/driver/ssh_base_spec.rb +644 -0
  87. data/spec/kitchen/driver_spec.rb +15 -15
  88. data/spec/kitchen/errors_spec.rb +309 -0
  89. data/spec/kitchen/instance_spec.rb +143 -46
  90. data/spec/kitchen/lazy_hash_spec.rb +36 -9
  91. data/spec/kitchen/loader/yaml_spec.rb +237 -226
  92. data/spec/kitchen/logger_spec.rb +419 -0
  93. data/spec/kitchen/logging_spec.rb +59 -0
  94. data/spec/kitchen/login_command_spec.rb +49 -0
  95. data/spec/kitchen/metadata_chopper_spec.rb +82 -0
  96. data/spec/kitchen/platform_spec.rb +4 -4
  97. data/spec/kitchen/provisioner/base_spec.rb +65 -125
  98. data/spec/kitchen/provisioner/chef_base_spec.rb +798 -0
  99. data/spec/kitchen/provisioner/chef_solo_spec.rb +316 -0
  100. data/spec/kitchen/provisioner/chef_zero_spec.rb +624 -0
  101. data/spec/kitchen/provisioner/shell_spec.rb +269 -0
  102. data/spec/kitchen/provisioner_spec.rb +6 -6
  103. data/spec/kitchen/shell_out_spec.rb +143 -0
  104. data/spec/kitchen/ssh_spec.rb +683 -0
  105. data/spec/kitchen/state_file_spec.rb +28 -21
  106. data/spec/kitchen/suite_spec.rb +7 -7
  107. data/spec/kitchen/util_spec.rb +68 -10
  108. data/spec/kitchen_spec.rb +107 -0
  109. data/spec/spec_helper.rb +18 -13
  110. data/support/chef-client-zero.rb +10 -9
  111. data/support/chef_helpers.sh +16 -0
  112. data/support/download_helpers.sh +109 -0
  113. data/test-kitchen.gemspec +42 -33
  114. metadata +107 -33
@@ -16,7 +16,7 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- require 'kitchen/provisioner/chef_base'
19
+ require "kitchen/provisioner/chef_base"
20
20
 
21
21
  module Kitchen
22
22
 
@@ -29,26 +29,44 @@ module Kitchen
29
29
 
30
30
  default_config :solo_rb, {}
31
31
 
32
+ default_config :chef_solo_path do |provisioner|
33
+ File.join(provisioner[:chef_omnibus_root], %w[bin chef-solo])
34
+ end
35
+
36
+ # (see Base#create_sandbox)
32
37
  def create_sandbox
33
38
  super
34
39
  prepare_solo_rb
35
40
  end
36
41
 
42
+ # (see Base#run_command)
37
43
  def run_command
38
- [
39
- sudo('chef-solo'),
44
+ level = config[:log_level] == :info ? :auto : config[:log_level]
45
+
46
+ cmd = sudo(config[:chef_solo_path])
47
+ args = [
40
48
  "--config #{config[:root_path]}/solo.rb",
41
- "--json-attributes #{config[:root_path]}/dna.json",
42
- config[:log_file] ? "--logfile #{config[:log_file]}" : nil,
43
- "--log_level #{config[:log_level]}"
44
- ].join(" ")
49
+ "--log_level #{level}",
50
+ "--force-formatter",
51
+ "--no-color",
52
+ "--json-attributes #{config[:root_path]}/dna.json"
53
+ ]
54
+ args << "--logfile #{config[:log_file]}" if config[:log_file]
55
+
56
+ Util.wrap_command([cmd, *args].join(" "))
45
57
  end
46
58
 
47
59
  private
48
60
 
61
+ # Writes a solo.rb configuration file to the sandbox directory.
62
+ #
63
+ # @api private
49
64
  def prepare_solo_rb
50
65
  data = default_config_rb.merge(config[:solo_rb])
51
66
 
67
+ info("Preparing solo.rb")
68
+ debug("Creating solo.rb from #{data.inspect}")
69
+
52
70
  File.open(File.join(sandbox_path, "solo.rb"), "wb") do |file|
53
71
  file.write(format_config_file(data))
54
72
  end
@@ -16,7 +16,7 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- require 'kitchen/provisioner/chef_base'
19
+ require "kitchen/provisioner/chef_base"
20
20
 
21
21
  module Kitchen
22
22
 
@@ -30,7 +30,14 @@ module Kitchen
30
30
  default_config :client_rb, {}
31
31
  default_config :ruby_bindir, "/opt/chef/embedded/bin"
32
32
  default_config :json_attributes, true
33
+ default_config :chef_zero_host, nil
34
+ default_config :chef_zero_port, 8889
33
35
 
36
+ default_config :chef_client_path do |provisioner|
37
+ File.join(provisioner[:chef_omnibus_root], %w[bin chef-client])
38
+ end
39
+
40
+ # (see Base#create_sandbox)
34
41
  def create_sandbox
35
42
  super
36
43
  prepare_chef_client_zero_rb
@@ -38,71 +45,136 @@ module Kitchen
38
45
  prepare_client_rb
39
46
  end
40
47
 
48
+ # (see Base#prepare_command)
41
49
  def prepare_command
42
- return if local_mode_supported?
50
+ return if modern?
43
51
 
44
- ruby_bin = config[:ruby_bindir]
52
+ ruby_bin = Pathname.new(config[:ruby_bindir])
45
53
 
46
- # use Bourne (/bin/sh) as Bash does not exist on all Unix flavors
47
- #
48
- # * we are installing latest chef in order to get chef-zero and
49
- # Chef::ChefFS only. The version of Chef that gets run will be
50
- # the installed omnibus package. Yep, this is funky :)
51
- <<-PREPARE.gsub(/^ {10}/, '')
52
- sh -c '
54
+ # we are installing latest chef in order to get chef-zero and
55
+ # Chef::ChefFS only. The version of Chef that gets run will be
56
+ # the installed omnibus package. Yep, this is funky :)
57
+ cmd = <<-PREPARE.gsub(/^ {10}/, "")
53
58
  #{chef_client_zero_env(:export)}
54
- if ! #{sudo("#{ruby_bin}/gem")} list chef-zero -i >/dev/null; then
59
+ if ! #{sudo(ruby_bin.join("gem"))} list chef-zero -i >/dev/null; then
55
60
  echo ">>>>>> Attempting to use chef-zero with old version of Chef"
56
61
  echo "-----> Installing chef zero dependencies"
57
- #{sudo("#{ruby_bin}/gem")} install chef --no-ri --no-rdoc --conservative
58
- fi'
62
+ #{sudo(ruby_bin.join("gem"))} install chef --no-ri --no-rdoc --conservative
63
+ fi
59
64
  PREPARE
65
+
66
+ Util.wrap_command(cmd)
60
67
  end
61
68
 
69
+ # (see Base#run_command)
62
70
  def run_command
71
+ cmd = modern? ? local_mode_command : shim_command
72
+
73
+ Util.wrap_command([cmd, *chef_client_args].join(" "))
74
+ end
75
+
76
+ private
77
+
78
+ # Returns the command that will run chef client in local mode (a.k.a.
79
+ # chef zero mode).
80
+ #
81
+ # @return [String] the command string
82
+ # @api private
83
+ def local_mode_command
84
+ "#{sudo(config[:chef_client_path])} --local-mode"
85
+ end
86
+
87
+ # Returns the command that will run a backwards compatible shim script
88
+ # that approximates local mode in a modern chef-client run.
89
+ #
90
+ # @return [String] the command string
91
+ # @api private
92
+ def shim_command
93
+ [
94
+ chef_client_zero_env,
95
+ sudo("#{config[:ruby_bindir]}/ruby"),
96
+ "#{config[:root_path]}/chef-client-zero.rb"
97
+ ].join(" ")
98
+ end
99
+
100
+ # Returns an Array of command line arguments for the chef client.
101
+ #
102
+ # @return [Array<String>] an array of command line arguments
103
+ # @api private
104
+ def chef_client_args
105
+ level = config[:log_level] == :info ? :auto : config[:log_level]
63
106
  args = [
64
107
  "--config #{config[:root_path]}/client.rb",
65
- "--log_level #{config[:log_level]}"
108
+ "--log_level #{level}",
109
+ "--force-formatter",
110
+ "--no-color"
66
111
  ]
112
+
113
+ if config[:chef_zero_host]
114
+ args << "--chef-zero-host #{config[:chef_zero_host]}"
115
+ end
116
+ if config[:chef_zero_port]
117
+ args << "--chef-zero-port #{config[:chef_zero_port]}"
118
+ end
67
119
  if config[:json_attributes]
68
120
  args << "--json-attributes #{config[:root_path]}/dna.json"
69
121
  end
70
-
71
- if local_mode_supported?
72
- ["#{sudo('chef-client')} -z"].concat(args).join(" ")
73
- else
74
- [
75
- chef_client_zero_env,
76
- sudo("#{config[:ruby_bindir]}/ruby"),
77
- "#{config[:root_path]}/chef-client-zero.rb"
78
- ].concat(args).join(" ")
122
+ if config[:log_file]
123
+ args << "--logfile #{config[:log_file]}"
79
124
  end
80
- end
81
125
 
82
- private
126
+ args
127
+ end
83
128
 
129
+ # Writes a chef-client local-mode shim script to the sandbox directory
130
+ # only if the desired version of Chef is old enough. The version of Chef
131
+ # is determined using the `config[:require_chef_omnibus]` value.
132
+ #
133
+ # @api private
84
134
  def prepare_chef_client_zero_rb
85
- return if local_mode_supported?
135
+ return if modern?
136
+
137
+ info("Preparing chef-client-zero.rb")
138
+ debug("Using a vendored chef-client-zero.rb")
86
139
 
87
140
  source = File.join(File.dirname(__FILE__),
88
- %w{.. .. .. support chef-client-zero.rb})
141
+ %w[.. .. .. support chef-client-zero.rb])
89
142
  FileUtils.cp(source, File.join(sandbox_path, "chef-client-zero.rb"))
90
143
  end
91
144
 
145
+ # Writes a fake (but valid) validation.pem into the sandbox directory.
146
+ #
147
+ # @api private
92
148
  def prepare_validation_pem
149
+ info("Preparing validation.pem")
150
+ debug("Using a dummy validation.pem")
151
+
93
152
  source = File.join(File.dirname(__FILE__),
94
- %w{.. .. .. support dummy-validation.pem})
153
+ %w[.. .. .. support dummy-validation.pem])
95
154
  FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
96
155
  end
97
156
 
157
+ # Writes a client.rb configuration file to the sandbox directory.
158
+ #
159
+ # @api private
98
160
  def prepare_client_rb
99
161
  data = default_config_rb.merge(config[:client_rb])
100
162
 
163
+ info("Preparing client.rb")
164
+ debug("Creating client.rb from #{data.inspect}")
165
+
101
166
  File.open(File.join(sandbox_path, "client.rb"), "wb") do |file|
102
167
  file.write(format_config_file(data))
103
168
  end
104
169
  end
105
170
 
171
+ # Generates a string of shell environment variables needed for the
172
+ # chef-client-zero.rb shim script to properly function.
173
+ #
174
+ # @param extra [Symbol] whether or not the environment variables need to
175
+ # be exported, using the `:export` symbol (default: `nil`)
176
+ # @return [String] a shell script string
177
+ # @api private
106
178
  def chef_client_zero_env(extra = nil)
107
179
  args = [
108
180
  %{CHEF_REPO_PATH="#{config[:root_path]}"},
@@ -123,7 +195,11 @@ module Kitchen
123
195
  # The only way this method returns false is if require_chef_omnibus has
124
196
  # an explicit version set to less than 11.8.0, when chef zero mode was
125
197
  # introduced. Otherwise a modern Chef installation is assumed.
126
- def local_mode_supported?
198
+ #
199
+ # @return [true,false] whether or not the desired version of Chef
200
+ # supports local mode
201
+ # @api private
202
+ def modern?
127
203
  version = config[:require_chef_omnibus]
128
204
 
129
205
  case version
@@ -16,7 +16,7 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- require 'kitchen'
19
+ require "kitchen"
20
20
 
21
21
  module Kitchen
22
22
 
@@ -16,7 +16,7 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- require 'kitchen/provisioner/base'
19
+ require "kitchen/provisioner/base"
20
20
 
21
21
  module Kitchen
22
22
 
@@ -28,7 +28,7 @@ module Kitchen
28
28
  class Shell < Base
29
29
 
30
30
  default_config :script do |provisioner|
31
- provisioner.calculate_path("bootstrap.sh", :script)
31
+ provisioner.calculate_path("bootstrap.sh", :type => :file)
32
32
  end
33
33
  expand_path_for :script
34
34
 
@@ -37,23 +37,34 @@ module Kitchen
37
37
  end
38
38
  expand_path_for :data_path
39
39
 
40
+ # (see Base#create_sandbox)
40
41
  def create_sandbox
41
42
  super
42
43
  prepare_data
43
44
  prepare_script
44
45
  end
45
46
 
47
+ # (see Base#init_command)
46
48
  def init_command
47
49
  data = File.join(config[:root_path], "data")
48
- "#{sudo('rm')} -rf #{data} ; mkdir -p #{config[:root_path]}"
50
+ cmd = "#{sudo("rm")} -rf #{data} ; mkdir -p #{config[:root_path]}"
51
+
52
+ Util.wrap_command(cmd)
49
53
  end
50
54
 
55
+ # (see Base#run_command)
51
56
  def run_command
52
- sudo(File.join(config[:root_path], File.basename(config[:script])))
57
+ Util.wrap_command(
58
+ sudo(File.join(config[:root_path], File.basename(config[:script])))
59
+ )
53
60
  end
54
61
 
55
- protected
62
+ private
56
63
 
64
+ # Creates a data directory in the sandbox directory, if a data directory
65
+ # can be found and copies in the tree.
66
+ #
67
+ # @api private
57
68
  def prepare_data
58
69
  return unless config[:data_path]
59
70
 
@@ -65,6 +76,10 @@ module Kitchen
65
76
  FileUtils.cp_r(Dir.glob("#{config[:data_path]}/*"), tmpdata_dir)
66
77
  end
67
78
 
79
+ # Copies the executable script to the sandbox directory or creates a
80
+ # stub script if one cannot be found.
81
+ #
82
+ # @api private
68
83
  def prepare_script
69
84
  info("Preparing script")
70
85
 
@@ -73,7 +88,7 @@ module Kitchen
73
88
  FileUtils.cp_r(config[:script], sandbox_path)
74
89
  else
75
90
  config[:script] = File.join(sandbox_path, "bootstrap.sh")
76
- info("#{File.basename(config[:script])} not found " +
91
+ info("#{File.basename(config[:script])} not found " \
77
92
  "so Kitchen will run a stubbed script. Is this intended?")
78
93
  File.open(config[:script], "wb") do |file|
79
94
  file.write(%{#!/bin/sh\necho "NO BOOTSTRAP SCRIPT PRESENT"\n})
@@ -16,9 +16,9 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- require 'rake/tasklib'
19
+ require "rake/tasklib"
20
20
 
21
- require 'kitchen'
21
+ require "kitchen"
22
22
 
23
23
  module Kitchen
24
24
 
@@ -39,8 +39,13 @@ module Kitchen
39
39
 
40
40
  private
41
41
 
42
+ # @return [Config] a Kitchen::Config
42
43
  attr_reader :config
43
44
 
45
+ # Generates a test Rake task for each instance and one to test all
46
+ # instances in serial.
47
+ #
48
+ # @api private
44
49
  def define
45
50
  namespace "kitchen" do
46
51
  config.instances.each do |instance|
@@ -51,7 +56,7 @@ module Kitchen
51
56
  end
52
57
 
53
58
  desc "Run all test instances"
54
- task "all" => config.instances.map { |i| i.name }
59
+ task "all" => config.instances.map(&:name)
55
60
  end
56
61
  end
57
62
  end
@@ -16,7 +16,7 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
 
19
- require 'mixlib/shellout'
19
+ require "mixlib/shellout"
20
20
 
21
21
  module Kitchen
22
22
 
@@ -27,7 +27,7 @@ module Kitchen
27
27
  module ShellOut
28
28
 
29
29
  # Wrapped exception for any interally raised shell out commands.
30
- class ShellCommandFailed < TransientFailure ; end
30
+ class ShellCommandFailed < TransientFailure; end
31
31
 
32
32
  # Executes a command in a subshell on the local running system.
33
33
  #
@@ -41,11 +41,11 @@ module Kitchen
41
41
  # the command
42
42
  # @option options [Hash] :environment a Hash of environment variables to
43
43
  # set before the command is run. By default, the environment will
44
- # *always* be set to 'LC_ALL' => 'C' to prevent issues with multibyte
44
+ # *always* be set to `'LC_ALL' => 'C'` to prevent issues with multibyte
45
45
  # characters in Ruby 1.8. To avoid this, use :environment => nil for
46
46
  # *no* extra environment settings, or
47
- # :environment => {'LC_ALL'=>nil, ...} to set other environment settings
48
- # without changing the locale.
47
+ # `:environment => {'LC_ALL'=>nil, ...}` to set other environment
48
+ # settings without changing the locale.
49
49
  # @option options [Integer] :timeout Numeric value for the number of
50
50
  # seconds to wait on the child process before raising an Exception.
51
51
  # This is calculated as the total amount of time that ShellOut waited on
@@ -56,11 +56,10 @@ module Kitchen
56
56
  # @raise [ShellCommandFailed] if the command fails
57
57
  # @raise [Error] for all other unexpected exceptions
58
58
  def run_command(cmd, options = {})
59
- use_sudo = options[:use_sudo].nil? ? false : options[:use_sudo]
60
- cmd = "sudo -E #{cmd}" if use_sudo
61
- subject = "[#{options[:log_subject] || "local"} command]"
59
+ cmd = "sudo -E #{cmd}" if options.fetch(:use_sudo, false)
60
+ subject = "[#{options.fetch(:log_subject, "local")} command]"
62
61
 
63
- debug("#{subject} BEGIN (#{display_cmd(cmd)})")
62
+ debug("#{subject} BEGIN (#{cmd})")
64
63
  sh = Mixlib::ShellOut.new(cmd, shell_opts(options))
65
64
  sh.run_command
66
65
  debug("#{subject} END #{Util.duration(sh.execution_time)}")
@@ -68,22 +67,20 @@ module Kitchen
68
67
  sh.stdout
69
68
  rescue Mixlib::ShellOut::ShellCommandFailed => ex
70
69
  raise ShellCommandFailed, ex.message
71
- rescue Exception => error
70
+ rescue Exception => error # rubocop:disable Lint/RescueException
72
71
  error.extend(Kitchen::Error)
73
72
  raise
74
73
  end
75
74
 
76
75
  private
77
76
 
78
- def display_cmd(cmd)
79
- first_line, newline, rest = cmd.partition("\n")
80
- last_char = cmd[cmd.size - 1]
81
-
82
- newline == "\n" ? "#{first_line}\\n...#{last_char}" : cmd
83
- end
84
-
77
+ # Returns a hash of MixLib::ShellOut options for the command.
78
+ #
79
+ # @param options [Hash] a Hash of options
80
+ # @return [Hash] a new Hash of options, filterd and merged with defaults
81
+ # @api private
85
82
  def shell_opts(options)
86
- filtered_opts = options.reject do |key, value|
83
+ filtered_opts = options.reject do |key, _value|
87
84
  [:use_sudo, :log_subject, :quiet].include?(key)
88
85
  end
89
86
  { :live_stream => logger, :timeout => 60000 }.merge(filtered_opts)