Class: Krane::ContainerOverrides
- Inherits:
-
Object
- Object
- Krane::ContainerOverrides
- Defined in:
- lib/krane/container_overrides.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#env_vars ⇒ Object
readonly
Returns the value of attribute env_vars.
-
#image_tag ⇒ Object
readonly
Returns the value of attribute image_tag.
Instance Method Summary collapse
- #apply!(container) ⇒ Object
-
#initialize(command: nil, arguments: nil, env_vars: [], image_tag: nil) ⇒ ContainerOverrides
constructor
A new instance of ContainerOverrides.
Constructor Details
#initialize(command: nil, arguments: nil, env_vars: [], image_tag: nil) ⇒ ContainerOverrides
Returns a new instance of ContainerOverrides.
6 7 8 9 10 11 |
# File 'lib/krane/container_overrides.rb', line 6 def initialize(command: nil, arguments: nil, env_vars: [], image_tag: nil) @command = command @arguments = arguments @env_vars = env_vars @image_tag = image_tag end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
4 5 6 |
# File 'lib/krane/container_overrides.rb', line 4 def arguments @arguments end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
4 5 6 |
# File 'lib/krane/container_overrides.rb', line 4 def command @command end |
#env_vars ⇒ Object (readonly)
Returns the value of attribute env_vars.
4 5 6 |
# File 'lib/krane/container_overrides.rb', line 4 def env_vars @env_vars end |
#image_tag ⇒ Object (readonly)
Returns the value of attribute image_tag.
4 5 6 |
# File 'lib/krane/container_overrides.rb', line 4 def image_tag @image_tag end |
Instance Method Details
#apply!(container) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/krane/container_overrides.rb', line 13 def apply!(container) container.command = command if command container.args = arguments if arguments if image_tag image = container.image base_image, _old_tag = image.split(':') new_image = "#{base_image}:#{image_tag}" container.image = new_image end env_args = env_vars.map do |env| key, value = env.split('=', 2) { name: key, value: value } end container.env ||= [] container.env = container.env.map(&:to_h) + env_args end |