Class: PackerExecutor
- Inherits:
-
Object
- Object
- PackerExecutor
- Defined in:
- lib/executor.rb
Overview
executes packer commands against template object
Instance Method Summary collapse
- #build ⇒ Object
-
#build_options ⇒ Object
specify the builders if any were passed.
-
#initialize(template, builders) ⇒ PackerExecutor
constructor
A new instance of PackerExecutor.
-
#list ⇒ Object
print out the builders for this template.
Constructor Details
#initialize(template, builders) ⇒ PackerExecutor
Returns a new instance of PackerExecutor.
21 22 23 24 25 26 |
# File 'lib/executor.rb', line 21 def initialize(template, builders) @template = template @file_path = template.path @template_builders = template.builders @specified_builders = builders end |
Instance Method Details
#build ⇒ Object
47 48 49 50 51 52 |
# File 'lib/executor.rb', line 47 def build puts "Building #{File.basename(@file_path, '.json')}:".to_green IO.popen("packer build #{} #{@file_path}") do |cmd| cmd.each { |line| puts line } end end |
#build_options ⇒ Object
specify the builders if any were passed
43 44 45 |
# File 'lib/executor.rb', line 43 def "-only=#{@specified_builders.join(',')}" unless @specified_builders.empty? end |
#list ⇒ Object
print out the builders for this template
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/executor.rb', line 29 def list puts File.basename(@file_path, '.json') + ':' builders = @template.builders_hash if builders.empty? puts '- No builders found'.indent.to_red else builders.each_pair do |name, type| puts "- #{name} (type: #{type})".indent end end end |