class Container

Public Instance Methods

logs_token() click to toggle source
# File lib/resources/container.rb, line 14
def logs_token
  attributes = {
    'follow': true,
    'lines': 500
  }
  request_token(:logs, attributes)
end
parse_command(command=nil) click to toggle source
# File lib/resources/container.rb, line 28
def parse_command(command=nil)
  if !command
    command = [
      "/bin/sh",
      "-c",
      "TERM=xterm-256color; export TERM; [ -x /bin/bash ] && ([ -x /usr/bin/script ] && /usr/bin/script -q -c \"/bin/bash\" /dev/null || exec /bin/bash) || exec /bin/sh"
    ]
  else
    command = [
      "/bin/sh",
      "-c",
      "TERM=xterm-256color; export TERM; [ -x /bin/bash ] && ([ -x /usr/bin/script ] && /usr/bin/script -q -c \"#{command}\" /dev/null || exec #{command}) || /bin/sh #{command}"
    ]
  end
  command
end
remote_token(command=nil) click to toggle source
# File lib/resources/container.rb, line 4
def remote_token(command=nil)
  attributes = {
    'attachStdin': true,
    'attachStdout': true,
    'tty': true,
    'command': parse_command(command)
  }
  request_token(:execute, attributes)
end
request_token(action, attributes) click to toggle source
# File lib/resources/container.rb, line 22
def request_token(action, attributes)
  response = post(nil, {action: action}, attributes.to_json)
  json_response = JSON.parse(response.body)
  {token: json_response['token'], url: json_response['url']}
end