Class: OctocatalogDiff::Facts::JSON
- Inherits:
-
Object
- Object
- OctocatalogDiff::Facts::JSON
- 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.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/octocatalog-diff/facts/json.rb', line 15 def self.fact_retriever( = {}, node = '') facts = ::JSON.parse(.fetch(:fact_file_string)) if facts.keys.include?('name') && facts.keys.include?('values') && facts['values'].is_a?(Hash) # If you saved the output of something like # `puppet facts find $(hostname)` the structure will already be a # {'name' => <fqdn>, 'values' => <hash of facts>}. We do nothing # here because we don't want to double-encode. else facts = { 'name' => node, 'values' => facts } end facts['name'] = node unless node.empty? facts['name'] = facts['values'].fetch('fqdn', 'unknown.node') if facts['name'].empty? facts end |