Sha256: 6c3a46c0cf066b04c14b4ddc11e5a3258b4ba62007b257a0c86d3f4f46679fe2
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer::Strategies::Abstract include KuberKit::Import[ "shell.docker_commands", "core.image_store", "configs", ] STRATEGY_OPTIONS = [ :container_name, :image_name, :detached, :docker_run_args, :docker_run_command, :delete_if_exists ] Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any def deploy(shell, service) 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 container_name = strategy_options.fetch(:container_name, service.uri) docker_run_args = strategy_options.fetch(:docker_run_args, nil) docker_run_command = strategy_options.fetch(:docker_run_command, nil) image_name = strategy_options.fetch(:image_name, nil) if image_name.nil? raise KuberKit::Error, "image_name is mandatory attribute for this deploy strategy" end image = image_store.get_image(image_name.to_sym) delete_enabled = strategy_options.fetch(:delete_if_exists, false) if delete_enabled && docker_commands.container_exists?(shell, container_name) docker_commands.delete_container(shell, container_name) end docker_commands.run( shell, image.remote_registry_url, run_args: docker_run_args, run_command: docker_run_command, detached: !!strategy_options[:detached] ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kuber_kit-0.3.8 | lib/kuber_kit/service_deployer/strategies/docker.rb |