Skip to content

Commit

Permalink
Better clean V1 API
Browse files Browse the repository at this point in the history
  • Loading branch information
merqlove committed Jan 9, 2016
1 parent dd3d08e commit 4189e50
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
16 changes: 4 additions & 12 deletions lib/do_snapshot/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(*args)
set_mailer

# Check for keys via options
%w( digital_ocean_client_id digital_ocean_api_key digital_ocean_access_token ).each do |key|
%w( digital_ocean_access_token ).each do |key|
ENV[key.upcase] = options[key] if options.include? key
end
end
Expand All @@ -40,9 +40,9 @@ def initialize(*args)
### Examples
Select api version (1, 2):
Select api version (2):
$ do_snapshot -p 1
$ do_snapshot -p 2
Set DigitalOcean keys:
Expand Down Expand Up @@ -151,14 +151,6 @@ def initialize(*args)
type: :string,
banner: 'YOURLONGAPITOKEN',
desc: 'DIGITAL_OCEAN_ACCESS_TOKEN. if you can\'t use environment.'
method_option :digital_ocean_client_id,
type: :string,
banner: 'YOURLONGAPICLIENTID',
desc: 'DIGITAL_OCEAN_CLIENT_ID. if you can\'t use environment.'
method_option :digital_ocean_api_key,
type: :string,
banner: 'YOURLONGAPIKEY',
desc: 'DIGITAL_OCEAN_API_KEY. if you can\'t use environment.'

def snap
command.snap
Expand Down Expand Up @@ -197,7 +189,7 @@ def update_command
end

def command_filter
%w( log smtp mail trace digital_ocean_client_id digital_ocean_api_key digital_ocean_access_token )
%w( log smtp mail trace digital_ocean_access_token )
end

def setup_config # rubocop:disable Metrics/AbcSize
Expand Down
2 changes: 1 addition & 1 deletion spec/do_snapshot/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
expect(cli_obj.args)
.to include('help')
expect(cli_obj.options)
.to include('digital_ocean_client_id')
.to include('digital_ocean_access_token')
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/shared/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def do_not_send_email
let(:image_id) { '5019770' }
let(:image_id2) { '5019903' }
let(:cli_env_nil) { Hash['DIGITAL_OCEAN_CLIENT_ID' => nil, 'DIGITAL_OCEAN_API_KEY' => nil, 'DIGITAL_OCEAN_ACCESS_TOKEN' => nil] }
let(:cli_keys) { Thor::CoreExt::HashWithIndifferentAccess.new(digital_ocean_client_id: client_key, digital_ocean_api_key: api_key, digital_ocean_access_token: access_token) }
let(:cli_keys_other) { Thor::CoreExt::HashWithIndifferentAccess.new(digital_ocean_client_id: 'NOTFOO', digital_ocean_api_key: 'NOTBAR', digital_ocean_access_token: 'NOTTOK') }
let(:cli_keys) { Thor::CoreExt::HashWithIndifferentAccess.new(digital_ocean_access_token: access_token) }
let(:cli_keys_other) { Thor::CoreExt::HashWithIndifferentAccess.new(digital_ocean_access_token: 'NOTTOK') }
let(:snapshot_name) { "example.com_#{DateTime.now.strftime('%Y_%m_%d')}" }
let(:default_options) { Hash[protocol: 2, only: %w( 100823 ), exclude: %w(), keep: 3, stop: false, trace: true, clean: true, delay: 0, timeout: 600] }
let(:default_options_cli) { default_options.reject { |key, _| %w( droplets threads ).include?(key.to_s) } }
Expand Down

0 comments on commit 4189e50

Please sign in to comment.