Sha256: 83bf33ad05dfc31efb07b919a6d1d3e94a11ccd3a8c760d6f1ac92598d224df4

Contents?: true

Size: 1008 Bytes

Versions: 3

Compression:

Stored size: 1008 Bytes

Contents

# frozen_string_literal: true

module Facter
  class ExternalFactLoader
    def custom_facts
      @custom_facts = load_custom_facts
    end

    def external_facts
      @external_facts = load_external_facts
    end

    private

    def load_custom_facts
      custom_facts = []

      custom_facts_to_load = LegacyFacter.collection.custom_facts

      custom_facts_to_load&.each do |k, v|
        loaded_fact = LoadedFact.new(k.to_s, nil, :custom)
        loaded_fact.is_env = v.options[:is_env] if v.options[:is_env]
        custom_facts << loaded_fact
      end

      custom_facts
    end

    def load_external_facts
      external_facts = []

      external_facts_to_load = LegacyFacter.collection.external_facts

      external_facts_to_load&.each do |k, v|
        loaded_fact = LoadedFact.new(k.to_s, nil, :external)
        loaded_fact.file = v.options[:file]
        loaded_fact.is_env = v.options[:is_env]
        external_facts << loaded_fact
      end

      external_facts
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facter-4.0.52 lib/facter/framework/core/fact_loaders/external_fact_loader.rb
facter-4.0.51 lib/facter/framework/core/fact_loaders/external_fact_loader.rb
facter-4.0.50 lib/facter/framework/core/fact_loaders/external_fact_loader.rb