Class: Packer::PostProcessor

Inherits:
DataObject show all
Defined in:
lib/packer/postprocessor.rb,
lib/packer/postprocessors/docker.rb,
lib/packer/postprocessors/vagrant.rb,
lib/packer/postprocessors/compress.rb,
lib/packer/postprocessors/manifest.rb,
lib/packer/postprocessors/shell-local.rb

Defined Under Namespace

Classes: Compress, DockerImport, DockerPush, DockerSave, DockerTag, Manifest, ShellLocal, UnrecognizedPostProcessorTypeError, Vagrant

Constant Summary collapse

DOCKER_IMPORT =
'docker-import'
DOCKER_PUSH =
'docker-push'
DOCKER_SAVE =
'docker-save'
DOCKER_TAG =
'docker-tag'
VAGRANT =
'vagrant'
COMPRESS =
'compress'
SHELL_LOCAL =
'shell-local'
MANIFEST =
'manifest'
VALID_POST_PROCESSOR_TYPES =
[
  DOCKER_IMPORT,
  DOCKER_PUSH,
  DOCKER_SAVE,
  DOCKER_TAG,
  COMPRESS,
  VAGRANT,
  SHELL_LOCAL,
  MANIFEST
]

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.


51
52
53
54
# File 'lib/packer/postprocessor.rb', line 51

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

Class Method Details

.get_postprocessor(type) ⇒ Object


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/packer/postprocessor.rb', line 30

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,
    COMPRESS      => Packer::PostProcessor::Compress,
    SHELL_LOCAL   => Packer::PostProcessor::ShellLocal,
    VAGRANT       => Packer::PostProcessor::Vagrant,
    MANIFEST      => Packer::PostProcessor::Manifest
  }.fetch(type).new
end

.typesObject


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

def self.types
  VALID_POST_PROCESSOR_TYPES
end

Instance Method Details

#except(buildname) ⇒ Object


63
64
65
66
67
68
# File 'lib/packer/postprocessor.rb', line 63

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

#keep_input_artifact(bool) ⇒ Object


70
71
72
# File 'lib/packer/postprocessor.rb', line 70

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

#only(buildname) ⇒ Object


56
57
58
59
60
61
# File 'lib/packer/postprocessor.rb', line 56

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