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
- #cached_platforms_by_id ⇒ Object
- #compute_client ⇒ Object
- #compute_url ⇒ Object
- #config ⇒ Object
- #get_platform(org, id) ⇒ Object
Instance Method Details
#cached_platforms_by_id ⇒ Object
31 32 33 |
# File 'lib/kontena/plugin/cloud/node/common.rb', line 31 def cached_platforms_by_id @cached_platforms_by_id ||= {} end |
#compute_client ⇒ Object
7 8 9 |
# File 'lib/kontena/plugin/cloud/node/common.rb', line 7 def compute_client @compute_client ||= Kontena::Client.new(compute_url, config.current_account.token, prefix: '/') end |
#compute_url ⇒ Object
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 |
#config ⇒ Object
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 |