Sha256: 3f8d9ef28ae48602b410c5b53dd02a500399bfd641f71fc19f7ced243504de27

Contents?: true

Size: 871 Bytes

Versions: 45

Compression:

Stored size: 871 Bytes

Contents

# frozen_string_literal: true
module Krane
  class ContainerOverrides
    attr_reader :command, :arguments, :env_vars, :image_tag

    def initialize(command: nil, arguments: nil, env_vars: [], image_tag: nil)
      @command = command
      @arguments = arguments
      @env_vars = env_vars
      @image_tag = image_tag
    end

    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
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
krane-3.6.2 lib/krane/container_overrides.rb
krane-3.6.1 lib/krane/container_overrides.rb
krane-3.5.2 lib/krane/container_overrides.rb
krane-3.5.1 lib/krane/container_overrides.rb
krane-3.5.0 lib/krane/container_overrides.rb
krane-3.4.2 lib/krane/container_overrides.rb
krane-3.4.1 lib/krane/container_overrides.rb
krane-3.4.0 lib/krane/container_overrides.rb
krane-3.3.0 lib/krane/container_overrides.rb
krane-3.2.0 lib/krane/container_overrides.rb
krane-3.1.0 lib/krane/container_overrides.rb
krane-3.0.1 lib/krane/container_overrides.rb
krane-3.0.0 lib/krane/container_overrides.rb
krane-2.4.9 lib/krane/container_overrides.rb
krane-2.4.8 lib/krane/container_overrides.rb
krane-2.4.7 lib/krane/container_overrides.rb
krane-2.4.6 lib/krane/container_overrides.rb
krane-2.4.5 lib/krane/container_overrides.rb
krane-2.4.4 lib/krane/container_overrides.rb
krane-2.4.3 lib/krane/container_overrides.rb