Class: Kontena::Cli::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/kontena_cli_plugin.rb

Instance Method Summary collapse

Instance Method Details

#load_cloud_settings_from_envObject



48
49
50
51
52
53
54
55
# File 'lib/kontena_cli_plugin.rb', line 48

def load_cloud_settings_from_env
  return unless ENV['KONTENA_CLOUD_TOKEN']

  debug { 'Loading cloud configuration from ENV' }
  accounts << Account.new(.merge(
    token: Token.new(access_token: ENV['KONTENA_CLOUD_TOKEN'], parent_type: :account, parent_name: 'default')
  ))
end

#load_master_settings_from_envObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/kontena_cli_plugin.rb', line 31

def load_master_settings_from_env
  return nil unless ENV['KONTENA_URL']

  debug { 'Loading master configuration from ENV' }
  servers << Server.new(
    url: ENV['KONTENA_URL'],
    name: 'default',
    token: Token.new(access_token: ENV['KONTENA_TOKEN'], parent_type: :master, parent_name: 'default'),
    grid: ENV['KONTENA_GRID'],
    parent_type: :master,
    parent_name: 'default'
  )

  self.current_master  = 'default'
  self. = 'kontena'
end

#load_settings_from_envObject



26
27
28
29
# File 'lib/kontena_cli_plugin.rb', line 26

def load_settings_from_env
  load_cloud_settings_from_env
  load_master_settings_from_env
end