class Percheron::Actions::Shell
Constants
- DEFAULT_COMMAND
- DOCKER_CLIENT
Attributes
raw_command[R]
unit[R]
Public Class Methods
new(unit, raw_command: DEFAULT_COMMAND)
click to toggle source
# File lib/percheron/actions/shell.rb, line 9 def initialize(unit, raw_command: DEFAULT_COMMAND) @unit = unit @raw_command = raw_command end
Public Instance Methods
execute!()
click to toggle source
# File lib/percheron/actions/shell.rb, line 14 def execute! exec! if valid? end
Private Instance Methods
command()
click to toggle source
# File lib/percheron/actions/shell.rb, line 26 def command "sh -c '%s'" % [ raw_command ] end
exec!()
click to toggle source
# File lib/percheron/actions/shell.rb, line 30 def exec! cmd = '%s exec -ti %s %s' % [ DOCKER_CLIENT, unit.full_name, command ] $logger.debug %(Executing "#{cmd}" on '#{unit.display_name}' unit) system(cmd) end
valid?()
click to toggle source
# File lib/percheron/actions/shell.rb, line 22 def valid? Validators::DockerClient.new.valid? end