Class: Kuby::Docker::LocalTags

Inherits:
Object
  • Object
show all
Defined in:
lib/kuby/docker/local_tags.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cli, metadata) ⇒ LocalTags

Returns a new instance of LocalTags.



6
7
8
9
# File 'lib/kuby/docker/local_tags.rb', line 6

def initialize(cli, )
  @cli = cli
  @metadata = 
end

Instance Attribute Details

#cliObject (readonly)

Returns the value of attribute cli.



4
5
6
# File 'lib/kuby/docker/local_tags.rb', line 4

def cli
  @cli
end

#metadataObject (readonly)

Returns the value of attribute metadata.



4
5
6
# File 'lib/kuby/docker/local_tags.rb', line 4

def 
  @metadata
end

Instance Method Details

#latest_tagsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kuby/docker/local_tags.rb', line 16

def latest_tags
  # find "latest" tag
  images = cli.images(.image_url)
  latest = images.find { |image| image[:tag] == Tags::LATEST }

  unless latest
    raise MissingTagError.new(Tags::LATEST)
  end

  # find all tags that point to the same image as 'latest'
  images.each_with_object([]) do |image_data, tags|
    if image_data[:id] == latest[:id]
      tags << image_data[:tag]
    end
  end
end

#tagsObject



11
12
13
14
# File 'lib/kuby/docker/local_tags.rb', line 11

def tags
  images = cli.images(.image_url)
  images.map { |image| image[:tag] }
end

#timestamp_tagsObject



33
34
35
# File 'lib/kuby/docker/local_tags.rb', line 33

def timestamp_tags
  tags.map { |t| TimestampTag.try_parse(t) }.compact
end