Class: VagrantPlugins::SshConfigManager::Action::Destroy

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_ssh_config_manager/action/destroy.rb

Overview

Handles SSH config cleanup when a Vagrant machine is destroyed

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Destroy

Returns a new instance of Destroy.



8
9
10
11
12
# File 'lib/vagrant_ssh_config_manager/action/destroy.rb', line 8

def initialize(app, env)
  @app = app
  @env = env
  @logger = Log4r::Logger.new('vagrant::plugins::ssh_config_manager::action::destroy')
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant_ssh_config_manager/action/destroy.rb', line 14

def call(env)
  machine = env[:machine]

  # Handle SSH config removal before destroying the machine
  if machine
    config = machine.config.sshconfigmanager
    handle_ssh_config_removal(machine, config) if config&.enabled && config.auto_remove_on_destroy
  end

  # Call the next middleware (actual destroy)
  @app.call(env)
end