broadside 3.1.3 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc7c5e27460dcaa89e814ebd4d4ed182d0621e55
4
- data.tar.gz: e1854045b97ca7b25eb17efb8fe8ce3b3cfc21f5
3
+ metadata.gz: 7f38120e5ed461522f423547c8f4cb6cb1d80dc2
4
+ data.tar.gz: 46b2213e403886e691880e640752fd2791bc0b69
5
5
  SHA512:
6
- metadata.gz: 4a5ceee9eca2a326c375b1cfed70dfbe28d5ad2704c0ba6433ee2a6d819eb1394a6242bce1003f6005ec29f5a270d0bb450d61e06846094441afe516de2ecff5
7
- data.tar.gz: 65dced59ea804ea74bf75b906978d5692bbc820f426c327d3182ac7bbe5d3fb4b5cd1d80f6341865570b6382966b1af1d9dfe457ee7d9663013589069ef37212
6
+ metadata.gz: 452b96e5e2567b1e954897c3652742199b33402e718c9d0cb63131b1756691ed7f4c9895a06695dce6ee75046042290f7b6c7f015d6d9f057fda561b879e5467
7
+ data.tar.gz: 783ae62663751c666413f2a2a72d2ba6d745e419254c0c8fccd2769cb415686cc4378b00b6da3298eaf11549004c2fdb63445e9496d84027c76c5a0d03d0b112
@@ -1,3 +1,7 @@
1
+ # 3.2.0
2
+ -- Add ability to execute a bash command on a container
3
+ -- Output actual bash command being run when log level is debug.
4
+
1
5
  # 3.1.3
2
6
  -- Better error messaging when trying to bash/ssh/etc to an instance_index that doesn't exist
3
7
 
@@ -6,6 +6,7 @@ module Broadside
6
6
  module Command
7
7
  extend LoggingUtils
8
8
 
9
+ BASH = 'bash'.freeze
9
10
  DEFAULT_TAIL_LINES = 10
10
11
 
11
12
  class << self
@@ -95,7 +96,7 @@ module Broadside
95
96
  info "Tailing logs for running container at #{ip}..."
96
97
 
97
98
  cmd = "docker logs -f --tail=#{lines} `#{docker_ps_cmd(target.family)}`"
98
- exec(Broadside.config.ssh_cmd(ip) + " '#{cmd}'")
99
+ system_exec(Broadside.config.ssh_cmd(ip) + " '#{cmd}'")
99
100
  end
100
101
 
101
102
  def ssh(options)
@@ -103,20 +104,26 @@ module Broadside
103
104
  ip = get_running_instance_ip!(target, *options[:instance])
104
105
  info "Establishing SSH connection to #{ip}..."
105
106
 
106
- exec(Broadside.config.ssh_cmd(ip))
107
+ system_exec(Broadside.config.ssh_cmd(ip))
107
108
  end
108
109
 
109
110
  def bash(options)
111
+ command = options[:command] || BASH
110
112
  target = Broadside.config.get_target_by_name!(options[:target])
111
113
  ip = get_running_instance_ip!(target, *options[:instance])
112
- info "Running bash for running container at #{ip}..."
114
+ cmd = "docker exec -i -t `#{docker_ps_cmd(target.family)}` #{command}"
115
+ info "Executing #{command} on running container at #{ip}..."
113
116
 
114
- cmd = "docker exec -i -t `#{docker_ps_cmd(target.family)}` bash"
115
- exec(Broadside.config.ssh_cmd(ip, tty: true) + " '#{cmd}'")
117
+ system_exec(Broadside.config.ssh_cmd(ip, tty: command == BASH) + " '#{cmd}'")
116
118
  end
117
119
 
118
120
  private
119
121
 
122
+ def system_exec(cmd)
123
+ debug "Executing: #{cmd}"
124
+ exec(cmd)
125
+ end
126
+
120
127
  def get_running_instance_ip!(target, instance_index = 0)
121
128
  EcsManager.check_service_and_task_definition_state!(target)
122
129
  running_instances = EcsManager.get_running_instance_ips!(target.cluster, target.family)
@@ -91,10 +91,14 @@ command :ssh do |ssh|
91
91
  end
92
92
  end
93
93
 
94
- desc 'Establish a shell inside a running container.'
94
+ desc 'Establish a shell or run a bash command inside a running container.'
95
95
  command :bash do |bash|
96
96
  add_command_flags(bash)
97
97
 
98
+ bash.desc 'bash command to run (wrap argument in quotes)'
99
+ bash.arg_name 'BASH_COMMAND'
100
+ bash.flag [:c, :command], type: Array
101
+
98
102
  bash.action do |_, options, _|
99
103
  Broadside::Command.bash(options)
100
104
  end
@@ -1,3 +1,3 @@
1
1
  module Broadside
2
- VERSION = '3.1.3'.freeze
2
+ VERSION = '3.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: broadside
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Leung
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-24 00:00:00.000000000 Z
12
+ date: 2017-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport