Make CLI option take precedence over DSL option if it is nondefault

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2021-03-18 23:27:41 -04:00
parent 35b0081c2c
commit e5b74b5760

View file

@ -32,7 +32,15 @@ module Inspec::Resources
@command = cmd @command = cmd
@timeout = options[:timeout]&.to_i || Inspec::Config.cached.final_options['command_timeout']&.to_i || 3600 cli_timeout = Inspec::Config.cached['command_timeout'].to_i
# Can access this via Inspec::InspecCLI.commands["exec"].options[:command_timeout].default,
# but that may not be loaded for kitchen-inspec and other pure gem consumers
default_cli_timeout = 3600
if cli_timeout != default_cli_timeout
@timeout = cli_timeout
else
@timeout = options[:timeout]&.to_i || default_cli_timeout
end
if options[:redact_regex] if options[:redact_regex]
unless options[:redact_regex].is_a?(Regexp) unless options[:redact_regex].is_a?(Regexp)