Class: Nvoi::Cli::Delete::Command
- Inherits:
-
Object
- Object
- Nvoi::Cli::Delete::Command
- Defined in:
- lib/nvoi/cli/delete/command.rb
Overview
Command handles cleanup of all cloud resources
Instance Method Summary collapse
-
#initialize(options) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ Command
Returns a new instance of Command.
8 9 10 11 |
# File 'lib/nvoi/cli/delete/command.rb', line 8 def initialize() = @log = Nvoi.logger end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nvoi/cli/delete/command.rb', line 13 def run @log.info "Delete CLI %s", VERSION # Load configuration config_path = resolve_config_path @config = Utils::ConfigLoader.load(config_path) # Apply branch override if specified apply_branch_override if [:branch] # Initialize cloud provider @provider = External::Cloud.for(@config) # Initialize Cloudflare client cf = @config.cloudflare @cf_client = External::Dns::Cloudflare.new(cf.api_token, cf.account_id) @log.info "Using %s Cloud provider", @config.provider_name # Run teardown steps in order require_relative "steps/detach_volumes" require_relative "steps/teardown_server" require_relative "steps/teardown_volume" require_relative "steps/teardown_firewall" require_relative "steps/teardown_network" require_relative "steps/teardown_tunnel" require_relative "steps/teardown_dns" Steps::DetachVolumes.new(@config, @provider, @log).run Steps::TeardownServer.new(@config, @provider, @log).run Steps::TeardownVolume.new(@config, @provider, @log).run Steps::TeardownFirewall.new(@config, @provider, @log).run Steps::TeardownNetwork.new(@config, @provider, @log).run Steps::TeardownTunnel.new(@config, @cf_client, @log).run Steps::TeardownDns.new(@config, @cf_client, @log).run @log.success "Cleanup complete" end |