Class: Packer::PostProcessor

Inherits:
DataObject show all
Defined in:
lib/packer/postprocessor.rb,
lib/packer/postprocessors/docker.rb,
lib/packer/postprocessors/vagrant.rb

Direct Known Subclasses

DockerImport, DockerPush, DockerSave, DockerTag, Vagrant

Defined Under Namespace

Classes: DockerImport, DockerPush, DockerSave, DockerTag, UnrecognizedPostProcessorTypeError, Vagrant

Constant Summary collapse

DOCKER_IMPORT =
'docker-import'
DOCKER_PUSH =
'docker-push'
DOCKER_SAVE =
'docker-save'
DOCKER_TAG =
'docker-tag'
VAGRANT =
'vagrant'
VALID_POST_PROCESSOR_TYPES =
[
  DOCKER_IMPORT,
  DOCKER_PUSH,
  DOCKER_SAVE,
  DOCKER_TAG,
  VAGRANT
]

Instance Attribute Summary

Attributes inherited from DataObject

#data, #key_dependencies, #required

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DataObject

#__add_array_of_array_of_strings, #__add_array_of_hashes, #__add_array_of_ints, #__add_array_of_strings, #__add_boolean, #__add_hash, #__add_integer, #__add_json, #__add_string, #__exclusive_key_error, #add_key_dependencies, #add_required, #deep_copy, #validate, #validate_key_dependencies, #validate_required

Constructor Details

#initializePostProcessor

Returns a new instance of PostProcessor.



41
42
43
44
# File 'lib/packer/postprocessor.rb', line 41

def initialize
  super
  self.add_required('type')
end

Class Method Details

.get_postprocessor(type) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/packer/postprocessor.rb', line 24

def self.get_postprocessor(type)
  unless validate_type(type)
    raise UnrecognizedPostProcessorTypeError.new("Unrecognized post-processor type #{type}")
  end
  {
    DOCKER_IMPORT => Packer::PostProcessor::DockerImport,
    DOCKER_PUSH   => Packer::PostProcessor::DockerPush,
    DOCKER_SAVE   => Packer::PostProcessor::DockerSave,
    DOCKER_TAG    => Packer::PostProcessor::DockerTag,
    VAGRANT       => Packer::PostProcessor::Vagrant
  }.fetch(type).new
end

.typesObject



37
38
39
# File 'lib/packer/postprocessor.rb', line 37

def self.types
  VALID_POST_PROCESSOR_TYPES
end

Instance Method Details

#except(buildname) ⇒ Object



53
54
55
56
57
58
# File 'lib/packer/postprocessor.rb', line 53

def except(buildname)
  unless self.data.key? 'except'
    self.data['except'] = []
  end
  self.data['except'] << buildname.to_s
end

#keep_input_artifact(bool) ⇒ Object



60
61
62
# File 'lib/packer/postprocessor.rb', line 60

def keep_input_artifact(bool)
  self.__add_boolean('keep_input_artifact', bool)
end

#only(buildname) ⇒ Object



46
47
48
49
50
51
# File 'lib/packer/postprocessor.rb', line 46

def only(buildname)
  unless self.data.key? 'only'
    self.data['only'] = []
  end
  self.data['only'] << buildname.to_s
end