Sha256: 2ea38c7047a04314752e89b733a4c0d01c8cb929ecae6a65fd41815a18563b72

Contents?: true

Size: 1.58 KB

Versions: 229

Compression:

Stored size: 1.58 KB

Contents

require 'puppet/loaders'
require 'puppet/pops'

# A Catalog "compiler" that is like the regular compiler but with an API
# that is harmonized with the ScriptCompiler
#
# The Script compiler is "one shot" - it does not support rechecking if underlying source has changed or
# deal with possible errors in a cached environment.
#
class Puppet::Parser::CatalogCompiler < Puppet::Parser::Compiler

  # Evaluates the configured setup for a script + code in an environment with modules
  #
  def compile
    Puppet[:strict_variables] = true
    Puppet[:strict] = :error

    Puppet.override(rich_data: true) do
      super
    end

  rescue Puppet::ParseErrorWithIssue => detail
    detail.node = node.name
    Puppet.log_exception(detail)
    raise
  rescue => detail
    message = "#{detail} on node #{node.name}"
    Puppet.log_exception(detail, message)
    raise Puppet::Error, message, detail.backtrace
  end

  # Evaluates all added constructs, and validates the resulting catalog.
  # This can be called whenever a series of evaluation of puppet code strings
  # have reached a stable state (essentially that there are no relationships to
  # non-existing resources).
  #
  # Raises an error if validation fails.
  #
  def compile_additions
    evaluate_additions
    validate
  end

  # Evaluates added constructs that are lazily evaluated until all of them have been evaluated.
  # 
  def evaluate_additions
    evaluate_generators
    finish
  end

  # Validates the current state of the catalog.
  # Does not cause evaluation of lazy constructs.
  def validate
    validate_catalog(CatalogValidator::FINAL)
  end
end

Version data entries

229 entries across 229 versions & 2 rubygems

Version Path
puppet-6.29.0 lib/puppet/parser/catalog_compiler.rb
puppet-6.29.0-x86-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.29.0-x64-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.29.0-universal-darwin lib/puppet/parser/catalog_compiler.rb
puppet-6.28.0 lib/puppet/parser/catalog_compiler.rb
puppet-6.28.0-x86-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.28.0-x64-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.28.0-universal-darwin lib/puppet/parser/catalog_compiler.rb
puppet-6.27.0 lib/puppet/parser/catalog_compiler.rb
puppet-6.27.0-x86-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.27.0-x64-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.27.0-universal-darwin lib/puppet/parser/catalog_compiler.rb
puppet-6.26.0 lib/puppet/parser/catalog_compiler.rb
puppet-6.26.0-x86-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.26.0-x64-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.26.0-universal-darwin lib/puppet/parser/catalog_compiler.rb
puppet-6.25.1 lib/puppet/parser/catalog_compiler.rb
puppet-6.25.1-x86-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.25.1-x64-mingw32 lib/puppet/parser/catalog_compiler.rb
puppet-6.25.1-universal-darwin lib/puppet/parser/catalog_compiler.rb