<?php

namespace App\Provisioning\Steps\Host;

use App\Models\ProvisioningRun;
use App\Provisioning\StepResult;
use App\Services\Ssh\RemoteShell;

/**
 * Baseline Proxmox configuration after the kernel switch: ensure the default
 * bridge exists and drop the enterprise repo. Idempotent and best-effort.
 */
class ConfigureProxmox extends HostStep
{
    public function __construct(private RemoteShell $shell) {}

    public function key(): string
    {
        return 'configure_proxmox';
    }

    public function execute(ProvisioningRun $run): StepResult
    {
        $host = $this->host($run);
        $this->keyLogin($this->shell, $host);

        // Most PVE installs create vmbr0; record its absence for real-host follow-up.
        $this->shell->run('ip link show vmbr0');
        $this->shell->run('rm -f /etc/apt/sources.list.d/pve-enterprise.list');

        return StepResult::advance();
    }
}
