aptible-api 0.9.27 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 405bef35093af9c898e855eb7db32cc8c8dc9f56
4
- data.tar.gz: b06c78cf3a837db863594ca488cbc285c794e374
3
+ metadata.gz: d7d11f79004548577d85638bdac39f9c276dbdef
4
+ data.tar.gz: 6b62d4586b02bd18066f8268798ee9f0d963d914
5
5
  SHA512:
6
- metadata.gz: d659a6d82f799cc4c925adca659d94d9a85cb519ea1cb215c1460a83f1b0b0cd8563da4f357bc025df0d799043cacd637db463aa82144c0d6b322dea228515b5
7
- data.tar.gz: c2dec80e92e48c6d955fe26fb8ce9005b8fa66ecb3be25e02f20ea1ac1f165a3a16127640e3afb38575975db4d139f4af7eb25bae614726c6b0163a30ddea3ca
6
+ metadata.gz: 5b0f62df81806e16939bf779ab5524c236c4b46b02a14110d05f8981856dbd3edcd26e8122570f494c6c301f0996f5e7c3cdaeae128219bfa6988e3f780cb5c2
7
+ data.tar.gz: 7f442ca267be1e134753e5e7646fbca42d437f14e3020f9a39d6b973ac47d573a415a97a12c0e4a316c7d6519113fae10e201edbc36aa45a50a358a7dd28d06a
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  sudo: false
2
2
 
3
3
  rvm:
4
- - 2.0.0
5
- - 2.1.0
6
- - 2.2.0
4
+ - "2.0"
5
+ - "2.1"
6
+ - "2.2"
data/Rakefile CHANGED
@@ -1,4 +1,8 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
- require 'aptible/tasks'
4
- Aptible::Tasks.load_tasks
3
+ begin
4
+ require 'aptible/tasks'
5
+ Aptible::Tasks.load_tasks
6
+ rescue LoadError
7
+ $stderr.puts 'Skipping Aptible::Tasks initialization...'
8
+ end
@@ -10,6 +10,7 @@ module Aptible
10
10
  has_many :images
11
11
  has_many :operations
12
12
  has_many :vhosts
13
+ has_many :ephemeral_sessions
13
14
  embeds_many :services
14
15
 
15
16
  field :id
@@ -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 = stack.ssh_portal_host
62
- port = stack.ssh_portal_port
63
- key = stack.ssh_host_rsa_public_key
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(host, port, key) do |known_hosts_file|
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, key)
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} #{key}\n"
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
@@ -33,3 +33,5 @@ require 'aptible/api/vhost'
33
33
  require 'aptible/api/ssh_portal_connection'
34
34
  require 'aptible/api/stack'
35
35
  require 'aptible/api/database_credential'
36
+ require 'aptible/api/ephemeral_session'
37
+ require 'aptible/api/ephemeral_container'
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Api
3
- VERSION = '0.9.27'.freeze
3
+ VERSION = '0.10.0'.freeze
4
4
  end
5
5
  end
@@ -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.9.27
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-04-13 00:00:00.000000000 Z
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.4.5.1
220
+ rubygems_version: 2.6.13
219
221
  signing_key:
220
222
  specification_version: 4
221
223
  summary: Ruby client for api.aptible.com