Method: Puppet::Pops::Loaders#load_main_manifest

Defined in:
lib/puppet/pops/loaders.rb

#load_main_manifestModel::Program

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Load the main manifest for the given environment

There are two sources that can be used for the initial parse:

1. The value of `Puppet[:code]`: Puppet can take a string from
  its settings and parse that as a manifest. This is used by various
  Puppet applications to read in a manifest and pass it to the
  environment as a side effect. This is attempted first.
2. The contents of the environment's +manifest+ attribute: Puppet will
  try to load the environment manifest. The manifest must be a file.

Returns:



279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/puppet/pops/loaders.rb', line 279

def load_main_manifest
  parser = Parser::EvaluatingParser.singleton
  parsed_code = Puppet[:code]
  program = if parsed_code != ""
    parser.parse_string(parsed_code, 'unknown-source-location')
  else
    file = @environment.manifest

    # if the manifest file is a reference to a directory, parse and combine
    # all .pp files in that directory
    if file == Puppet::Node::Environment::NO_MANIFEST
      nil
    elsif File.directory?(file)
      raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints directory '#{file}'. It must be a file"
    elsif File.exist?(file)
      parser.parse_file(file)
    else
      raise Puppet::Error, "manifest of environment '#{@environment.name}' appoints '#{file}'. It does not exist"
    end
  end
  instantiate_definitions(program, public_environment_loader) unless program.nil?
  program
rescue Puppet::ParseErrorWithIssue => detail
  detail.environment = @environment.name
  raise
rescue => detail
  msg = _('Could not parse for environment %{env}: %{detail}') % { env: @environment, detail: detail }
  error = Puppet::Error.new(msg)
  error.set_backtrace(detail.backtrace)
  raise error
end