Class: Avm::Docker::Image

Inherits:
EacDocker::Images::Templatized
  • Object
show all
Includes:
Entries::Jobs::WithVariablesSource
Defined in:
lib/avm/docker/image.rb

Direct Known Subclasses

Instances::DockerImage, Self::DockerImage

Constant Summary collapse

DEFAULT_REGISTRY_NAME =
'local'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Entries::Jobs::WithVariablesSource

#variables_source

Constructor Details

#initialize(registry = nil) ⇒ Image

Returns a new instance of Image.



26
27
28
29
30
31
# File 'lib/avm/docker/image.rb', line 26

def initialize(registry = nil)
  super()
  @registry = registry || self.class.default_registry
  self.snapshot = true
  self.version = true
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



23
24
25
# File 'lib/avm/docker/image.rb', line 23

def registry
  @registry
end

#snapshotObject

Returns the value of attribute snapshot.



24
25
26
# File 'lib/avm/docker/image.rb', line 24

def snapshot
  @snapshot
end

#versionObject

Returns the value of attribute version.



24
25
26
# File 'lib/avm/docker/image.rb', line 24

def version
  @version
end

Class Method Details

.default_registryEacDocker::Registry

Returns:

  • (EacDocker::Registry)


18
19
20
# File 'lib/avm/docker/image.rb', line 18

def default_registry
  ::EacDocker::Registry.new(DEFAULT_REGISTRY_NAME)
end

Instance Method Details

#build(extra_args = []) ⇒ Object



33
34
35
36
37
# File 'lib/avm/docker/image.rb', line 33

def build(extra_args = [])
  nyi "Extra args: #{extra_args}" if extra_args.any?

  provide
end

#generator_versionObject



39
40
41
# File 'lib/avm/docker/image.rb', line 39

def generator_version
  ::Avm::VERSION
end

#pushObject



43
44
45
# File 'lib/avm/docker/image.rb', line 43

def push
  ::EacDocker::Executables.docker.command.append(['push', tag]).system!
end

#run(instance) ⇒ Object



47
48
49
# File 'lib/avm/docker/image.rb', line 47

def run(instance)
  run_run(instance) if container_exist?(instance)
end

#tagObject



51
52
53
54
55
# File 'lib/avm/docker/image.rb', line 51

def tag
  r = tag_name
  r += ":#{tag_version}" if tag_version.present?
  r
end

#tag_nameObject



57
58
59
60
61
# File 'lib/avm/docker/image.rb', line 57

def tag_name
  return registry.name if registry.name.present?

  raise 'Registry name is blank'
end

#tag_versionObject



63
64
65
# File 'lib/avm/docker/image.rb', line 63

def tag_version
  [tag_version_version, stereotype_tag].compact_blank.join('_')
end

#tag_version_versionObject



67
68
69
70
71
72
73
# File 'lib/avm/docker/image.rb', line 67

def tag_version_version
  return nil unless version

  r = generator_version
  r += '-snapshot' if snapshot
  r
end