Method: Inspec::Runner#load_attributes

Defined in:
lib/inspec/runner.rb

#load_attributes(options) ⇒ Object

determine all attributes before the execution, fetch data from secrets backend



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/inspec/runner.rb', line 147

def load_attributes(options)
  options[:attributes] ||= {}

  secrets_targets = options[:attrs]
  return options[:attributes] if secrets_targets.nil?

  secrets_targets.each do |target|
    validate_attributes_file_readability!(target)

    secrets = Inspec::SecretsBackend.resolve(target)
    if secrets.nil?
      raise Inspec::Exceptions::SecretsBackendNotFound,
            "Cannot find parser for attributes file '#{target}'. " \
            'Check to make sure file has the appropriate extension.'
    end

    next if secrets.attributes.nil?
    options[:attributes].merge!(secrets.attributes)
  end

  options[:attributes]
end