Class: Container
- Defined in:
- lib/resources/container.rb
Instance Method Summary collapse
- #logs_token ⇒ Object
- #parse_command(command = nil) ⇒ Object
- #remote_token(command = nil) ⇒ Object
- #request_token(action, attributes) ⇒ Object
Instance Method Details
#logs_token ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/resources/container.rb', line 14 def logs_token attributes = { 'follow': true, 'lines': 500 } request_token(:logs, attributes) end |
#parse_command(command = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# 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) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# 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) ⇒ Object
22 23 24 25 26 |
# 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 |