Class: Kontena::Plugin::Cloud::Platform::RemoveCommand

Inherits:
Command
  • Object
show all
Includes:
Cli::Common, Common
Defined in:
lib/kontena/plugin/cloud/platform/remove_command.rb

Constant Summary

Constants included from CloudCommand

CloudCommand::PLATFORM_NOT_SELECTED_ERROR

Instance Method Summary collapse

Methods included from Common

#cached_platforms, #current_organization, #current_platform, #fetch_platforms, #fetch_platforms_for_org, #find_platform_by_name, #login_to_platform, #parse_platform_name, #platform_config_exists?, #prompt_platform, #require_platform

Methods included from CloudCommand

#verify_current_grid, #verify_current_master, #verify_current_master_token

Instance Method Details

#executeObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kontena/plugin/cloud/platform/remove_command.rb', line 12

def execute
  require_platform(name)
  platform = find_platform_by_name(current_platform, current_organization)

  confirm_command(name) unless forced?

  spinner "Removing platform #{pastel.cyan(name)}" do
    cloud_client.delete("/organizations/#{current_organization}/platforms/#{platform.id}")
    remove_from_config(name)
  end
end

#remove_from_config(name) ⇒ Object



24
25
26
27
28
# File 'lib/kontena/plugin/cloud/platform/remove_command.rb', line 24

def remove_from_config(name)
  config.current_server = nil
  config.servers.delete_if {|s| s.name == name }
  config.write
end