Sha256: bc600ec81771cb2a7b828876c09ecc649f8f5fed6bcc12e4514c25858495b117
Contents?: true
Size: 1.72 KB
Versions: 5
Compression:
Stored size: 1.72 KB
Contents
# typed: strict module Kuby module Docker class LocalTags # extend T::Sig # T::Sig::WithoutRuntime.sig { returns Kuby::Docker::CLI } attr_reader :cli # T::Sig::WithoutRuntime.sig { returns(String) } attr_reader :image_url # T::Sig::WithoutRuntime.sig { # params( # cli: Kuby::Docker::CLI, # image_url: String # ) # .void # } def initialize(cli, image_url) @cli = cli @image_url = image_url # @latest_timestamp_tag = T.let(@latest_timestamp_tag, T.nilable(TimestampTag)) end # T::Sig::WithoutRuntime.sig { returns(T::Array[String]) } def tags images = cli.images(image_url) images.map { |image| image[:tag] } end # T::Sig::WithoutRuntime.sig { returns(T::Array[String]) } def latest_tags # 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, tags| if image_data[:id] == latest[:id] tags << image_data[:tag] end end end # T::Sig::WithoutRuntime.sig { returns(T::Array[Kuby::Docker::TimestampTag]) } def timestamp_tags tags.map { |t| TimestampTag.try_parse(t) }.compact end # T::Sig::WithoutRuntime.sig { returns(T.nilable(Kuby::Docker::TimestampTag)) } def latest_timestamp_tag @latest_timestamp_tag ||= timestamp_tags.sort.last end end end end
Version data entries
5 entries across 5 versions & 1 rubygems