<?php

namespace Database\Factories;

use App\Models\Host;
use App\Models\ProvisioningRun;
use Illuminate\Database\Eloquent\Factories\Factory;

/** @extends Factory<ProvisioningRun> */
class ProvisioningRunFactory extends Factory
{
    protected $model = ProvisioningRun::class;

    public function definition(): array
    {
        return [
            'subject_type' => Host::class,
            'subject_id' => Host::factory(),
            'pipeline' => 'host',
            'current_step' => 0,
            'status' => ProvisioningRun::STATUS_PENDING,
            'attempt' => 0,
            'max_attempts' => 5,
            'context' => [],
        ];
    }

    public function forHost(Host $host): static
    {
        return $this->state(fn () => [
            'subject_type' => Host::class,
            'subject_id' => $host->id,
        ]);
    }
}
