Sha256: 3b89799e4af714fb61d93a8bb99707608fa093a3f937c3e816729d54fe2460b8

Contents?: true

Size: 888 Bytes

Versions: 6

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

module Facter
  class ConfigReader
    attr_accessor :conf

    def initialize(config_path = nil)
      @config_file_path = config_path || default_path
      refresh_config
    end

    def block_list
      @conf['facts'] && @conf['facts']['blocklist']
    end

    def ttls
      @conf['facts'] && @conf['facts']['ttls']
    end

    def global
      @conf['global']
    end

    def cli
      @conf['cli']
    end

    def refresh_config
      @conf = File.readable?(@config_file_path) ? Hocon.load(@config_file_path) : {}
    end

    private

    def default_path
      os = OsDetector.instance.identifier

      windows_path = File.join('C:', 'ProgramData', 'PuppetLabs', 'facter', 'etc', 'facter.conf')
      linux_path = File.join('/', 'etc', 'puppetlabs', 'facter', 'facter.conf')

      os == :windows ? windows_path : linux_path
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
facter-4.0.15 lib/framework/config/config_reader.rb
facter-4.0.14 lib/framework/config/config_reader.rb
facter-4.0.13 lib/framework/config/config_reader.rb
facter-4.0.12 lib/framework/config/config_reader.rb
facter-4.0.11 lib/framework/config/config_reader.rb
facter-4.0.10.pre lib/framework/config/config_reader.rb