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/shell-local.rb

Defined Under Namespace

Classes: Compress, DockerImport, DockerPush, DockerSave, DockerTag, 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'
VALID_POST_PROCESSOR_TYPES =
[
  DOCKER_IMPORT,
  DOCKER_PUSH,
  DOCKER_SAVE,
  DOCKER_TAG,
  COMPRESS,
  VAGRANT,
  SHELL_LOCAL
]

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.



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

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

Class Method Details

.get_postprocessor(type) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/packer/postprocessor.rb', line 28

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
  }.fetch(type).new
end

.typesObject



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

def self.types
  VALID_POST_PROCESSOR_TYPES
end

Instance Method Details

#except(buildname) ⇒ Object



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

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

#keep_input_artifact(bool) ⇒ Object



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

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

#only(buildname) ⇒ Object



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

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