Sha256: 8059c1df4bf6d73c10022948925c33118baca3f4e04ca28eb7404d0202ee865b

Contents?: true

Size: 1.34 KB

Versions: 65

Compression:

Stored size: 1.34 KB

Contents

class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDeployer::Strategies::Abstract
  include KuberKit::Import[
    "service_reader.reader",
    "shell.docker_compose_commands",
    "configs",
  ]

  STRATEGY_OPTIONS = [
    :service_name, 
    :command_name,
    :custom_args,
    :detached
  ]

  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
  def deploy(shell, service)
    service_config = reader.read(shell, service)
    config_path    = "#{configs.service_config_dir}/#{service.name}.yml"
    shell.write(config_path, service_config)

    strategy_options = service.attribute(:deployer, default: {})
    unknown_options  = strategy_options.keys.map(&:to_sym) - STRATEGY_OPTIONS
    if unknown_options.any?
      raise KuberKit::Error, "Unknow options for deploy strategy: #{unknown_options}. Available options: #{STRATEGY_OPTIONS}"
    end

    service_name = strategy_options.fetch(:service_name, service.name.to_s)
    command_name = strategy_options.fetch(:command_name, nil)
    custom_args  = strategy_options.fetch(:custom_args, nil)

    docker_compose_commands.run(shell, config_path, 
      service:      service_name, 
      command:      command_name,
      args:         custom_args, 
      detached:     !!strategy_options[:detached],
      interactive:  !strategy_options[:detached]
    )
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
kuber_kit-1.3.8 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.3.7 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.1.8 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.3.6 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.1.7 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.3.5 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.3.4 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.1.6 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.3.3 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.3.2 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.1.5 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.3.1 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.3.0 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.1.4 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.2.7 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.2.6 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.2.5 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.2.4 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.2.2 lib/kuber_kit/service_deployer/strategies/docker_compose.rb
kuber_kit-1.1.2 lib/kuber_kit/service_deployer/strategies/docker_compose.rb