lib/percheron/actions/shell.rb in percheron-0.7.4 vs lib/percheron/actions/shell.rb in percheron-0.7.5

- old
+ new

@@ -1,32 +1,37 @@ module Percheron module Actions class Shell include Base - DEFAULT_SHELL = '/bin/sh' + DEFAULT_COMMAND = '/bin/sh' DOCKER_CLIENT = 'docker' - def initialize(container, shell: DEFAULT_SHELL) + def initialize(container, command: DEFAULT_COMMAND) @container = container - @shell = shell + @command = command end def execute! - $logger.debug "Executing #{shell} on '#{container.name}' container" exec! if valid? end private - attr_reader :container, :shell + attr_reader :container def valid? Validators::DockerClient.new.valid? end + def command + "sh -c '%s'" % @command + end + def exec! - system('%s exec -ti %s %s' % [ DOCKER_CLIENT, container.full_name, shell ]) + cmd = '%s exec -ti %s %s' % [ DOCKER_CLIENT, container.full_name, command ] + $logger.debug "Executing '#{cmd}' on '#{container.name}' container" + system(cmd) end end end end