Class: OpenStax::Aws::PackerFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/openstax/aws/packer_factory.rb

Class Method Summary collapse

Class Method Details

.new_packer(absolute_file_path:, dry_run: true) ⇒ Object

There are differences between Packer 1.2 and 1.4. This factory attempts to provide the right version of packer class.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/openstax/aws/packer_factory.rb', line 7

def self.new_packer(absolute_file_path:, dry_run: true)
  packer_version = `packer --version`

  raise "packer is not installed" if packer_version.nil?

  packer_class =
    case packer_version
    when /^1.2/
      Packer_1_2_5
    else
      Packer_1_4_1
    end

  @packer = packer_class.new(absolute_file_path: absolute_file_path,
                             dry_run: dry_run)
end