Class: VagrantPlugins::SshConfigManager::Action::Reload

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

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Reload

Returns a new instance of Reload.



7
8
9
10
11
# File 'lib/vagrant_ssh_config_manager/action/reload.rb', line 7

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

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  # Call the next middleware first
  @app.call(env)

  # Only proceed if the machine is running and SSH is ready
  machine = env[:machine]
  return unless machine && machine.state.id == :running

  # Check if plugin is enabled
  config = machine.config.sshconfigmanager
  return unless config&.enabled

  # Handle SSH config update
  handle_ssh_config_update(machine, config)
end