Class: Barbeque::DockerImage

Inherits:
Object
  • Object
show all
Defined in:
lib/barbeque/docker_image.rb

Constant Summary collapse

DEFAULT_TAG =
'latest'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ DockerImage

Returns a new instance of DockerImage.



5
6
7
8
9
10
11
# File 'lib/barbeque/docker_image.rb', line 5

def initialize(str)
  # See: https://github.com/docker/docker/blob/v1.10.2/image/spec/v1.md
  result = str.match(%r{((?<registry>[^/]+)?/)?(?<repository>[\w./-]+)(:(?<tag>[\w.-]+))?\z})
  @repository = result[:repository]
  @tag        = result[:tag] || DEFAULT_TAG
  @registry   = result[:registry] || ENV['BARBEQUE_DOCKER_REGISTRY']
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



13
14
15
# File 'lib/barbeque/docker_image.rb', line 13

def registry
  @registry
end

#repositoryObject (readonly)

Returns the value of attribute repository.



13
14
15
# File 'lib/barbeque/docker_image.rb', line 13

def repository
  @repository
end

#tagObject

Returns the value of attribute tag.



14
15
16
# File 'lib/barbeque/docker_image.rb', line 14

def tag
  @tag
end

Instance Method Details

#to_sObject



16
17
18
# File 'lib/barbeque/docker_image.rb', line 16

def to_s
  [registry, "#{repository}:#{tag}"].compact.join('/')
end