Sha256: 4a1a7b8092eafcc2c25e2b44ff3cf95df201bb8b050546d53c3623edbf017f56
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
module Kamal::Commands class Base delegate :sensitive, :argumentize, to: Kamal::Utils DOCKER_HEALTH_STATUS_FORMAT = "'{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}'" DOCKER_HEALTH_LOG_FORMAT = "'{{json .State.Health}}'" attr_accessor :config def initialize(config) @config = config end def run_over_ssh(*command, host:) "ssh".tap do |cmd| if config.ssh.proxy && config.ssh.proxy.is_a?(Net::SSH::Proxy::Jump) cmd << " -J #{config.ssh.proxy.jump_proxies}" elsif config.ssh.proxy && config.ssh.proxy.is_a?(Net::SSH::Proxy::Command) cmd << " -o ProxyCommand='#{config.ssh.proxy.command_line_template}'" end cmd << " -t #{config.ssh.user}@#{host} '#{command.join(" ")}'" end end def container_id_for(container_name:, only_running: false) docker :container, :ls, *("--all" unless only_running), "--filter", "name=^#{container_name}$", "--quiet" end private def combine(*commands, by: "&&") commands .compact .collect { |command| Array(command) + [ by ] }.flatten # Join commands .tap { |commands| commands.pop } # Remove trailing combiner end def chain(*commands) combine *commands, by: ";" end def pipe(*commands) combine *commands, by: "|" end def append(*commands) combine *commands, by: ">>" end def write(*commands) combine *commands, by: ">" end def xargs(command) [ :xargs, command ].flatten end def docker(*args) args.compact.unshift :docker end def tags(**details) Kamal::Tags.from_config(config, **details) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kamal-0.16.1 | lib/kamal/commands/base.rb |
kamal-0.16.0 | lib/kamal/commands/base.rb |