aptible-api 0.9.27 → 0.10.0
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/.travis.yml +3 -3
- data/Rakefile +6 -2
- data/lib/aptible/api/app.rb +1 -0
- data/lib/aptible/api/ephemeral_container.rb +17 -0
- data/lib/aptible/api/ephemeral_session.rb +17 -0
- data/lib/aptible/api/operation.rb +11 -7
- data/lib/aptible/api/resource.rb +2 -0
- data/lib/aptible/api/version.rb +1 -1
- data/spec/aptible/api/operation_spec.rb +32 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7d11f79004548577d85638bdac39f9c276dbdef
|
4
|
+
data.tar.gz: 6b62d4586b02bd18066f8268798ee9f0d963d914
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b0f62df81806e16939bf779ab5524c236c4b46b02a14110d05f8981856dbd3edcd26e8122570f494c6c301f0996f5e7c3cdaeae128219bfa6988e3f780cb5c2
|
7
|
+
data.tar.gz: 7f442ca267be1e134753e5e7646fbca42d437f14e3020f9a39d6b973ac47d573a415a97a12c0e4a316c7d6519113fae10e201edbc36aa45a50a358a7dd28d06a
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
data/lib/aptible/api/app.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Aptible
|
2
|
+
module Api
|
3
|
+
class EphemeralContainer < Resource
|
4
|
+
belongs_to :ephemeral_session
|
5
|
+
belongs_to :log_drain
|
6
|
+
|
7
|
+
field :id
|
8
|
+
|
9
|
+
field :docker_name
|
10
|
+
field :layer
|
11
|
+
field :interactive
|
12
|
+
|
13
|
+
field :created_at, type: Time
|
14
|
+
field :updated_at, type: Time
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Aptible
|
2
|
+
module Api
|
3
|
+
class EphemeralSession < Resource
|
4
|
+
belongs_to :app
|
5
|
+
belongs_to :operation
|
6
|
+
has_many :ephemeral_containers
|
7
|
+
has_many :operations
|
8
|
+
|
9
|
+
field :aws_instance_id
|
10
|
+
field :host
|
11
|
+
field :name
|
12
|
+
|
13
|
+
field :created_at, type: Time
|
14
|
+
field :updated_at, type: Time
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -7,6 +7,7 @@ module Aptible
|
|
7
7
|
belongs_to :resource
|
8
8
|
|
9
9
|
has_many :ssh_portal_connections
|
10
|
+
has_many :ephemeral_sessions
|
10
11
|
|
11
12
|
field :id
|
12
13
|
field :type
|
@@ -23,6 +24,7 @@ module Aptible
|
|
23
24
|
field :disk_size
|
24
25
|
field :command
|
25
26
|
field :destination_region
|
27
|
+
field :interactive
|
26
28
|
field :user_name
|
27
29
|
field :user_email
|
28
30
|
field :created_at, type: Time
|
@@ -43,7 +45,7 @@ module Aptible
|
|
43
45
|
status == 'failed'
|
44
46
|
end
|
45
47
|
|
46
|
-
def with_ssh_cmd(private_key_file)
|
48
|
+
def with_ssh_cmd(private_key_file, host: nil, port: nil, host_key: nil)
|
47
49
|
# We expect that the public key will be found next to the private key,
|
48
50
|
# which is also what SSH itself expects. If that's not the case, then
|
49
51
|
# we'll just fail. The Aptible CLI will always ensure credentials are
|
@@ -58,11 +60,13 @@ module Aptible
|
|
58
60
|
certificate = connection.ssh_certificate_body
|
59
61
|
|
60
62
|
stack = account.stack
|
61
|
-
host
|
62
|
-
port
|
63
|
-
|
63
|
+
host ||= stack.ssh_portal_host
|
64
|
+
port ||= stack.ssh_portal_port
|
65
|
+
host_key ||= stack.ssh_host_rsa_public_key
|
64
66
|
|
65
|
-
with_temporary_known_hosts(
|
67
|
+
with_temporary_known_hosts(
|
68
|
+
host, port, host_key
|
69
|
+
) do |known_hosts_file|
|
66
70
|
with_temporary_id(private_key, public_key, certificate) do |id_file|
|
67
71
|
cmd = [
|
68
72
|
'ssh',
|
@@ -85,10 +89,10 @@ module Aptible
|
|
85
89
|
|
86
90
|
private
|
87
91
|
|
88
|
-
def with_temporary_known_hosts(host, port,
|
92
|
+
def with_temporary_known_hosts(host, port, host_key)
|
89
93
|
Dir.mktmpdir do |dir|
|
90
94
|
known_hosts_file = File.join(dir, 'known_hosts')
|
91
|
-
contents = "[#{host}]:#{port} #{
|
95
|
+
contents = "[#{host}]:#{port} #{host_key}\n"
|
92
96
|
File.open(known_hosts_file, 'w', 0o600) { |f| f.write(contents) }
|
93
97
|
yield known_hosts_file
|
94
98
|
end
|
data/lib/aptible/api/resource.rb
CHANGED
data/lib/aptible/api/version.rb
CHANGED
@@ -97,6 +97,38 @@ describe Aptible::Api::Operation do
|
|
97
97
|
|
98
98
|
expect(has_yielded).to be_truthy
|
99
99
|
end
|
100
|
+
|
101
|
+
it 'allows passing a custom host' do
|
102
|
+
expect(subject).to receive(:create_ssh_portal_connection!)
|
103
|
+
.with(ssh_public_key: 'some public key')
|
104
|
+
.and_return(ssh_portal_connection)
|
105
|
+
|
106
|
+
has_yielded = false
|
107
|
+
|
108
|
+
subject.with_ssh_cmd(
|
109
|
+
private_key_file,
|
110
|
+
host: 'host-foo.com',
|
111
|
+
port: 123,
|
112
|
+
host_key: 'foo key'
|
113
|
+
) do |cmd, _|
|
114
|
+
_, dest, _, port, = cmd
|
115
|
+
|
116
|
+
expect(dest).to eq('foo-user@host-foo.com')
|
117
|
+
expect(port).to eq('123')
|
118
|
+
|
119
|
+
hosts_param = cmd.find { |p| p.start_with?('UserKnownHostsFile') }
|
120
|
+
expect(cmd[cmd.index(hosts_param) - 1]).to eq('-o')
|
121
|
+
expect(hosts_param).not_to be_nil
|
122
|
+
hosts_file = hosts_param.split('=')[1]
|
123
|
+
|
124
|
+
expect(File.read(hosts_file))
|
125
|
+
.to eq("[host-foo.com]:123 foo key\n")
|
126
|
+
|
127
|
+
has_yielded = true
|
128
|
+
end
|
129
|
+
|
130
|
+
expect(has_yielded).to be_truthy
|
131
|
+
end
|
100
132
|
end
|
101
133
|
|
102
134
|
context 'with a PTY' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptible-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.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: 2017-
|
11
|
+
date: 2017-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aptible-resource
|
@@ -178,6 +178,8 @@ files:
|
|
178
178
|
- lib/aptible/api/database_credential.rb
|
179
179
|
- lib/aptible/api/database_image.rb
|
180
180
|
- lib/aptible/api/disk.rb
|
181
|
+
- lib/aptible/api/ephemeral_container.rb
|
182
|
+
- lib/aptible/api/ephemeral_session.rb
|
181
183
|
- lib/aptible/api/image.rb
|
182
184
|
- lib/aptible/api/log_drain.rb
|
183
185
|
- lib/aptible/api/operation.rb
|
@@ -215,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
217
|
version: '0'
|
216
218
|
requirements: []
|
217
219
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.
|
220
|
+
rubygems_version: 2.6.13
|
219
221
|
signing_key:
|
220
222
|
specification_version: 4
|
221
223
|
summary: Ruby client for api.aptible.com
|