Class: OctocatalogDiff::Catalog::Computed
- Inherits:
-
Object
- Object
- OctocatalogDiff::Catalog::Computed
- Defined in:
- lib/octocatalog-diff/catalog/computed.rb
Overview
Represents a Puppet catalog that is computed (via ‘puppet master –compile …`) By instantiating this class, the catalog is computed.
Instance Attribute Summary collapse
-
#catalog ⇒ Object
readonly
Returns the value of attribute catalog.
-
#catalog_json ⇒ Object
readonly
Returns the value of attribute catalog_json.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#retries ⇒ Object
readonly
Returns the value of attribute retries.
Instance Method Summary collapse
-
#build(logger = Logger.new(StringIO.new)) ⇒ Object
Actually build the catalog (populate @error_message, @catalog, @catalog_json).
-
#compilation_dir ⇒ String
Compilation directory.
-
#environment ⇒ Object
Environment used to compile catalog.
-
#initialize(options) ⇒ Computed
constructor
Constructor.
-
#puppet_version ⇒ String
Get the Puppet version.
Constructor Details
#initialize(options) ⇒ Computed
Constructor
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 30 def initialize() raise ArgumentError, 'Usage: OctocatalogDiff::Catalog::Computed.initialize(options_hash)' unless .is_a?(Hash) raise ArgumentError, 'Node name must be passed to OctocatalogDiff::Catalog::Computed' unless [:node].is_a?(String) # Standard readable variables @node = [:node] @error_message = nil @catalog = nil @catalog_json = nil # Additional class variables @pass_env_vars = .fetch(:pass_env_vars, []) @retry_failed_catalog = .fetch(:retry_failed_catalog, 0) @tag = .fetch(:tag, 'catalog') @puppet_binary = [:puppet_binary] @puppet_version = [:puppet_version] @puppet_command = [:puppet_command] @retries = nil @builddir = nil @facts_terminus = .fetch(:facts_terminus, 'yaml') # Pass through the input for other access @opts = raise ArgumentError, 'Branch is undefined' unless @opts[:branch] end |
Instance Attribute Details
#catalog ⇒ Object (readonly)
Returns the value of attribute catalog.
19 20 21 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 19 def catalog @catalog end |
#catalog_json ⇒ Object (readonly)
Returns the value of attribute catalog_json.
19 20 21 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 19 def catalog_json @catalog_json end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
19 20 21 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 19 def @error_message end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
19 20 21 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 19 def node @node end |
#retries ⇒ Object (readonly)
Returns the value of attribute retries.
19 20 21 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 19 def retries @retries end |
Instance Method Details
#build(logger = Logger.new(StringIO.new)) ⇒ Object
Actually build the catalog (populate @error_message, @catalog, @catalog_json)
57 58 59 60 61 62 63 64 65 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 57 def build(logger = Logger.new(StringIO.new)) if @facts_terminus != 'facter' facts_obj = OctocatalogDiff::CatalogUtil::Facts.new(@opts, logger) logger.debug "Start retrieving facts for #{@node} from #{self.class}" @opts[:facts] = facts_obj.facts logger.debug "Success retrieving facts for #{@node} from #{self.class}" end build_catalog(logger) end |
#compilation_dir ⇒ String
Compilation directory
76 77 78 79 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 76 def compilation_dir raise 'Catalog was not built' if @builddir.nil? @builddir.tempdir end |
#environment ⇒ Object
Environment used to compile catalog
82 83 84 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 82 def environment @opts.fetch(:environment, 'production') end |
#puppet_version ⇒ String
Get the Puppet version
69 70 71 72 |
# File 'lib/octocatalog-diff/catalog/computed.rb', line 69 def puppet_version raise ArgumentError, '"puppet_binary" was not passed to OctocatalogDiff::Catalog::Computed' unless @puppet_binary @puppet_version ||= OctocatalogDiff::Util::PuppetVersion.puppet_version(@puppet_binary, @opts) end |