403Webshell
Server IP : 66.29.132.122  /  Your IP : 18.191.205.99
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera/config.rb
class Hiera::Config
  class << self
    ##
    # load takes a string or hash as input, strings are treated as filenames
    # hashes are stored as data that would have been in the config file
    #
    # Unless specified it will only use YAML as backend with a
    # hierarchy of 'nodes/%{::trusted.certname}' and 'common', and with a
    # console logger.
    #
    # @return [Hash] representing the configuration.
    def load(source)
      @config = {:backends => ["yaml"],
                 :hierarchy => ["nodes/%{::trusted.certname}", "common"],
                 :merge_behavior => :native }

      if source.is_a?(String)
        if File.exist?(source)
          config = begin
                     yaml_load_file(source)
                   rescue TypeError => detail
                     case detail.message
                     when /no implicit conversion from nil to integer/
                       false
                     else
                       raise detail
                     end
                   end
          if config
            version = config['version'] || config[:version] || 3
            if version >= 4
              raise "v#{version} hiera.yaml is only to be used inside an environment or a module and cannot be given to the global hiera"
            end
            @config.merge! config
          end
        else
          raise "Config file #{source} not found"
        end
      elsif source.is_a?(Hash)
        @config.merge! source
      end

      @config[:backends] = [ @config[:backends] ].flatten

      if @config.include?(:logger)
        Hiera.logger = @config[:logger].to_s
      else
        @config[:logger] = "console"
        Hiera.logger = "console"
      end

      self.validate!

      @config
    end

    def validate!
      case @config[:merge_behavior]
      when :deep,'deep',:deeper,'deeper'
        begin
          require "deep_merge"
          require "deep_merge/rails_compat"
        rescue LoadError
          raise Hiera::Error, "Must have 'deep_merge' gem installed for the configured merge_behavior."
        end
      end
    end

    ##
    # yaml_load_file directly delegates to YAML.load_file and is intended to be
    # a private, internal method suitable for stubbing and mocking.
    #
    # @return [Object] return value of {YAML.load_file}
    def yaml_load_file(source)
      YAML.load_file(source)
    end
    private :yaml_load_file

    def load_backends
      @config[:backends].each do |backend|
        begin
          require "hiera/backend/#{backend.downcase}_backend"
        rescue LoadError => e
          raise "Cannot load backend #{backend}: #{e}"
        end
      end
    end

    def include?(key)
      @config.include?(key)
    end

    def [](key)
      @config[key]
    end
  end
end

Youez - 2016 - github.com/yon3zu
LinuXploit