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.



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

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.



20
21
22
# File 'lib/avm/docker/image.rb', line 20

def registry
  @registry
end

#snapshotObject

Returns the value of attribute snapshot.



21
22
23
# File 'lib/avm/docker/image.rb', line 21

def snapshot
  @snapshot
end

#versionObject

Returns the value of attribute version.



21
22
23
# File 'lib/avm/docker/image.rb', line 21

def version
  @version
end

Class Method Details

.default_registryEacDocker::Registry

Returns:

  • (EacDocker::Registry)


15
16
17
# File 'lib/avm/docker/image.rb', line 15

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

Instance Method Details

#build(extra_args = []) ⇒ Object



30
31
32
33
34
# File 'lib/avm/docker/image.rb', line 30

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

  provide
end

#generator_versionObject



36
37
38
# File 'lib/avm/docker/image.rb', line 36

def generator_version
  ::Avm::VERSION
end

#pushObject



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

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

#run(instance) ⇒ Object



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

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

#tagObject



48
49
50
51
52
# File 'lib/avm/docker/image.rb', line 48

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

#tag_nameObject



54
55
56
57
58
# File 'lib/avm/docker/image.rb', line 54

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

  raise 'Registry name is blank'
end

#tag_versionObject



60
61
62
# File 'lib/avm/docker/image.rb', line 60

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

#tag_version_versionObject



64
65
66
67
68
69
70
# File 'lib/avm/docker/image.rb', line 64

def tag_version_version
  return nil unless version

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