contexto 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -0
- data/bin/contexto +2 -0
- data/lib/contexto/contextualize.rb +7 -4
- data/lib/contexto/ssh.rb +10 -2
- data/lib/contexto/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee3f0c704b3e64a3bf0a7918efd31722f4c75ed1
|
4
|
+
data.tar.gz: ad05060c02428b7ca51dc251faaa8e262dbca6c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 654c9fac82ff73b4c37fe2afc391544350aacd5725a201d46b1f0b5f93c911e07e7ecc29db99cbc43a9e74f1583afa9f69f9b7675ee66dfdc07e607fe3b4679d
|
7
|
+
data.tar.gz: 1e8676c564d870af09e1e7cfa2db6ea4dc9710c4b501ed6d213121a42832542409951d0362aa49f6e7a20160dc41e22ea4df19db89e310155618dcc03029174a
|
data/README.md
CHANGED
@@ -103,6 +103,28 @@ Run options: --seed 52808
|
|
103
103
|
................................................E
|
104
104
|
```
|
105
105
|
|
106
|
+
#### Shell on Docker host
|
107
|
+
|
108
|
+
You can get an SSH shell on the Docker host too using the `--ssh` task.
|
109
|
+
|
110
|
+
```shell
|
111
|
+
$ contexto -c sandbox -s backend-app -t sidekiq --ssh
|
112
|
+
|
113
|
+
** Contexto Contextualizes **
|
114
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
115
|
+
|
116
|
+
Last login: Sat Apr 1 18:58:38 2017 from ip-172-31-12-234.ec2.internal
|
117
|
+
|
118
|
+
__| __| __|
|
119
|
+
_| ( \__ \ Amazon ECS-Optimized Amazon Linux AMI 2016.09.f
|
120
|
+
____|\___|____/
|
121
|
+
|
122
|
+
For documentation visit, http://aws.amazon.com/documentation/ecs
|
123
|
+
9 package(s) needed for security, out of 19 available
|
124
|
+
Run "sudo yum update" to apply all updates.
|
125
|
+
[ec2-user@ip-10-2-1-221 ~]$
|
126
|
+
```
|
127
|
+
|
106
128
|
## Development
|
107
129
|
|
108
130
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/bin/contexto
CHANGED
@@ -12,6 +12,7 @@ $stderr.sync = true
|
|
12
12
|
|
13
13
|
options = {}
|
14
14
|
options[:console] = false
|
15
|
+
options[:ssh] = false
|
15
16
|
|
16
17
|
optparse = OptionParser.new do |opts|
|
17
18
|
opts.banner = 'Usage: contexto [options]'
|
@@ -20,6 +21,7 @@ optparse = OptionParser.new do |opts|
|
|
20
21
|
opts.on('-t', '--container CONTAINER', 'Container') { |v| options[:container] = v }
|
21
22
|
opts.on('-r', '--rake COMMAND', 'Rake command') { |v| options[:rake] = v }
|
22
23
|
opts.on('-b', '--console') { options[:console] = true }
|
24
|
+
opts.on('-f', '--ssh') { options[:ssh] = true }
|
23
25
|
end
|
24
26
|
|
25
27
|
begin
|
@@ -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, :rake
|
7
|
+
attr_reader :display, :cluster, :service, :container, :console, :ssh, :rake
|
8
8
|
|
9
9
|
def initialize(params = {})
|
10
10
|
@cluster = params.fetch(:cluster) if params[:cluster]
|
@@ -12,16 +12,19 @@ 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
|
+
@ssh = params.fetch(:ssh)
|
15
16
|
@display = Contexto::Display.new
|
16
17
|
end
|
17
18
|
|
18
19
|
def run
|
19
|
-
if
|
20
|
+
if connect?
|
20
21
|
task = describe_tasks
|
21
22
|
ec2_instance_id = describe_container_instance(task[:container_instance_arn])
|
22
23
|
@ssh = Contexto::SSH.new(describe_instances(ec2_instance_id), cluster, service, container)
|
23
24
|
if console
|
24
25
|
@ssh.console
|
26
|
+
elsif ssh
|
27
|
+
@ssh.ssh
|
25
28
|
elsif rake
|
26
29
|
@ssh.rake(rake)
|
27
30
|
end
|
@@ -46,8 +49,8 @@ module Contexto
|
|
46
49
|
|
47
50
|
private
|
48
51
|
|
49
|
-
def
|
50
|
-
(console || rake)
|
52
|
+
def connect?
|
53
|
+
(console || ssh || rake)
|
51
54
|
end
|
52
55
|
|
53
56
|
def show_clusters
|
data/lib/contexto/ssh.rb
CHANGED
@@ -14,15 +14,23 @@ module Contexto
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def console
|
17
|
-
exec "#{cmd} c'\""
|
17
|
+
exec "#{ssh_cmd} #{cmd} c'\""
|
18
|
+
end
|
19
|
+
|
20
|
+
def ssh
|
21
|
+
exec "#{ssh_cmd}\""
|
18
22
|
end
|
19
23
|
|
20
24
|
def rake(rake_cmd)
|
21
25
|
exec "#{cmd} #{rake_cmd}'\""
|
22
26
|
end
|
23
27
|
|
28
|
+
def ssh_cmd
|
29
|
+
"ssh -t -A #{@bastion_host} \"ssh -t ec2-user@#{@ipaddress} "
|
30
|
+
end
|
31
|
+
|
24
32
|
def cmd
|
25
|
-
"
|
33
|
+
"'docker exec -it \\$(docker ps | grep ecs-#{@cluster}-#{@service}-.*-#{@container} | cut -d\\ -f1) bin/rails "
|
26
34
|
end
|
27
35
|
end
|
28
36
|
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.2
|
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-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|