aptible-cli 0.12.0 → 0.13.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: daac13a8f95ed0d51f55b1facdaf8fb7d6777253
4
- data.tar.gz: 289c5c14b294a2bc47ed05c6c51bd6dedcc8fb9d
3
+ metadata.gz: 85166609cc820ace0f7d804059e47335a9e9dd04
4
+ data.tar.gz: aff75a2d86c878dd185e18a0b5eeb153328ee248
5
5
  SHA512:
6
- metadata.gz: 53d1ff2a1fd3987bf053c8779679eee38a369a1a0f39ed93e7880335d486e81f0ece0991e652276aab01554b1f3cb9eba4a3a794c74894cac9dd122b148ab1cb
7
- data.tar.gz: 4e813f1040e3677a3a96f14c3788b6ba3564443e370bbec606ca7c3e5b9f9a9fc65fc53a078ae43cddea6496dd0b25f7ded2981d943abcfbf13f41430db5cba4
6
+ metadata.gz: 0760707d72ec0f5795ca9f63211a778978a555b681827359e3634e17e3129e43826d2f68beebd34fdfc95bfb234375f66d3a230012a7e6cff52c67c37f8d7e87
7
+ data.tar.gz: 482ddca8bf3c13ffd67e5c4398b335fdfcbeaac44d509e64193a5e671ba471083b577b5f7d0713a4f27176c556ed64f5393ed770e0e64e96e8d075d2b5f0afe1
@@ -8,5 +8,5 @@ rvm:
8
8
 
9
9
  script:
10
10
  - bundle exec rake
11
- - bundle exec script/sync-readme-usage README.md
11
+ - bundle exec script/sync-readme-usage
12
12
  - git diff --exit-code
data/README.md CHANGED
@@ -29,39 +29,39 @@ From `aptible help`:
29
29
  <!-- BEGIN USAGE -->
30
30
  ```
31
31
  Commands:
32
- aptible apps # List all applications
33
- aptible apps:create HANDLE # Create a new application
34
- aptible apps:deprovision # Deprovision an app
35
- aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] # Scale a service
36
- aptible backup:list DB_HANDLE # List backups for a database
37
- aptible backup:restore BACKUP_ID [--handle HANDLE] [--container-size SIZE_MB] [--size SIZE_GB] # Restore a backup
38
- aptible config # Print an app's current configuration
39
- aptible config:add # Add an ENV variable to an app
40
- aptible config:rm # Remove an ENV variable from an app
41
- aptible config:set # Alias for config:add
42
- aptible config:unset # Alias for config:rm
43
- aptible db:backup HANDLE # Backup a database
44
- aptible db:clone SOURCE DEST # Clone a database to create a new one
45
- aptible db:create HANDLE[--type TYPE] [--container-size SIZE_MB] [--size SIZE_GB] # Create a new database
46
- aptible db:deprovision HANDLE # Deprovision a database
47
- aptible db:dump HANDLE # Dump a remote database to file
48
- aptible db:execute HANDLE SQL_FILE # Executes sql against a database
49
- aptible db:list # List all databases
50
- aptible db:reload HANDLE # Reload a database
51
- aptible db:restart HANDLE [--container-size SIZE_MB] [--size SIZE_GB] # Restart a database
52
- aptible db:tunnel HANDLE # Create a local tunnel to a database
53
- aptible db:url HANDLE # Display a database URL
54
- aptible deploy [OPTIONS] [VAR1=VAL1] [VAR=VAL2] ... # Deploy an app
55
- aptible domains # Print an app's current virtual domains
56
- aptible help [COMMAND] # Describe available commands or one specific command
57
- aptible login # Log in to Aptible
58
- aptible logs # Follows logs from a running app or database
59
- aptible operation:cancel OPERATION_ID # Cancel a running operation
60
- aptible ps # Display running processes for an app - DEPRECATED
61
- aptible rebuild # Rebuild an app, and restart its services
62
- aptible restart # Restart all services associated with an app
63
- aptible ssh [COMMAND] # Run a command against an app
64
- aptible version # Print Aptible CLI version
32
+ aptible apps # List all applications
33
+ aptible apps:create HANDLE # Create a new application
34
+ aptible apps:deprovision # Deprovision an app
35
+ aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] # Scale a service
36
+ aptible backup:list DB_HANDLE # List backups for a database
37
+ aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--size SIZE_GB] # Restore a backup
38
+ aptible config # Print an app's current configuration
39
+ aptible config:add # Add an ENV variable to an app
40
+ aptible config:rm # Remove an ENV variable from an app
41
+ aptible config:set # Alias for config:add
42
+ aptible config:unset # Alias for config:rm
43
+ aptible db:backup HANDLE # Backup a database
44
+ aptible db:clone SOURCE DEST # Clone a database to create a new one
45
+ aptible db:create HANDLE[--type TYPE] [--container-size SIZE_MB] [--size SIZE_GB] # Create a new database
46
+ aptible db:deprovision HANDLE # Deprovision a database
47
+ aptible db:dump HANDLE # Dump a remote database to file
48
+ aptible db:execute HANDLE SQL_FILE # Executes sql against a database
49
+ aptible db:list # List all databases
50
+ aptible db:reload HANDLE # Reload a database
51
+ aptible db:restart HANDLE [--container-size SIZE_MB] [--size SIZE_GB] # Restart a database
52
+ aptible db:tunnel HANDLE # Create a local tunnel to a database
53
+ aptible db:url HANDLE # Display a database URL
54
+ aptible deploy [OPTIONS] [VAR1=VAL1] [VAR=VAL2] ... # Deploy an app
55
+ aptible domains # Print an app's current virtual domains
56
+ aptible help [COMMAND] # Describe available commands or one specific command
57
+ aptible login # Log in to Aptible
58
+ aptible logs # Follows logs from a running app or database
59
+ aptible operation:cancel OPERATION_ID # Cancel a running operation
60
+ aptible ps # Display running processes for an app - DEPRECATED
61
+ aptible rebuild # Rebuild an app, and restart its services
62
+ aptible restart # Restart all services associated with an app
63
+ aptible ssh [COMMAND] # Run a command against an app
64
+ aptible version # Print Aptible CLI version
65
65
  ```
66
66
  <!-- END USAGE -->
67
67
 
@@ -70,7 +70,7 @@ Commands:
70
70
  1. Fork the project.
71
71
  1. Commit your changes, with specs.
72
72
  1. Ensure that your code passes specs (`rake spec`) and meets Aptible's Ruby style guide (`rake rubocop`).
73
- 1. If you add a command, update this README with the output of `aptible help | grep -v help`.
73
+ 1. If you add a command, sync this README (`bundle exec script/sync-readme-usage`).
74
74
  1. Create a new pull request on GitHub.
75
75
 
76
76
  ## Contributors
@@ -82,6 +82,7 @@ Commands:
82
82
  * Daniel Levenson ([@dleve123](https://github.com/dleve123))
83
83
  * Ryan Aipperspach ([@ryanaip](https://github.com/ryanaip))
84
84
  * Chas Ballew ([@chasballew](https://github.com/chasballew))
85
+ * Chet Bortz ([@cbortz](https://github.com/cbortz))
85
86
 
86
87
  ## Copyright and License
87
88
 
@@ -7,26 +7,36 @@ module Aptible
7
7
  include Helpers::Token
8
8
  include Helpers::Database
9
9
 
10
- desc 'backup:restore BACKUP_ID [--handle HANDLE] ' \
10
+ desc 'backup:restore BACKUP_ID ' \
11
+ '[--environment ENVIRONMENT_HANDLE] [--handle HANDLE] ' \
11
12
  '[--container-size SIZE_MB] [--size SIZE_GB]',
12
13
  'Restore a backup'
13
- option :handle
14
+ option :handle, desc: 'a name to use for the new database'
15
+ option :environment, desc: 'a different environment to restore to'
14
16
  option :container_size, type: :numeric
15
17
  option :size, type: :numeric
16
18
  define_method 'backup:restore' do |backup_id|
17
19
  backup = Aptible::Api::Backup.find(backup_id, token: fetch_token)
18
20
  raise Thor::Error, "Backup ##{backup_id} not found" if backup.nil?
21
+
19
22
  handle = options[:handle]
20
23
  unless handle
21
24
  ts_suffix = backup.created_at.getgm.strftime '%Y-%m-%d-%H-%M-%S'
22
25
  handle = "#{backup.database.handle}-at-#{ts_suffix}"
23
26
  end
24
27
 
28
+ destination_account = if options[:environment]
29
+ ensure_environment(
30
+ environment: options[:environment]
31
+ )
32
+ end
33
+
25
34
  opts = {
26
35
  type: 'restore',
27
36
  handle: handle,
28
37
  container_size: options[:container_size],
29
- disk_size: options[:size]
38
+ disk_size: options[:size],
39
+ destination_account: destination_account
30
40
  }.delete_if { |_, v| v.nil? }
31
41
 
32
42
  operation = backup.create_operation!(opts)
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.12.0'.freeze
3
+ VERSION = '0.13.0'.freeze
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'open3'
3
3
 
4
- USAGE = ARGV.fetch(0)
4
+ USAGE = ARGV.fetch(0, 'README.md')
5
5
 
6
6
  puts "Sync CLI usage in #{USAGE}"
7
7
 
@@ -2,7 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Aptible::CLI::Agent do
4
4
  let(:token) { 'some-token' }
5
- let(:account) { Fabricate(:account) }
5
+ let(:account) { Fabricate(:account, handle: 'test') }
6
+ let(:alt_account) { Fabricate(:account, handle: 'alt') }
6
7
  let(:database) { Fabricate(:database, account: account, handle: 'some-db') }
7
8
  let!(:backup) do
8
9
  # created_at: 2016-06-14 13:24:11 +0000
@@ -14,6 +15,7 @@ describe Aptible::CLI::Agent do
14
15
  before do
15
16
  allow(subject).to receive(:fetch_token).and_return(token)
16
17
  allow(subject).to receive(:say) { |m| messages << m }
18
+ allow(Aptible::Api::Account).to receive(:all) { [account, alt_account] }
17
19
  end
18
20
 
19
21
  describe '#backup:restore' do
@@ -40,6 +42,7 @@ describe Aptible::CLI::Agent do
40
42
  expect(backup).to receive(:create_operation!) do |options|
41
43
  expect(options[:handle]).to eq(h)
42
44
  expect(options[:disk_size]).not_to be_present
45
+ expect(options[:destination_account]).not_to be_present
43
46
  op
44
47
  end
45
48
 
@@ -54,6 +57,7 @@ describe Aptible::CLI::Agent do
54
57
  expect(options[:handle]).to eq(h)
55
58
  expect(options[:container_size]).to be_nil
56
59
  expect(options[:disk_size]).to be_nil
60
+ expect(options[:destination_account]).not_to be_present
57
61
  op
58
62
  end
59
63
 
@@ -69,6 +73,7 @@ describe Aptible::CLI::Agent do
69
73
  expect(options[:handle]).to be_present
70
74
  expect(options[:container_size]).to eq(s)
71
75
  expect(options[:disk_size]).to be_nil
76
+ expect(options[:destination_account]).not_to be_present
72
77
  op
73
78
  end
74
79
 
@@ -83,12 +88,24 @@ describe Aptible::CLI::Agent do
83
88
  expect(options[:handle]).to be_present
84
89
  expect(options[:container_size]).to be_nil
85
90
  expect(options[:disk_size]).to eq(s)
91
+ expect(options[:destination_account]).not_to be_present
86
92
  op
87
93
  end
88
94
 
89
95
  subject.options = { size: s }
90
96
  subject.send('backup:restore', 1)
91
97
  end
98
+
99
+ it 'accepts an destination environment' do
100
+ expect(backup).to receive(:create_operation!) do |options|
101
+ expect(options[:handle]).to be_present
102
+ expect(options[:destination_account]).to eq(alt_account)
103
+ op
104
+ end
105
+
106
+ subject.options = { environment: 'alt' }
107
+ subject.send('backup:restore', 1)
108
+ end
92
109
  end
93
110
  end
94
111
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.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-09-21 00:00:00.000000000 Z
11
+ date: 2017-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource