Module: Aptible::CLI::Subcommands::SSH
- Included in:
- Agent
- Defined in:
- lib/aptible/cli/subcommands/ssh.rb
Class Method Summary collapse
-
.included(thor) ⇒ Object
rubocop:disable MethodLength.
Class Method Details
.included(thor) ⇒ Object
rubocop:disable MethodLength
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/aptible/cli/subcommands/ssh.rb', line 8 def self.included(thor) thor.class_eval do include Helpers::Operation include Helpers::App desc 'ssh COMMAND', 'Run a command against an app' long_desc " Runs an interactive command against a remote Aptible app\n\n If specifying an app, invoke via: aptible ssh [--app=APP] COMMAND\n LONGDESC\n option :app\n def ssh(*args)\n app = ensure_app(options)\n host = app.account.bastion_host\n port = app.account.bastion_port\n\n ENV['ACCESS_TOKEN'] = fetch_token\n ENV['APTIBLE_COMMAND'] = command_from_args(*args)\n ENV['APTIBLE_APP'] = app.handle\n\n Kernel.exec \"ssh -o 'SendEnv=*' -p \#{port} root@\#{host}\"\n end\n\n private\n\n def command_from_args(*args)\n args.empty? ? '/bin/bash' : Shellwords.join(args)\n end\n end\nend\n" |