Class: Puppet::Parser::CatalogCompiler

Inherits:
Compiler show all
Defined in:
lib/puppet/parser/catalog_compiler.rb

Overview

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.

Constant Summary

Constants included from Puppet::Pops::Evaluator::Runtime3Support

Puppet::Pops::Evaluator::Runtime3Support::NAME_SPACE_SEPARATOR

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE, Util::RFC_3986_URI_REGEX

Constants included from Util::SymbolicFileMode

Util::SymbolicFileMode::SetGIDBit, Util::SymbolicFileMode::SetUIDBit, Util::SymbolicFileMode::StickyBit, Util::SymbolicFileMode::SymbolicMode, Util::SymbolicFileMode::SymbolicSpecialToBit

Constants included from Util::POSIX

Util::POSIX::LOCALE_ENV_VARS, Util::POSIX::USER_ENV_VARS

Instance Attribute Summary

Attributes inherited from Compiler

#catalog, #code_id, #collections, #facts, #loaders, #node, #qualified_variables, #relationships, #resources, #topscope

Instance Method Summary collapse

Methods inherited from Compiler

#add_catalog_validator, #add_catalog_validators, #add_class, #add_override, #add_resource, #assert_app_in_site, compile, #context_overrides, #environment, #evaluate_applications, #evaluate_classes, #evaluate_node_classes, #evaluate_relationships, #evaluate_site, #initialize, #newscope, #on_empty_site, #prune_catalog, #prune_node_catalog, #resource_overrides, #validate_catalog, #with_context_overrides

Methods included from Puppet::Pops::Evaluator::Runtime3Support

#add_relationship, #call_function, #capitalize_qualified_name, #coerce_numeric, #convert, #create_local_scope_from, #create_match_scope_from, #create_resource_defaults, #create_resource_overrides, #create_resource_parameter, #create_resources, #diagnostic_producer, #external_call_function, #extract_file_line, #fail, #find_resource, #get_resource_parameter_value, #get_scope_nesting_level, #get_variable_value, #is_boolean?, #is_parameter_of_resource?, #is_true?, #optionally_fail, #resource_to_ptype, #runtime_issue, #set_match_data, #set_scope_nesting_level, #set_variable, #variable_bound?, #variable_exists?

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail

Methods included from Util

absolute_path?, benchmark, chuser, clear_environment, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, safe_posix_fork, set_env, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, which, withenv, withumask

Methods included from Util::SymbolicFileMode

#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?

Methods included from Util::POSIX

#get_posix_field, #gid, groups_of, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Methods included from AbstractCompiler

#catalog, #environment, #newscope, #qualified_variables, #topscope

Constructor Details

This class inherits a constructor from Puppet::Parser::Compiler

Instance Method Details

#compileObject

Evaluates the configured setup for a script + code in an environment with modules


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/puppet/parser/catalog_compiler.rb', line 14

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

#compile_additionsObject

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.


39
40
41
42
# File 'lib/puppet/parser/catalog_compiler.rb', line 39

def compile_additions
  evaluate_additions
  validate
end

#evaluate_additionsObject

Evaluates added constructs that are lazily evaluated until all of them have been evaluated.


46
47
48
49
# File 'lib/puppet/parser/catalog_compiler.rb', line 46

def evaluate_additions
  evaluate_generators
  finish
end

#validateObject

Validates the current state of the catalog. Does not cause evaluation of lazy constructs.


53
54
55
# File 'lib/puppet/parser/catalog_compiler.rb', line 53

def validate
  validate_catalog(CatalogValidator::FINAL)
end