Class: Kuby::Docker::Image
- Inherits:
-
Object
- Object
- Kuby::Docker::Image
- Defined in:
- lib/kuby/docker/image.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#alias_tags ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns T::Array }.
-
#credentials ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::Credentials) }.
-
#identifier ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }.
-
#image_url ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns(String) }.
-
#main_tag ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }.
-
#registry_index_url ⇒ Object
readonly
T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }.
Instance Method Summary collapse
-
#build(build_args = {}, docker_args = [], context: nil, cache_from: nil) ⇒ Object
T::Sig::WithoutRuntime.sig { params( build_args: T::Hash[String, String], docker_args: T::Array, context: T.nilable(String), cache_from: T.nilable(String) ).void }.
-
#current_version ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::Image) }.
-
#docker_cli ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::CLI) }.
-
#dockerfile ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::Dockerfile) }.
-
#image_host ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }.
-
#image_hostname ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }.
-
#image_repo ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }.
-
#image_uri ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::DockerURI) }.
-
#initialize(dockerfile, image_url, credentials, registry_index_url = nil, main_tag = nil, alias_tags = []) ⇒ Image
constructor
T::Sig::WithoutRuntime.sig { params( dockerfile: T.any(Dockerfile, T.proc.returns(Kuby::Docker::Dockerfile)), image_url: String, credentials: Kuby::Docker::Credentials, registry_index_url: T.nilable(String), main_tag: T.nilable(String), alias_tags: T::Array ).void }.
-
#new_version ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::Image) }.
-
#previous_version(current_tag = nil) ⇒ Object
T::Sig::WithoutRuntime.sig { params(current_tag: T.nilable(String)).returns(Image) }.
-
#pull(tag) ⇒ Object
T::Sig::WithoutRuntime.sig { params(tag: String).void }.
-
#push(tag) ⇒ Object
T::Sig::WithoutRuntime.sig { params(tag: String).void }.
-
#registry_index_host ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }.
-
#registry_index_hostname ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }.
-
#registry_index_uri ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::DockerURI) }.
-
#tags ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Array) }.
Constructor Details
#initialize(dockerfile, image_url, credentials, registry_index_url = nil, main_tag = nil, alias_tags = []) ⇒ Image
T::Sig::WithoutRuntime.sig
params(
dockerfile: T.any(Dockerfile, T.proc.returns(Kuby::Docker::Dockerfile)),
image_url: String,
credentials: Kuby::Docker::Credentials,
registry_index_url: T.nilable(String),
main_tag: T.nilable(String),
alias_tags: T::Array[String]
).void
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/kuby/docker/image.rb', line 36 def initialize(dockerfile, image_url, credentials, registry_index_url = nil, main_tag = nil, = []) @dockerfile = dockerfile @image_url = image_url @registry_index_url = registry_index_url @credentials = credentials @main_tag = main_tag @alias_tags = # @identifier = T.let(@identifier, T.nilable(String)) # @image_host = T.let(@image_host, T.nilable(String)) # @image_hostname = T.let(@image_hostname, T.nilable(String)) # @registry_index_host = T.let(@registry_index_host, T.nilable(String)) # @registry_index_hostname = T.let(@registry_index_hostname, T.nilable(String)) # @registry_index_uri = T.let(@registry_index_uri, T.nilable(DockerURI)) # @image_repo = T.let(@image_repo, T.nilable(String)) # @full_image_uri = T.let(@full_image_uri, T.nilable(DockerURI)) # @docker_cli = T.let(@docker_cli, T.nilable(Docker::CLI)) end |
Instance Attribute Details
#alias_tags ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns T::Array }
24 25 26 |
# File 'lib/kuby/docker/image.rb', line 24 def @alias_tags end |
#credentials ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::Credentials) }
18 19 20 |
# File 'lib/kuby/docker/image.rb', line 18 def credentials @credentials end |
#identifier ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }
9 10 11 |
# File 'lib/kuby/docker/image.rb', line 9 def identifier @identifier end |
#image_url ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns(String) }
12 13 14 |
# File 'lib/kuby/docker/image.rb', line 12 def image_url @image_url end |
#main_tag ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }
21 22 23 |
# File 'lib/kuby/docker/image.rb', line 21 def main_tag @main_tag end |
#registry_index_url ⇒ Object (readonly)
T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }
15 16 17 |
# File 'lib/kuby/docker/image.rb', line 15 def registry_index_url @registry_index_url end |
Instance Method Details
#build(build_args = {}, docker_args = [], context: nil, cache_from: nil) ⇒ Object
T::Sig::WithoutRuntime.sig
params(
build_args: T::Hash[String, String],
docker_args: T::Array[String],
context: T.nilable(String),
cache_from: T.nilable(String)
).void
127 128 129 |
# File 'lib/kuby/docker/image.rb', line 127 def build(build_args = {}, docker_args = [], context: nil, cache_from: nil) raise NotImplementedError, 'please use a Docker::Image subclass' end |
#current_version ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::Image) }
61 62 63 |
# File 'lib/kuby/docker/image.rb', line 61 def current_version raise NotImplementedError, 'please use a Docker::Image subclass' end |
#docker_cli ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::CLI) }
142 143 144 |
# File 'lib/kuby/docker/image.rb', line 142 def docker_cli @docker_cli ||= Docker::CLI.new end |
#dockerfile ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::Dockerfile) }
71 72 73 74 75 76 77 |
# File 'lib/kuby/docker/image.rb', line 71 def dockerfile if @dockerfile.respond_to?(:call) @dockerfile.call else @dockerfile end end |
#image_host ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }
80 81 82 |
# File 'lib/kuby/docker/image.rb', line 80 def image_host @image_host ||= "#{image_uri.host}:#{image_uri.port}" end |
#image_hostname ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }
95 96 97 |
# File 'lib/kuby/docker/image.rb', line 95 def image_hostname @image_hostname ||= image_uri.host end |
#image_repo ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }
100 101 102 |
# File 'lib/kuby/docker/image.rb', line 100 def image_repo @image_repo ||= image_uri.path end |
#image_uri ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::DockerURI) }
105 106 107 |
# File 'lib/kuby/docker/image.rb', line 105 def image_uri @full_image_uri ||= DockerURI.parse_uri(image_url) end |
#new_version ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::Image) }
56 57 58 |
# File 'lib/kuby/docker/image.rb', line 56 def new_version raise NotImplementedError, 'please use a Docker::Image subclass' end |
#previous_version(current_tag = nil) ⇒ Object
T::Sig::WithoutRuntime.sig { params(current_tag: T.nilable(String)).returns(Image) }
66 67 68 |
# File 'lib/kuby/docker/image.rb', line 66 def previous_version(current_tag = nil) raise NotImplementedError, 'please use a Docker::Image subclass' end |
#pull(tag) ⇒ Object
T::Sig::WithoutRuntime.sig { params(tag: String).void }
137 138 139 |
# File 'lib/kuby/docker/image.rb', line 137 def pull(tag) raise NotImplementedError, 'please use a Docker::Image subclass' end |
#push(tag) ⇒ Object
T::Sig::WithoutRuntime.sig { params(tag: String).void }
132 133 134 |
# File 'lib/kuby/docker/image.rb', line 132 def push(tag) raise NotImplementedError, 'please use a Docker::Image subclass' end |
#registry_index_host ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }
85 86 87 |
# File 'lib/kuby/docker/image.rb', line 85 def registry_index_host @registry_index_host ||= "#{registry_index_uri.host}:#{registry_index_uri.port}" end |
#registry_index_hostname ⇒ Object
T::Sig::WithoutRuntime.sig { returns(String) }
90 91 92 |
# File 'lib/kuby/docker/image.rb', line 90 def registry_index_hostname @registry_index_hostname ||= registry_index_uri.host end |
#registry_index_uri ⇒ Object
T::Sig::WithoutRuntime.sig { returns(Kuby::Docker::DockerURI) }
110 111 112 |
# File 'lib/kuby/docker/image.rb', line 110 def registry_index_uri @registry_index_uri ||= DockerURI.parse_index_uri(registry_index_url || image_url) end |
#tags ⇒ Object
T::Sig::WithoutRuntime.sig { returns(T::Array) }
115 116 117 |
# File 'lib/kuby/docker/image.rb', line 115 def [main_tag, *].compact end |