Sha256: cd03e9bea09e438359c940b9d663354ba8df473f270f3d2d3c1dfa0f79788d92

Contents?: true

Size: 840 Bytes

Versions: 6

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

module Facter
  class BlockList
    include Singleton

    attr_reader :block_groups, :block_list

    def initialize(block_list_path = nil)
      @block_groups_file_path = block_list_path || File.join(ROOT_DIR, 'block_groups.conf')
      load_block_groups
    end

    # Breakes down blocked groups in blocked facts
    def blocked_facts
      fact_list = []

      @block_list.each do |group_name|
        facts_for_block = @block_groups[group_name]

        fact_list += facts_for_block || [group_name]
      end

      fact_list
    end

    private

    def load_block_groups
      @block_groups = File.readable?(@block_groups_file_path) ? Hocon.load(@block_groups_file_path) : {}
      options = Options.instance
      @block_list = ConfigReader.new(options[:config]).block_list || {}
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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