contexto 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/bin/contexto +3 -1
- data/lib/contexto/contextualize.rb +5 -2
- data/lib/contexto/ssh.rb +8 -4
- data/lib/contexto/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 490c0e22ac549bef652ed2eeee1fd5a24ff596a4
|
4
|
+
data.tar.gz: 1ddb6fb3a4761d10558273b97802437f5dd40f8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0b59244e318aa403fdcda073a386246eb90d9d14668a47154c9e0758cccdc2ca6854578a4bb52dc6eb4f22d2c820790a2f38fce1d5db8e116157562ff448437
|
7
|
+
data.tar.gz: '04383e7cd14cee2be6114aae03b67cf7a806198326e2a246775db1a70e9d41de973d1b64ec238919d7387228c83c1a3407fbf2ba60bf6874ab6aa47836788505'
|
data/README.md
CHANGED
@@ -68,7 +68,19 @@ Containers
|
|
68
68
|
|
69
69
|
### SSH
|
70
70
|
|
71
|
-
You can also get Contexto to connect via SSH to a Rails console or run a `rake` task.
|
71
|
+
You can also get Contexto to connect via SSH to a Bash shell, Rails console or run a `rake` task.
|
72
|
+
|
73
|
+
#### Bash shell on container
|
74
|
+
|
75
|
+
To connect to a Bash shell in a specific container, specify the cluster, service and container and the `--bash` flag.
|
76
|
+
|
77
|
+
```shell
|
78
|
+
$ contexto -c sandbox -s backend-app -t app --bash
|
79
|
+
|
80
|
+
** Contexto Contextualizes **
|
81
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
82
|
+
circleci@4e65666c9414:/usr/src/app$
|
83
|
+
```
|
72
84
|
|
73
85
|
#### Rails console
|
74
86
|
|
data/bin/contexto
CHANGED
@@ -11,7 +11,8 @@ require 'English'
|
|
11
11
|
$stderr.sync = true
|
12
12
|
|
13
13
|
options = {}
|
14
|
-
options[:console]
|
14
|
+
options[:console] = false
|
15
|
+
options[:bash] = false
|
15
16
|
options[:ssh] = false
|
16
17
|
|
17
18
|
optparse = OptionParser.new do |opts|
|
@@ -21,6 +22,7 @@ optparse = OptionParser.new do |opts|
|
|
21
22
|
opts.on('-t', '--container CONTAINER', 'Container') { |v| options[:container] = v }
|
22
23
|
opts.on('-r', '--rake COMMAND', 'Rake command') { |v| options[:rake] = v }
|
23
24
|
opts.on('-b', '--console') { options[:console] = true }
|
25
|
+
opts.on('-e', '--bash') { options[:bash] = true }
|
24
26
|
opts.on('-f', '--ssh') { options[:ssh] = true }
|
25
27
|
end
|
26
28
|
|
@@ -4,7 +4,7 @@ require 'aws-sdk'
|
|
4
4
|
module Contexto
|
5
5
|
# ECS class
|
6
6
|
class Contextualize
|
7
|
-
attr_reader :display, :cluster, :service, :container, :console, :ssh, :rake
|
7
|
+
attr_reader :display, :cluster, :service, :container, :console, :bash, :ssh, :rake
|
8
8
|
|
9
9
|
def initialize(params = {})
|
10
10
|
@cluster = params.fetch(:cluster) if params[:cluster]
|
@@ -12,6 +12,7 @@ module Contexto
|
|
12
12
|
@container = params.fetch(:container) if params[:container]
|
13
13
|
@rake = params.fetch(:rake) if params[:rake]
|
14
14
|
@console = params.fetch(:console)
|
15
|
+
@bash = params.fetch(:bash)
|
15
16
|
@ssh = params.fetch(:ssh)
|
16
17
|
@display = Contexto::Display.new
|
17
18
|
end
|
@@ -23,6 +24,8 @@ module Contexto
|
|
23
24
|
@connection = Contexto::SSH.new(describe_instances(ec2_instance_id), cluster, service, container)
|
24
25
|
if console
|
25
26
|
@connection.console
|
27
|
+
elsif bash
|
28
|
+
@connection.bash
|
26
29
|
elsif ssh
|
27
30
|
@connection.ssh
|
28
31
|
elsif rake
|
@@ -50,7 +53,7 @@ module Contexto
|
|
50
53
|
private
|
51
54
|
|
52
55
|
def connect?
|
53
|
-
(console || ssh || rake)
|
56
|
+
(console || bash || ssh || rake)
|
54
57
|
end
|
55
58
|
|
56
59
|
def show_clusters
|
data/lib/contexto/ssh.rb
CHANGED
@@ -3,7 +3,7 @@ module Contexto
|
|
3
3
|
# SSH class
|
4
4
|
class SSH
|
5
5
|
attr_reader :ipaddress, :cluster, :service, :container
|
6
|
-
|
6
|
+
|
7
7
|
def initialize(ipaddress, cluster, service, container)
|
8
8
|
@ipaddress = ipaddress
|
9
9
|
@cluster = cluster
|
@@ -16,7 +16,7 @@ module Contexto
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def console
|
19
|
-
exec "#{ssh_cmd} #{cmd} c'\""
|
19
|
+
exec "#{ssh_cmd} #{cmd} bin/rails c'\""
|
20
20
|
end
|
21
21
|
|
22
22
|
def ssh
|
@@ -24,7 +24,11 @@ module Contexto
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def rake(rake_cmd)
|
27
|
-
exec "#{cmd} #{rake_cmd}'\""
|
27
|
+
exec "#{ssh_cmd} #{cmd} #{rake_cmd}'\""
|
28
|
+
end
|
29
|
+
|
30
|
+
def bash
|
31
|
+
exec "#{ssh_cmd} #{cmd} /bin/bash'\""
|
28
32
|
end
|
29
33
|
|
30
34
|
def ssh_cmd
|
@@ -32,7 +36,7 @@ module Contexto
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def cmd
|
35
|
-
"'docker exec -it \\$(docker ps | grep ecs-#{cluster}-#{service}-.*-#{container} | cut -d\\ -f1)
|
39
|
+
"'docker exec -it \\$(docker ps | grep ecs-#{cluster}-#{service}-.*-#{container} | cut -d\\ -f1) "
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|
data/lib/contexto/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contexto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Turnbull
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.6.11
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Shows you context for ECS services and containers.
|