Class: Puppet::Pops::Lookup::HieraConfigV4 Private
- Inherits:
-
HieraConfig
- Object
- HieraConfig
- Puppet::Pops::Lookup::HieraConfigV4
- Defined in:
- lib/puppet/pops/lookup/hiera_config.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants inherited from HieraConfig
Puppet::Pops::Lookup::HieraConfig::ALL_FUNCTION_KEYS, Puppet::Pops::Lookup::HieraConfig::CONFIG_FILE_NAME, Puppet::Pops::Lookup::HieraConfig::FUNCTION_KEYS, Puppet::Pops::Lookup::HieraConfig::FUNCTION_PROVIDERS, Puppet::Pops::Lookup::HieraConfig::KEY_BACKEND, Puppet::Pops::Lookup::HieraConfig::KEY_DATADIR, Puppet::Pops::Lookup::HieraConfig::KEY_DATA_DIG, Puppet::Pops::Lookup::HieraConfig::KEY_DATA_HASH, Puppet::Pops::Lookup::HieraConfig::KEY_DEFAULTS, Puppet::Pops::Lookup::HieraConfig::KEY_DEFAULT_HIERARCHY, Puppet::Pops::Lookup::HieraConfig::KEY_EXTENSION, Puppet::Pops::Lookup::HieraConfig::KEY_GLOB, Puppet::Pops::Lookup::HieraConfig::KEY_GLOBS, Puppet::Pops::Lookup::HieraConfig::KEY_HIERARCHY, Puppet::Pops::Lookup::HieraConfig::KEY_LOGGER, Puppet::Pops::Lookup::HieraConfig::KEY_LOOKUP_KEY, Puppet::Pops::Lookup::HieraConfig::KEY_MAPPED_PATHS, Puppet::Pops::Lookup::HieraConfig::KEY_NAME, Puppet::Pops::Lookup::HieraConfig::KEY_OPTIONS, Puppet::Pops::Lookup::HieraConfig::KEY_PATH, Puppet::Pops::Lookup::HieraConfig::KEY_PATHS, Puppet::Pops::Lookup::HieraConfig::KEY_PLAN_HIERARCHY, Puppet::Pops::Lookup::HieraConfig::KEY_URI, Puppet::Pops::Lookup::HieraConfig::KEY_URIS, Puppet::Pops::Lookup::HieraConfig::KEY_V3_BACKEND, Puppet::Pops::Lookup::HieraConfig::KEY_V3_DATA_HASH, Puppet::Pops::Lookup::HieraConfig::KEY_V3_LOOKUP_KEY, Puppet::Pops::Lookup::HieraConfig::KEY_V4_DATA_HASH, Puppet::Pops::Lookup::HieraConfig::KEY_VERSION, Puppet::Pops::Lookup::HieraConfig::LOCATION_KEYS
Constants included from Puppet::Pops::LabelProvider
Puppet::Pops::LabelProvider::A, Puppet::Pops::LabelProvider::AN, Puppet::Pops::LabelProvider::SKIPPED_CHARACTERS, Puppet::Pops::LabelProvider::VOWELS
Constants included from SubLookup
Instance Attribute Summary
Attributes inherited from HieraConfig
Class Method Summary collapse
- .config_type ⇒ Object private
Instance Method Summary collapse
- #create_configured_data_providers(lookup_invocation, parent_data_provider, _) ⇒ Object private
- #validate_config(config, owner) ⇒ Object private
- #version ⇒ Object private
Methods inherited from HieraConfig
config_exist?, #configured_data_providers, create, #create_hiera3_backend_provider, #fail, #find_line_matching, #has_default_hierarchy?, #initialize, #name, #scope_interpolations_stable?, symkeys_to_string, v4_function_config
Methods included from Puppet::Pops::LabelProvider
#a_an, #a_an_uc, #article, #combine_strings, #label, #plural_s, #the, #the_uc
Methods included from LocationResolver
#expand_globs, #expand_mapped_paths, #expand_uris, #resolve_paths
Methods included from Interpolation
Methods included from SubLookup
Constructor Details
This class inherits a constructor from Puppet::Pops::Lookup::HieraConfig
Class Method Details
.config_type ⇒ Object
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.
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/puppet/pops/lookup/hiera_config.rb', line 489 def self.config_type return @@CONFIG_TYPE if class_variable_defined?(:@@CONFIG_TYPE) tf = Types::TypeFactory nes_t = Types::PStringType::NON_EMPTY @@CONFIG_TYPE = tf.struct({ KEY_VERSION => tf.range(4, 4), tf.optional(KEY_DATADIR) => nes_t, tf.optional(KEY_HIERARCHY) => tf.array_of(tf.struct( KEY_BACKEND => nes_t, KEY_NAME => nes_t, tf.optional(KEY_DATADIR) => nes_t, tf.optional(KEY_PATH) => nes_t, tf.optional(KEY_PATHS) => tf.array_of(nes_t) )) }) end |
Instance Method Details
#create_configured_data_providers(lookup_invocation, parent_data_provider, _) ⇒ Object
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.
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
# File 'lib/puppet/pops/lookup/hiera_config.rb', line 509 def create_configured_data_providers(lookup_invocation, parent_data_provider, _) default_datadir = @config[KEY_DATADIR] data_providers = {} @config[KEY_HIERARCHY].each do |he| name = he[KEY_NAME] if data_providers.include?(name) first_line = find_line_matching(/\s+name:\s+['"]?#{name}(?:[^\w]|$)/) line = find_line_matching(/\s+name:\s+['"]?#{name}(?:[^\w]|$)/, first_line + 1) if first_line unless line line = first_line first_line = nil end fail(Issues::HIERA_HIERARCHY_NAME_MULTIPLY_DEFINED, { :name => name, :first_line => first_line }, line) end original_paths = he[KEY_PATHS] || [he[KEY_PATH] || name] datadir = @config_root + (he[KEY_DATADIR] || default_datadir) provider_name = he[KEY_BACKEND] data_providers[name] = if %w[json yaml].include?(provider_name) create_data_provider(name, parent_data_provider, KEY_DATA_HASH, "#{provider_name}_data", {}, resolve_paths(datadir, original_paths, lookup_invocation, @config_path.nil?, ".#{provider_name}")) elsif provider_name == 'hocon' && Puppet.features.hocon? create_data_provider(name, parent_data_provider, KEY_DATA_HASH, 'hocon_data', {}, resolve_paths(datadir, original_paths, lookup_invocation, @config_path.nil?, '.conf')) else fail(Issues::HIERA_NO_PROVIDER_FOR_BACKEND, { :name => provider_name }, find_line_matching(/[^\w]#{provider_name}(?:[^\w]|$)/)) end end data_providers.values end |
#validate_config(config, owner) ⇒ Object
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.
553 554 555 556 557 558 559 560 561 |
# File 'lib/puppet/pops/lookup/hiera_config.rb', line 553 def validate_config(config, owner) unless Puppet[:strict] == :off Puppet.warn_once('deprecations', 'hiera.yaml', _("%{config_path}: Use of 'hiera.yaml' version 4 is deprecated. It should be converted to version 5") % { config_path: @config_path }, config_path.to_s) end config[KEY_DATADIR] ||= 'data' config[KEY_HIERARCHY] ||= [{ KEY_NAME => 'common', KEY_BACKEND => 'yaml' }] Types::TypeAsserter.assert_instance_of(["The Lookup Configuration at '%s'", @config_path], self.class.config_type, config) end |
#version ⇒ Object
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.
563 564 565 |
# File 'lib/puppet/pops/lookup/hiera_config.rb', line 563 def version 4 end |