Class: Kuby::Docker::Metadata
- Inherits:
-
Object
- Object
- Kuby::Docker::Metadata
- Extended by:
- T::Sig
- Defined in:
- lib/kuby/docker/metadata.rb
Constant Summary collapse
- DEFAULT_DISTRO =
:debian
- DEFAULT_REGISTRY_HOST =
T.let('https://www.docker.com'.freeze, String)
- DEFAULT_REGISTRY_SCHEME =
T.let('https', String)
- LATEST_TAG =
T.let('latest'.freeze, String)
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
- #image_url ⇒ Object
Instance Method Summary collapse
- #distro ⇒ Object
- #distro=(distro_name) ⇒ Object
- #image_host ⇒ Object
- #image_hostname ⇒ Object
- #image_repo ⇒ Object
-
#initialize(environment) ⇒ Metadata
constructor
A new instance of Metadata.
- #tags ⇒ Object
Constructor Details
#initialize(environment) ⇒ Metadata
Returns a new instance of Metadata.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/kuby/docker/metadata.rb', line 22 def initialize(environment) @environment = environment @tags = T.let([], T::Array[String]) @image_url = T.let(@image_url, T.nilable(String)) @image_host = T.let(@image_host, T.nilable(String)) @image_hostname = T.let(@image_hostname, T.nilable(String)) @image_repo = T.let(@image_repo, T.nilable(String)) @distro = T.let(@distro, T.nilable(Symbol)) @full_image_uri = T.let(@full_image_uri, T.nilable(URI::Generic)) @default_image_url = T.let(@default_image_url, T.nilable(String)) @default_tags = T.let(@default_tags, T.nilable(T::Array[String])) end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
19 20 21 |
# File 'lib/kuby/docker/metadata.rb', line 19 def environment @environment end |
#image_url ⇒ Object
37 38 39 |
# File 'lib/kuby/docker/metadata.rb', line 37 def image_url @image_url || default_image_url end |
Instance Method Details
#distro ⇒ Object
62 63 64 |
# File 'lib/kuby/docker/metadata.rb', line 62 def distro @distro || DEFAULT_DISTRO end |
#distro=(distro_name) ⇒ Object
67 68 69 |
# File 'lib/kuby/docker/metadata.rb', line 67 def distro=(distro_name) @distro = distro_name end |
#image_host ⇒ Object
42 43 44 |
# File 'lib/kuby/docker/metadata.rb', line 42 def image_host @image_host ||= "#{full_image_uri.scheme}://#{full_image_uri.host}" end |
#image_hostname ⇒ Object
47 48 49 |
# File 'lib/kuby/docker/metadata.rb', line 47 def image_hostname @image_hostname ||= T.must(URI(image_host).host) end |
#image_repo ⇒ Object
52 53 54 |
# File 'lib/kuby/docker/metadata.rb', line 52 def image_repo @image_repo ||= T.must(full_image_uri.path).sub(/\A[\/]+/, '') end |
#tags ⇒ Object
57 58 59 |
# File 'lib/kuby/docker/metadata.rb', line 57 def @tags.empty? ? : @tags end |