aptible-cli 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/lib/aptible/cli/subcommands/db.rb +22 -12
- data/lib/aptible/cli/version.rb +1 -1
- metadata +24 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8340614d1cc3d2fb53ba6b4ae68dc03b6b19625e
|
4
|
+
data.tar.gz: 53687908023aceedb3e77846aedde82e6192211c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f28df71687301e46511dd5c0fd1f523e2d98b96f19768cc6a171fe4e1e96547a4591098e9d3ef1abd76ed8e000a01c9d155b16d2c328d08b7a02b83f70badbfb
|
7
|
+
data.tar.gz: bf28470cb7db548572226eaab4a7be3da12ae7dc7e0707b2fe721955148e0e3c06069cf7cca69f69c497576d1206ec96847919ca2d7e10d9a724f94f01edf503
|
data/.rubocop.yml
CHANGED
@@ -51,7 +51,7 @@ module Aptible
|
|
51
51
|
fail Thor::Error, 'db:dump only works for PostgreSQL'
|
52
52
|
end
|
53
53
|
|
54
|
-
local_port =
|
54
|
+
local_port = random_local_port
|
55
55
|
pid = fork { establish_connection(database, local_port) }
|
56
56
|
|
57
57
|
# TODO: Better test for connection readiness
|
@@ -74,7 +74,7 @@ module Aptible
|
|
74
74
|
fail Thor::Error, "Could not find database #{handle}"
|
75
75
|
end
|
76
76
|
|
77
|
-
local_port = options[:port] ||
|
77
|
+
local_port = options[:port] || random_local_port
|
78
78
|
puts "Creating tunnel at localhost:#{local_port}..."
|
79
79
|
establish_connection(database, local_port)
|
80
80
|
end
|
@@ -82,16 +82,14 @@ module Aptible
|
|
82
82
|
private
|
83
83
|
|
84
84
|
def establish_connection(database, local_port)
|
85
|
-
host = database.account.bastion_host
|
86
|
-
port = database.account.bastion_port
|
87
|
-
|
88
85
|
ENV['ACCESS_TOKEN'] = fetch_token
|
89
86
|
ENV['APTIBLE_DATABASE'] = database.handle
|
87
|
+
|
88
|
+
remote_port = claim_remote_port(database)
|
89
|
+
ENV['TUNNEL_PORT'] = remote_port
|
90
|
+
|
90
91
|
tunnel_args = "-L #{local_port}:localhost:#{remote_port}"
|
91
|
-
|
92
|
-
opts = " -o 'SendEnv=*' -o StrictHostKeyChecking=no " \
|
93
|
-
'-o UserKnownHostsFile=/dev/null'
|
94
|
-
command = "ssh #{opts} #{tunnel_args} #{connection_args}"
|
92
|
+
command = "ssh #{tunnel_args} #{common_ssh_args(database)}"
|
95
93
|
Kernel.exec(command)
|
96
94
|
end
|
97
95
|
|
@@ -101,7 +99,7 @@ module Aptible
|
|
101
99
|
end
|
102
100
|
end
|
103
101
|
|
104
|
-
def
|
102
|
+
def random_local_port
|
105
103
|
# Allocate a dummy server to discover an available port
|
106
104
|
dummy = TCPServer.new('127.0.0.1', 0)
|
107
105
|
port = dummy.addr[1]
|
@@ -109,8 +107,20 @@ module Aptible
|
|
109
107
|
port
|
110
108
|
end
|
111
109
|
|
112
|
-
def
|
113
|
-
|
110
|
+
def claim_remote_port(database)
|
111
|
+
ENV['ACCESS_TOKEN'] = fetch_token
|
112
|
+
|
113
|
+
`ssh #{common_ssh_args(database)} 2>/dev/null`.chomp
|
114
|
+
end
|
115
|
+
|
116
|
+
def common_ssh_args(database)
|
117
|
+
host = database.account.bastion_host
|
118
|
+
port = database.account.bastion_port
|
119
|
+
|
120
|
+
opts = " -o 'SendEnv=*' -o StrictHostKeyChecking=no " \
|
121
|
+
'-o UserKnownHostsFile=/dev/null'
|
122
|
+
connection_args = "-p #{port} root@#{host}"
|
123
|
+
"#{opts} #{connection_args}"
|
114
124
|
end
|
115
125
|
end
|
116
126
|
end
|
data/lib/aptible/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptible-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Macreery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aptible-api
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.7.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.7.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.19.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.19.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: git
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: aptible-tasks
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.2.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.2.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '2.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '2.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: pry
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: Aptible CLI
|
@@ -130,10 +130,10 @@ executables:
|
|
130
130
|
extensions: []
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
|
-
- .gitignore
|
134
|
-
- .rspec
|
135
|
-
- .rubocop.yml
|
136
|
-
- .travis.yml
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".rubocop.yml"
|
136
|
+
- ".travis.yml"
|
137
137
|
- Gemfile
|
138
138
|
- LICENSE.md
|
139
139
|
- README.md
|
@@ -166,12 +166,12 @@ require_paths:
|
|
166
166
|
- lib
|
167
167
|
required_ruby_version: !ruby/object:Gem::Requirement
|
168
168
|
requirements:
|
169
|
-
- -
|
169
|
+
- - ">="
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
173
|
requirements:
|
174
|
-
- -
|
174
|
+
- - ">="
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|