Method: Inspec::Profile#initialize
- Defined in:
- lib/inspec/profile.rb
#initialize(source_reader, options = {}) ⇒ Profile
rubocop:disable Metrics/AbcSize
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/inspec/profile.rb', line 88 def initialize(source_reader, = {}) @source_reader = source_reader @target = [:target] @logger = [:logger] || Logger.new(nil) @locked_dependencies = [:dependencies] @controls = [:controls] || [] @writable = [:writable] || false @profile_id = [:id] @cache = [:vendor_cache] || Cache.new @attr_values = [:attributes] @tests_collected = false @libraries_loaded = false @check_mode = [:check_mode] || false Metadata.finalize(@source_reader., @profile_id, ) # if a backend has already been created, clone it so each profile has its own unique backend object # otherwise, create a new backend object # # This is necessary since we store the RuntimeProfile on the backend object. If a user runs `inspec exec` # with multiple profiles, only the RuntimeProfile for the last-loaded profile will be available if # we share the backend between profiles. # # This will cause issues if a profile attempts to load a file via `inspec.profile.file` = .reject { |k, _| k == 'target' } # See https://github.com/chef/inspec/pull/1646 @backend = [:backend].nil? ? Inspec::Backend.create() : [:backend].dup @runtime_profile = RuntimeProfile.new(self) @backend.profile = @runtime_profile @runner_context = [:profile_context] || Inspec::ProfileContext.for_profile(self, @backend, @attr_values) @supports_platform = .supports_platform?(@backend) @supports_runtime = .supports_runtime? end |