Class: OctocatalogDiff::CatalogUtil::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/octocatalog-diff/catalog-util/command.rb

Overview

Used to construct the command to run ‘puppet’ to construct the catalog.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, logger = nil) ⇒ Command

Constructor

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/octocatalog-diff/catalog-util/command.rb', line 12

def initialize(options = {}, logger = nil)
  @options = options
  @logger = logger

  # Required parameters
  @compilation_dir = options[:compilation_dir]
  raise ArgumentError, 'Compile dir (:compilation_dir) must be a string' unless @compilation_dir.is_a?(String)
  raise Errno::ENOENT, "Compile dir #{@compilation_dir} doesn't exist" unless File.exist?(@compilation_dir)
  raise ArgumentError, "Compile dir #{@compilation_dir} not a directory" unless File.directory?(@compilation_dir)

  @node = options[:node]
  raise ArgumentError, 'Node must be specified to compile catalog' if @node.nil? || !@node.is_a?(String)

  # To be initialized on-demand
  @puppet_argv = nil
  @puppet_binary = nil
end

Instance Method Details

#puppet_argvObject

Retrieve puppet_command, puppet_binary, puppet_argv



31
32
33
34
# File 'lib/octocatalog-diff/catalog-util/command.rb', line 31

def puppet_argv
  setup
  @puppet_argv
end

#puppet_binaryObject



36
37
38
39
# File 'lib/octocatalog-diff/catalog-util/command.rb', line 36

def puppet_binary
  setup
  @puppet_binary
end

#puppet_commandObject



41
42
43
44
# File 'lib/octocatalog-diff/catalog-util/command.rb', line 41

def puppet_command
  setup
  [@puppet_binary, @puppet_argv].flatten.join(' ')
end