contexto 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/contexto +13 -14
- data/contexto.gemspec +1 -0
- data/lib/contexto/contextualize.rb +49 -29
- data/lib/contexto/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '01823bca9a67dc14286c25741fee3192d366192d'
|
4
|
+
data.tar.gz: feee83295be858f3fadd916b9dfa04e1bc220032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9aecc424407b74ba9dd636f4ae4e022f2a2ef9cd09872d3e0602d4550088e6b901e1666c393ab84f28d3f50efbae8f0e6b5419dd9df19757c227d88e6ab6c0
|
7
|
+
data.tar.gz: 3e303e464d36bbc0493ccda38c8dbe6f4ac7a616622194fea40e2941702e5dd115b9a3302aed6a813fb143d7ff4f41f1a9ecff8d6800cf8847d02e334572c7e4
|
data/bin/contexto
CHANGED
@@ -11,30 +11,29 @@ require 'English'
|
|
11
11
|
$stderr.sync = true
|
12
12
|
|
13
13
|
options = {}
|
14
|
-
options[:
|
15
|
-
options[:bash] = false
|
16
|
-
options[:ssh] = false
|
14
|
+
options[:connection_type] = false
|
17
15
|
|
18
16
|
optparse = OptionParser.new do |opts|
|
19
17
|
opts.banner = 'Usage: contexto [options]'
|
20
18
|
opts.on('-c', '--cluster CLUSTER', 'Cluster') { |v| options[:cluster] = v }
|
21
19
|
opts.on('-s', '--service SERVICE', 'Service') { |v| options[:service] = v }
|
22
|
-
opts.on('-
|
23
|
-
opts.on('-
|
24
|
-
opts.
|
25
|
-
|
26
|
-
|
20
|
+
opts.on('-v', '--container CONTAINER', 'Container') { |v| options[:container] = v }
|
21
|
+
opts.on('-t', "--type [TYPE]", [:console, :ssh, :bash], "Select connection type (console, ssh, bash)") { |v| options[:connection_type] = v }
|
22
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
23
|
+
puts opts
|
24
|
+
exit
|
25
|
+
end
|
27
26
|
end
|
28
27
|
|
29
28
|
begin
|
30
29
|
optparse.parse!
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
raise OptionParser::MissingArgument.new(missing.join(', '))
|
30
|
+
if options[:connection_type] && !options[:container]
|
31
|
+
raise OptionParser::MissingArgument.new("If you want to connect to a container you need to specify a container name.")
|
32
|
+
puts "\n"
|
35
33
|
end
|
36
|
-
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
37
|
-
puts $ERROR_INFO.to_s
|
34
|
+
rescue OptionParser::InvalidOption, OptionParser::InvalidArgument, OptionParser::MissingArgument
|
35
|
+
puts $ERROR_INFO.to_s.capitalize
|
36
|
+
puts "\n"
|
38
37
|
puts optparse
|
39
38
|
exit
|
40
39
|
end
|
data/contexto.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'aws-sdk', '~> 2'
|
23
23
|
spec.add_dependency 'command_line_reporter'
|
24
24
|
spec.add_dependency 'net-ssh-gateway'
|
25
|
+
spec.add_dependency 'highline'
|
25
26
|
|
26
27
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
27
28
|
spec.add_development_dependency 'pry', '~> 0.10.4'
|
@@ -1,59 +1,75 @@
|
|
1
1
|
require 'aws-sdk'
|
2
|
+
require 'highline'
|
2
3
|
|
3
4
|
# Context
|
4
5
|
module Contexto
|
5
6
|
# ECS class
|
6
7
|
class Contextualize
|
7
|
-
attr_reader :display, :cluster, :service, :container, :
|
8
|
+
attr_reader :display, :cluster, :service, :container, :connection_type
|
8
9
|
|
9
10
|
def initialize(params = {})
|
10
11
|
@cluster = params.fetch(:cluster) if params[:cluster]
|
11
12
|
@service = params.fetch(:service) if params[:service]
|
12
13
|
@container = params.fetch(:container) if params[:container]
|
13
|
-
@
|
14
|
-
@console = params.fetch(:console)
|
15
|
-
@bash = params.fetch(:bash)
|
16
|
-
@ssh = params.fetch(:ssh)
|
14
|
+
@connection_type = params.fetch(:connection_type) if params[:connection_type]
|
17
15
|
@display = Contexto::Display.new
|
18
16
|
end
|
19
17
|
|
20
18
|
def run
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@connection.console
|
27
|
-
elsif bash
|
28
|
-
@connection.bash
|
29
|
-
elsif ssh
|
30
|
-
@connection.ssh
|
31
|
-
elsif rake
|
32
|
-
@connection.rake(rake)
|
33
|
-
end
|
34
|
-
return
|
19
|
+
show
|
20
|
+
if (connection_type && container)
|
21
|
+
connect_to_endpoint
|
22
|
+
elsif container
|
23
|
+
prompt_endpoint
|
35
24
|
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def show
|
36
28
|
if !cluster
|
37
29
|
show_clusters
|
38
30
|
return
|
31
|
+
elsif cluster
|
32
|
+
show_cluster
|
33
|
+
puts "\n"
|
39
34
|
end
|
40
|
-
show_cluster
|
41
|
-
puts "\n"
|
42
35
|
if !service
|
43
36
|
show_services
|
44
|
-
|
45
|
-
|
37
|
+
return
|
38
|
+
elsif service
|
46
39
|
puts "\n"
|
47
40
|
show_service
|
48
|
-
|
41
|
+
end
|
42
|
+
if !container
|
49
43
|
show_tasks
|
44
|
+
return
|
45
|
+
elsif container
|
46
|
+
puts "\n"
|
47
|
+
show_tasks(container)
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
|
51
|
+
def connect
|
52
|
+
task = describe_tasks
|
53
|
+
ec2_instance_id = describe_container_instance(task[:container_instance_arn])
|
54
|
+
Contexto::SSH.new(describe_instances(ec2_instance_id), cluster, service, container)
|
55
|
+
end
|
54
56
|
|
55
|
-
def
|
56
|
-
|
57
|
+
def connect_to_endpoint
|
58
|
+
connnect.connection_type.to_sym
|
59
|
+
return
|
60
|
+
end
|
61
|
+
|
62
|
+
def prompt_endpoint
|
63
|
+
cli = HighLine.new
|
64
|
+
cli.choose do |menu|
|
65
|
+
puts "\n"
|
66
|
+
menu.header = "Do you want to connect to container #{container}'s? "
|
67
|
+
menu.prompt = "Please choose a connection type? "
|
68
|
+
menu.choice(:console) { connect.console }
|
69
|
+
menu.choice(:bash) { connect.bash }
|
70
|
+
menu.choice(:ssh) { connect.ssh }
|
71
|
+
menu.choice(:nah) { return }
|
72
|
+
end
|
57
73
|
end
|
58
74
|
|
59
75
|
def show_clusters
|
@@ -98,9 +114,13 @@ module Contexto
|
|
98
114
|
puts 'Service not found'
|
99
115
|
end
|
100
116
|
|
101
|
-
def show_tasks
|
117
|
+
def show_tasks(container = '')
|
102
118
|
task = describe_tasks
|
103
|
-
|
119
|
+
if container
|
120
|
+
containers = task[:containers].select { |c| container == c[:name] }
|
121
|
+
else
|
122
|
+
containers = task[:containers]
|
123
|
+
end
|
104
124
|
ec2_instance_id = describe_container_instance(task[:container_instance_arn])
|
105
125
|
title = 'Containers'
|
106
126
|
headings = %w(Container Status IP)
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Turnbull
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: highline
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
167
|
version: '0'
|
154
168
|
requirements: []
|
155
169
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.6.
|
170
|
+
rubygems_version: 2.6.13
|
157
171
|
signing_key:
|
158
172
|
specification_version: 4
|
159
173
|
summary: Shows you context for ECS services and containers.
|