Class: Kuby::Docker::LocalTags
- Inherits:
-
Object
- Object
- Kuby::Docker::LocalTags
- Defined in:
- lib/kuby/docker/local_tags.rb
Instance Attribute Summary collapse
-
#cli ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns Kuby::Docker::CLI }.
-
#image_url ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns(String) }.
Instance Method Summary collapse
-
#initialize(cli, image_url) ⇒ LocalTags
constructor
T::Sig::WithoutRuntime.sig { params( cli: Kuby::Docker::CLI, image_url: String ) .void }.
-
#latest_tags ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Array) }.
-
#latest_timestamp_tag ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T.nilable(Kuby::Docker::TimestampTag)) }.
-
#tags ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Array) }.
-
#timestamp_tags ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Array) }.
Constructor Details
#initialize(cli, image_url) ⇒ LocalTags
21 22 23 24 25 |
# File 'lib/kuby/docker/local_tags.rb', line 21 def initialize(cli, image_url) @cli = cli @image_url = image_url # @latest_timestamp_tag = T.let(@latest_timestamp_tag, T.nilable(TimestampTag)) end |
Instance Attribute Details
#cli ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns Kuby::Docker::CLI }
9 10 11 |
# File 'lib/kuby/docker/local_tags.rb', line 9 def cli @cli end |
#image_url ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns(String) }
12 13 14 |
# File 'lib/kuby/docker/local_tags.rb', line 12 def image_url @image_url end |
Instance Method Details
#latest_tags ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Array) }
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kuby/docker/local_tags.rb', line 34 def # find "latest" tag images = cli.images(image_url) latest = images.find { |image| image[:tag] == Kuby::Docker::LATEST_TAG } unless latest raise MissingTagError, "could not find tag #{Kuby::Docker::LATEST_TAG}" 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
T::Sig::WithoutRuntime.sig { returns(T.nilable(Kuby::Docker::TimestampTag)) }
57 58 59 |
# File 'lib/kuby/docker/local_tags.rb', line 57 def @latest_timestamp_tag ||= .sort.last end |
#tags ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Array) }
28 29 30 31 |
# File 'lib/kuby/docker/local_tags.rb', line 28 def images = cli.images(image_url) images.map { |image| image[:tag] } end |
#timestamp_tags ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Array) }
52 53 54 |
# File 'lib/kuby/docker/local_tags.rb', line 52 def .map { |t| TimestampTag.try_parse(t) }.compact end |