Class: VagrantPlugins::OrbStack::Action::Start

Inherits:
Object
  • Object
show all
Includes:
MachineValidation
Defined in:
lib/vagrant-orbstack/action/start.rb

Overview

Action middleware for starting OrbStack machines

This middleware handles starting a stopped OrbStack machine. It calls the OrbStack CLI to start the machine and invalidates the provider's state cache to ensure subsequent state queries are fresh.

The OrbStack CLI is idempotent - starting an already running machine is safe and will not cause an error.

Examples:

Usage in action builder

Vagrant::Action::Builder.new.tap do |b|
  b.use VagrantPlugins::OrbStack::Action::Start
end

Instance Method Summary collapse

Methods included from MachineValidation

#validate_machine_id!

Constructor Details

#initialize(app, _env) ⇒ Start

Initialize the middleware.

Parameters:

  • app (Object)

    The next middleware in the chain

  • env (Hash)

    The environment hash containing :machine, :ui, etc.



32
33
34
# File 'lib/vagrant-orbstack/action/start.rb', line 32

def initialize(app, _env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Execute the middleware.

Starts the machine by calling OrbStack CLI start command, then invalidates the state cache to ensure fresh state queries.

Parameters:

  • env (Hash)

    The environment hash

Returns:

  • (Object)

    Result from next middleware

Raises:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vagrant-orbstack/action/start.rb', line 47

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

  # Validate machine ID exists
  machine_id = validate_machine_id!(machine, 'start')

  ui.info("Starting machine '#{machine_id}'...")

  # Call OrbStack CLI to start the machine
  Util::OrbStackCLI.start_machine(machine_id)

  # Invalidate state cache to ensure fresh state on next query
  machine.provider.invalidate_state_cache

  # Continue middleware chain
  @app.call(env)
end