diff --git a/lib/omc/cli.rb b/lib/omc/cli.rb index b5f3b92..d17fccb 100644 --- a/lib/omc/cli.rb +++ b/lib/omc/cli.rb @@ -6,12 +6,19 @@ module Omc class Cli < Thor - class_option :account, aliases: '-a', optional: true - class_option :layer, aliases: '-l', optional: true + class_option :account, aliases: '-a' + class_option :layer, aliases: '-l' + class_option :forward_agent, aliases: "-A", type: :boolean, default: false desc 'ssh STACK', 'Connect to an instance on a stack on an account' def ssh(stack) - command = StackCommand.new(aws_account, user, stack, layer: options[:layer]) + command = StackCommand.new( + aws_account, + user, + stack, + layer: options[:layer], + forward_agent: options[:forward_agent] + ) command.ssh end diff --git a/lib/omc/stack_command.rb b/lib/omc/stack_command.rb index 0fefa8d..991a217 100644 --- a/lib/omc/stack_command.rb +++ b/lib/omc/stack_command.rb @@ -3,12 +3,13 @@ module Omc class StackCommand - def initialize aws_account, user, stack_name, app: nil, layer: nil + def initialize aws_account, user, stack_name, app: nil, layer: nil, forward_agent: false @aws_account = aws_account @user = user @stack_name = stack_name @app_name = app @layer_name = layer + @forward_agent = forward_agent end def ssh @@ -98,7 +99,10 @@ def bastion end def default_ssh_args - bastion ? [ '-o', "ProxyCommand ssh -W %h:%p #{bastion.host}" ] : [] + [].tap do |args| + args.push("-o", "ProxyCommand ssh -W %h:%p #{bastion.host}") if bastion + args.push("-A") if @forward_agent + end end def get_by_name collection, name, key: :name