Class: VagrantPlugins::OrbStack::Action::Create

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

Overview

Action middleware for creating and starting OrbStack machines

This middleware handles the machine creation lifecycle with full idempotency support. It checks the current machine state and:

  • If running: does nothing (no-op)
  • If stopped: starts the existing machine
  • If not created: creates a new machine with unique name

After creation, persists machine metadata and invalidates state cache.

Examples:

Usage in action builder

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

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ Create

Initialize the middleware.

Parameters:

  • app (Object)

    The next middleware in the chain

  • env (Hash)

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



33
34
35
# File 'lib/vagrant-orbstack/action/create.rb', line 33

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

Instance Method Details

#call(env) ⇒ Object

Execute the middleware.

Implements idempotent machine creation:

  1. Query current state
  2. If running: no-op
  3. If stopped: start machine
  4. If not created: create new machine
  5. Persist metadata and invalidate cache
  6. Continue middleware chain

Parameters:

  • env (Hash)

    The environment hash

Returns:

  • (Object)

    Result from next middleware

Raises:



54
55
56
57
# File 'lib/vagrant-orbstack/action/create.rb', line 54

def call(env)
  handle_machine_state(env)
  @app.call(env)
end