Class: OctocatalogDiff::Facts::JSON

Inherits:
Object
  • Object
show all
Defined in:
lib/octocatalog-diff/facts/json.rb

Overview

Deal with facts in JSON files

Class Method Summary collapse

Class Method Details

.fact_retriever(options = {}, node = '') ⇒ Hash

Returns Facts.

Parameters:

  • options (Hash) (defaults to: {})

    Options hash specifically for this fact type.

    • :fact_file_string [String] => Fact data as a string

  • node (String) (defaults to: '')

    Node name (overrides node name from fact data)

Returns:

  • (Hash)

    Facts



15
16
17
18
19
# File 'lib/octocatalog-diff/facts/json.rb', line 15

def self.fact_retriever(options = {}, node = '')
  facts = ::JSON.parse(options.fetch(:fact_file_string))
  node = facts.fetch('fqdn', 'unknown.node') if node.empty?
  { 'name' => node, 'values' => facts }
end