Class: Kuby::Docker::LocalTags

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
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.



21
22
23
24
25
26
# File 'lib/kuby/docker/local_tags.rb', line 21

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

  @latest_timestamp_tag = T.let(@latest_timestamp_tag, T.nilable(TimestampTag))
end

Instance Attribute Details

#cliObject (readonly)

Returns the value of attribute cli.



9
10
11
# File 'lib/kuby/docker/local_tags.rb', line 9

def cli
  @cli
end

#metadataObject (readonly)

Returns the value of attribute metadata.



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

def 
  @metadata
end

Instance Method Details

#latest_tagsObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/kuby/docker/local_tags.rb', line 35

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

#latest_timestamp_tagObject



58
59
60
# File 'lib/kuby/docker/local_tags.rb', line 58

def latest_timestamp_tag
  @latest_timestamp_tag ||= timestamp_tags.sort.last
end

#tagsObject



29
30
31
32
# File 'lib/kuby/docker/local_tags.rb', line 29

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

#timestamp_tagsObject



53
54
55
# File 'lib/kuby/docker/local_tags.rb', line 53

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