Sha256: 9c847b5a60fd71823357f32024fbbf716c64831c7fe358a74bb2ba2aacf933c7

Contents?: true

Size: 1.01 KB

Versions: 27

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Facter
  class ConfigReader
    class << self
      attr_accessor :conf

      def init(config_path = nil)
        config_path ||= default_path
        refresh_config(config_path)
        self
      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 fact_groups
        @conf['fact-groups']
      end

      def refresh_config(config_path)
        @conf = File.readable?(config_path) ? Hocon.load(config_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
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
facter-4.0.49 lib/facter/framework/config/config_reader.rb
facter-4.0.48 lib/facter/framework/config/config_reader.rb
facter-4.0.47 lib/facter/framework/config/config_reader.rb
facter-4.0.46 lib/facter/framework/config/config_reader.rb
facter-4.0.44 lib/facter/framework/config/config_reader.rb
facter-4.0.43 lib/facter/framework/config/config_reader.rb
facter-4.0.42 lib/facter/framework/config/config_reader.rb
facter-4.0.41 lib/facter/framework/config/config_reader.rb
facter-4.0.40 lib/facter/framework/config/config_reader.rb
facter-4.0.39 lib/facter/framework/config/config_reader.rb
facter-4.0.38 lib/facter/framework/config/config_reader.rb
facter-4.0.37 lib/facter/framework/config/config_reader.rb
facter-4.0.36 lib/facter/framework/config/config_reader.rb
facter-4.0.35 lib/facter/framework/config/config_reader.rb
facter-4.0.34 lib/facter/framework/config/config_reader.rb
facter-4.0.33 lib/facter/framework/config/config_reader.rb
facter-4.0.32 lib/facter/framework/config/config_reader.rb
facter-4.0.31 lib/facter/framework/config/config_reader.rb
facter-4.0.30 lib/facter/framework/config/config_reader.rb
facter-4.0.29 lib/framework/config/config_reader.rb