lib/inspec/cli.rb in inspec-1.0.0 vs lib/inspec/cli.rb in inspec-1.1.0
- old
+ new
@@ -32,10 +32,11 @@
profile_options
def json(target)
diagnose
o = opts.dup
o[:ignore_supports] = true
+ o[:backend] = Inspec::Backend.create(target: 'mock://')
profile = Inspec::Profile.for_target(target, o)
dst = o[:output].to_s
if dst.empty?
puts JSON.dump(profile.info)
@@ -58,10 +59,11 @@
def check(path) # rubocop:disable Metrics/AbcSize
diagnose
o = opts.dup
# configure_logger(o) # we do not need a logger for check yet
o[:ignore_supports] = true # we check for integrity only
+ o[:backend] = Inspec::Backend.create(target: 'mock://')
# run check
profile = Inspec::Profile.for_target(path, o)
result = profile.check
@@ -103,12 +105,16 @@
pretty_handle_exception(e)
end
desc 'vendor', 'Download all dependencies and generate a lockfile'
def vendor(path = nil)
- configure_logger(opts)
- profile = Inspec::Profile.for_target('./', opts.merge(cache: Inspec::Cache.new(path)))
+ o = opts.dup
+ o[:cache] = Inspec::Cache.new(path)
+ o[:backend] = Inspec::Backend.create(target: 'mock://')
+ configure_logger(o)
+
+ profile = Inspec::Profile.for_target('./', o)
lockfile = profile.generate_lockfile
File.write('inspec.lock', lockfile.to_yaml)
rescue StandardError => e
pretty_handle_exception(e)
end
@@ -129,15 +135,16 @@
diagnose
o = opts.dup
o[:logger] = Logger.new(STDOUT)
o[:logger].level = get_log_level(o.log_level)
+ o[:backend] = Inspec::Backend.create(target: 'mock://')
profile = Inspec::Profile.for_target(path, o)
result = profile.check
if result && !opts[:ignore_errors] == false
- @logger.info 'Profile check failed. Please fix the profile before generating an archive.'
+ o[:logger].info 'Profile check failed. Please fix the profile before generating an archive.'
return exit 1
end
# generate archive
exit 1 unless profile.archive(opts)