module Brillo::Helpers::ExecHelper

Public Instance Methods

execute(*command) click to toggle source
# File lib/brillo/helpers/exec_helper.rb, line 5
def execute *command
  command_string = Array(command).join(' ')
  log_anonymized command_string
  stdout, stderr, status = Open3.capture3 command_string
  [status.success?, stdout, stderr]
end
execute!(*command) click to toggle source
# File lib/brillo/helpers/exec_helper.rb, line 12
def execute! *command
  success, stdout, stderr = execute(command)
  if success
    [success, stdout, stderr]
  else
    raise RuntimeError, "#{stdout} #{stderr}"
  end
end

Private Instance Methods

log_anonymized(command_string) click to toggle source
# File lib/brillo/helpers/exec_helper.rb, line 23
def log_anonymized command_string
  command_string = command_string.gsub(/PGPASSWORD=[^\s]+/, "PGPASSWORD={FILTERED}")
  command_string = command_string.gsub(/--password=[^\s]+/, "--password={FILTERED}")
  command_string = command_string.gsub(/EC2_ACCESS_KEY=[^\s]+/, "EC2_ACCESS_KEY={FILTERED}")
  command_string = command_string.gsub(/EC2_SECRET_KEY=[^\s]+/, "EC2_SECRET_KEY={FILTERED}")
  logger.info "Running \n\t #{command_string}"
end