class Puppet::Pops::Lookup::HieraConfigV4
@api private
Public Class Methods
config_type()
click to toggle source
# File lib/puppet/pops/lookup/hiera_config.rb 476 def self.config_type 477 return @@CONFIG_TYPE if class_variable_defined?(:@@CONFIG_TYPE) 478 tf = Types::TypeFactory 479 nes_t = Types::PStringType::NON_EMPTY 480 481 @@CONFIG_TYPE = tf.struct({ 482 KEY_VERSION => tf.range(4, 4), 483 tf.optional(KEY_DATADIR) => nes_t, 484 tf.optional(KEY_HIERARCHY) => tf.array_of(tf.struct( 485 KEY_BACKEND => nes_t, 486 KEY_NAME => nes_t, 487 tf.optional(KEY_DATADIR) => nes_t, 488 tf.optional(KEY_PATH) => nes_t, 489 tf.optional(KEY_PATHS) => tf.array_of(nes_t) 490 )) 491 }) 492 end
Public Instance Methods
create_configured_data_providers(lookup_invocation, parent_data_provider, _)
click to toggle source
# File lib/puppet/pops/lookup/hiera_config.rb 494 def create_configured_data_providers(lookup_invocation, parent_data_provider, _) 495 default_datadir = @config[KEY_DATADIR] 496 data_providers = {} 497 498 @config[KEY_HIERARCHY].each do |he| 499 name = he[KEY_NAME] 500 if data_providers.include?(name) 501 first_line = find_line_matching(/\s+name:\s+['"]?#{name}(?:[^\w]|$)/) 502 line = find_line_matching(/\s+name:\s+['"]?#{name}(?:[^\w]|$)/, first_line + 1) if first_line 503 unless line 504 line = first_line 505 first_line = nil 506 end 507 fail(Issues::HIERA_HIERARCHY_NAME_MULTIPLY_DEFINED, { :name => name, :first_line => first_line }, line) 508 end 509 original_paths = he[KEY_PATHS] || [he[KEY_PATH] || name] 510 datadir = @config_root + (he[KEY_DATADIR] || default_datadir) 511 provider_name = he[KEY_BACKEND] 512 data_providers[name] = case 513 when provider_name == 'json', provider_name == 'yaml' 514 create_data_provider(name, parent_data_provider, KEY_DATA_HASH, "#{provider_name}_data", {}, 515 resolve_paths(datadir, original_paths, lookup_invocation, @config_path.nil?, ".#{provider_name}")) 516 when provider_name == 'hocon' && Puppet.features.hocon? 517 create_data_provider(name, parent_data_provider, KEY_DATA_HASH, 'hocon_data', {}, 518 resolve_paths(datadir, original_paths, lookup_invocation, @config_path.nil?, '.conf')) 519 else 520 fail(Issues::HIERA_NO_PROVIDER_FOR_BACKEND, { :name => provider_name }, find_line_matching(/[^\w]#{provider_name}(?:[^\w]|$)/)) 521 end 522 end 523 data_providers.values 524 end
validate_config(config, owner)
click to toggle source
# File lib/puppet/pops/lookup/hiera_config.rb 526 def validate_config(config, owner) 527 unless Puppet[:strict] == :off 528 Puppet.warn_once('deprecations', 'hiera.yaml', 529 _("%{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) 530 end 531 config[KEY_DATADIR] ||= 'data' 532 config[KEY_HIERARCHY] ||= [{ KEY_NAME => 'common', KEY_BACKEND => 'yaml' }] 533 Types::TypeAsserter.assert_instance_of(["The Lookup Configuration at '%s'", @config_path], self.class.config_type, config) 534 end
version()
click to toggle source
# File lib/puppet/pops/lookup/hiera_config.rb 536 def version 537 4 538 end