Module: Kontena::Plugin::Cloud::Node::Common

Included in:
CreateCommand, ListCommand, RebootCommand, ShellCommand, TerminateCommand
Defined in:
lib/kontena/plugin/cloud/node/common.rb

Instance Method Summary collapse

Instance Method Details

#cached_platforms_by_idObject



31
32
33
# File 'lib/kontena/plugin/cloud/node/common.rb', line 31

def cached_platforms_by_id
  @cached_platforms_by_id ||= {}
end

#compute_clientObject



7
8
9
# File 'lib/kontena/plugin/cloud/node/common.rb', line 7

def compute_client
  @compute_client ||= Kontena::Client.new(compute_url, config..token, prefix: '/')
end

#compute_urlObject



15
16
17
# File 'lib/kontena/plugin/cloud/node/common.rb', line 15

def compute_url
  ENV['KONTENA_COMPUTE_URL'] || 'https://compute.kontena.io'
end

#configObject



11
12
13
# File 'lib/kontena/plugin/cloud/node/common.rb', line 11

def config
  Kontena::Cli::Config.instance
end

#get_platform(org, id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kontena/plugin/cloud/node/common.rb', line 19

def get_platform(org, id)
  unless cached_platforms_by_id[id]
    data = cloud_client.get("/organizations/#{org}/platforms/#{id}")['data']
    if data
      platform = Kontena::Cli::Models::Platform.new(data)
      cached_platforms_by_id[id] = platform
    end
  end

  cached_platforms_by_id[id]
end