Class: VagrantPlugins::OrbStack::Action::SSHRun
- Inherits:
-
Object
- Object
- VagrantPlugins::OrbStack::Action::SSHRun
- Includes:
- MachineValidation
- Defined in:
- lib/vagrant-orbstack/action/ssh_run.rb
Overview
Action middleware for validating SSH readiness before command execution
This middleware validates that the machine is in a running state before
Vagrant executes SSH commands via vagrant ssh -c "command". It does NOT
execute the SSH command itself - Vagrant's built-in SSH layer handles that
after this validation middleware approves the operation.
Unlike other actions, SSHRun is read-only: it only validates state and does not call OrbStack CLI or modify machine state. This makes it safe to call repeatedly without side effects.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Execute the middleware.
-
#initialize(app, _env) ⇒ SSHRun
constructor
Initialize the middleware.
Methods included from MachineValidation
Constructor Details
#initialize(app, _env) ⇒ SSHRun
Initialize the middleware.
33 34 35 |
# File 'lib/vagrant-orbstack/action/ssh_run.rb', line 33 def initialize(app, _env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
Execute the middleware.
Validates that the machine has a valid ID and is in running state. If validation passes, continues the middleware chain for Vagrant to execute the SSH command. If validation fails, raises an error and blocks SSH command execution.
This is a read-only operation:
- Does NOT call OrbStack CLI (only queries cached state)
- Does NOT invalidate state cache (no state changes occur)
- Does NOT display UI messages (validation only)
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/vagrant-orbstack/action/ssh_run.rb', line 54 def call(env) machine = env[:machine] # Validate machine ID exists (from MachineValidation) validate_machine_id!(machine, 'ssh') # Validate machine is running state = machine.provider.state raise Errors::SSHNotReady, machine_name: machine.id unless state.id == :running # Continue middleware chain (Vagrant handles SSH execution) @app.call(env) end |