Sha256: d83bad807f884517988d9d1dda0627232c5834a26d9c89ddfd599bbd7ff27f25

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 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
      # puts @conf['global']
      @conf['global']
    end

    def cli
      @conf['cli']
    end

    def refresh_config
      @conf = File.exist?(@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

1 entries across 1 versions & 1 rubygems

Version Path
facter-4.0.7.pre lib/framework/config/config_reader.rb