Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
Merge 7302a54 into 9933642
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanIrimie committed Apr 30, 2020
2 parents 9933642 + 7302a54 commit 1db5b17
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/framework/core/fact_loaders/internal_fact_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def legacy_facts
@facts.select { |fact| fact.type == :legacy }
end

def initialize
def initialize(os_descendents = nil)
@facts = []

os_descendents = OsDetector.instance.hierarchy
os_descendents ||= OsDetector.instance.hierarchy
load_all_oses_in_descending_order(os_descendents)
end

Expand Down
24 changes: 24 additions & 0 deletions tasks/fact_list_generator.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
desc 'Create a fact list for the specified os'
task :fact_list_generator, [:os_name] do |_, args|
ROOT_DIR = Pathname.new(File.expand_path('..', __dir__)) unless defined?(ROOT_DIR)

require "#{ROOT_DIR}/lib/framework/core/file_loader"
load_lib_dirs('facts', '**')

os_hierarchy = Facter::OsHierarchy.new
hierarchy = os_hierarchy.construct_hierarchy(args[:os_name])

internal_fact_loader = Facter::InternalFactLoader.new(hierarchy)
facts = internal_fact_loader.facts

fact_mapping = []
facts.each do |loaded_fact|
fact_hash = Hash.new
fact_hash[:name] = loaded_fact.name
fact_hash[:klass] = loaded_fact.klass
fact_hash[:type] = loaded_fact.type
fact_mapping << fact_hash
end

puts JSON.pretty_generate(fact_mapping)
end

0 comments on commit 1db5b17

Please sign in to comment.