Class: Indocker::ContainerMetadata
- Inherits:
-
Object
- Object
- Indocker::ContainerMetadata
- Defined in:
- lib/indocker/container/container_metadata.rb
Defined Under Namespace
Modules: States
Constant Summary collapse
- HOSTPORT =
'HostPort'
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #after_start_directives ⇒ Object
- #before_start_directives ⇒ Object
- #container_dependencies ⇒ Object
- #env_files ⇒ Object
- #exposed_ports ⇒ Object
- #image ⇒ Object
-
#initialize(name:, directives:) ⇒ ContainerMetadata
constructor
A new instance of ContainerMetadata.
- #networks ⇒ Object
- #port_bindings ⇒ Object
- #repo ⇒ Object
- #tag ⇒ Object
Constructor Details
#initialize(name:, directives:) ⇒ ContainerMetadata
Returns a new instance of ContainerMetadata.
17 18 19 20 |
# File 'lib/indocker/container/container_metadata.rb', line 17 def initialize(name:, directives:) @name = name @directives = directives end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/indocker/container/container_metadata.rb', line 2 def name @name end |
Instance Method Details
#after_start_directives ⇒ Object
78 79 80 |
# File 'lib/indocker/container/container_metadata.rb', line 78 def after_start_directives @directives.select(&:after_start?) end |
#before_start_directives ⇒ Object
74 75 76 |
# File 'lib/indocker/container/container_metadata.rb', line 74 def before_start_directives @directives.select(&:before_start?) end |
#container_dependencies ⇒ Object
70 71 72 |
# File 'lib/indocker/container/container_metadata.rb', line 70 def container_dependencies depends_on_directives.map(&:container_name) end |
#env_files ⇒ Object
38 39 40 |
# File 'lib/indocker/container/container_metadata.rb', line 38 def env_files env_directives.map(&:path) end |
#exposed_ports ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/indocker/container/container_metadata.rb', line 42 def exposed_ports return nil if ports_directives.empty? && expose_directives.empty? result = Hash.new expose_directives.each do |d| result[d.port.to_s] = {} end ports_directives.each do |d| result[d.docker_port] = {} end result end |
#image ⇒ Object
30 31 32 |
# File 'lib/indocker/container/container_metadata.rb', line 30 def image from_directive.image end |
#networks ⇒ Object
34 35 36 |
# File 'lib/indocker/container/container_metadata.rb', line 34 def networks network_directives.map(&:name) end |
#port_bindings ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/indocker/container/container_metadata.rb', line 58 def port_bindings return nil if ports_directives.empty? result = Hash.new ports_directives.each do |d| result[d.docker_port] = [{ HOSTPORT => d.host_port }] end result end |
#repo ⇒ Object
22 23 24 |
# File 'lib/indocker/container/container_metadata.rb', line 22 def repo from_directive.repo end |
#tag ⇒ Object
26 27 28 |
# File 'lib/indocker/container/container_metadata.rb', line 26 def tag from_directive.tag end |