Module: Kontena::Plugin::Upcloud::Prompts::Common

Included in:
Nodes::RestartCommand, Nodes::TerminateCommand
Defined in:
lib/kontena/plugin/upcloud/prompts.rb

Defined Under Namespace

Modules: Defaults

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
# File 'lib/kontena/plugin/upcloud/prompts.rb', line 8

def self.included(base)
  base.prepend Defaults
  base.option "--username", "USER", "Upcloud username", required: true, environment_variable: 'UPCLOUD_USERNAME'
  base.option "--password", "PASS", "Upcloud password", required: true, environment_variable: 'UPCLOUD_PASSWORD'
end

Instance Method Details

#abort_unless_api_accessObject



18
19
20
21
22
# File 'lib/kontena/plugin/upcloud/prompts.rb', line 18

def abort_unless_api_access
  unless upcloud_client.api_access?
    exit_with_error('Upcloud API authentication failed. Check that API access is enabled for the user.')
  end
end

#upcloud_clientObject



14
15
16
# File 'lib/kontena/plugin/upcloud/prompts.rb', line 14

def upcloud_client
  @upcloud_client ||=  Kontena::Machine::Upcloud::Client.new(username, password)
end