Class: Kuby::Docker::LocalTags
- Inherits:
-
Object
- Object
- Kuby::Docker::LocalTags
- Extended by:
- T::Sig
- Defined in:
- lib/kuby/docker/local_tags.rb
Instance Attribute Summary collapse
-
#cli ⇒ Object
readonly
Returns the value of attribute cli.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#initialize(cli, metadata) ⇒ LocalTags
constructor
A new instance of LocalTags.
- #latest_tags ⇒ Object
- #latest_timestamp_tag ⇒ Object
- #tags ⇒ Object
- #timestamp_tags ⇒ Object
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
#cli ⇒ Object (readonly)
Returns the value of attribute cli.
9 10 11 |
# File 'lib/kuby/docker/local_tags.rb', line 9 def cli @cli end |
#metadata ⇒ Object (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_tags ⇒ Object
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 # 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, | if image_data[:id] == latest[:id] << image_data[:tag] end end end |
#latest_timestamp_tag ⇒ Object
58 59 60 |
# File 'lib/kuby/docker/local_tags.rb', line 58 def @latest_timestamp_tag ||= .sort.last end |
#tags ⇒ Object
29 30 31 32 |
# File 'lib/kuby/docker/local_tags.rb', line 29 def images = cli.images(.image_url) images.map { |image| T.must(image[:tag]) } end |
#timestamp_tags ⇒ Object
53 54 55 |
# File 'lib/kuby/docker/local_tags.rb', line 53 def .map { |t| TimestampTag.try_parse(t) }.compact end |