lib/inspec/runner.rb in inspec-1.48.0 vs lib/inspec/runner.rb in inspec-1.49.2

- old
+ new

@@ -26,11 +26,11 @@ # r.add_target("/path/to/some/profile") # r.add_target("http://url/to/some/profile") # r.run # ``` # - class Runner # rubocop:disable Metrics/ClassLength + class Runner extend Forwardable def_delegator :@test_collector, :report attr_reader :backend, :rules, :attributes @@ -38,13 +38,14 @@ @rules = [] @conf = conf.dup @conf[:logger] ||= Logger.new(nil) @target_profiles = [] @controls = @conf[:controls] || [] + @depends = @conf[:depends] || [] @ignore_supports = @conf[:ignore_supports] @create_lockfile = @conf[:create_lockfile] - @cache = Inspec::Cache.new(@conf[:cache]) + @cache = Inspec::Cache.new(@conf[:vendor_cache]) @test_collector = @conf.delete(:test_collector) || begin require 'inspec/runner_rspec' RunnerRspec.new(@conf) end @@ -166,11 +167,11 @@ # # @eturns [Inspec::ProfileContext] # def add_target(target, _opts = []) profile = Inspec::Profile.for_target(target, - cache: @cache, + vendor_cache: @cache, backend: @backend, controls: @controls, attributes: @conf[:attributes]) raise "Could not resolve #{target} to valid input." if profile.nil? @target_profiles << profile if supports_profile?(profile) @@ -183,12 +184,12 @@ raise 'This profile requires InSpec version '\ "#{profile.metadata.inspec_requirement}. You are running "\ "InSpec v#{Inspec::VERSION}.\n" end - if !profile.supports_os? - raise "This OS/platform (#{@backend.os[:name]}) is not supported by this profile." + if !profile.supports_platform? + raise "This OS/platform (#{@backend.platform.name}/#{@backend.platform.release}) is not supported by this profile." end true end @@ -212,9 +213,16 @@ def eval_with_virtual_profile(command) require 'fetchers/mock' add_target({ 'inspec.yml' => 'name: inspec-shell' }) our_profile = @target_profiles.first ctx = our_profile.runner_context + + # Load local profile dependencies. This is used in inspec shell + # to provide access to local profiles that add resources. + @depends + .map { |x| Inspec::Profile.for_path(x, { profile_context: ctx }) } + .each(&:load_libraries) + ctx.load(command) end private