82 lines
3.0 KiB
PHP
82 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Admin;
|
|
|
|
use App\Support\ProvisioningSettings;
|
|
use App\Support\Settings;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Component;
|
|
|
|
/**
|
|
* Deployment configuration that is not secret but still has to be settable —
|
|
* which DNS zone customer instances live under, where the WireGuard hub is
|
|
* reachable, where Traefik's dynamic config lives, the public half of the SSH
|
|
* identity, and the monitoring bridge's URL.
|
|
*
|
|
* Split from Admin\Secrets on purpose: these values are visible and editable
|
|
* without a password re-confirmation, because none of them opens anything by
|
|
* itself — the credentials that pair with some of them (the SSH private key,
|
|
* the monitoring bridge token) live in the vault instead, gated the way a
|
|
* live payment key is.
|
|
*
|
|
* Every field here is genuinely read from Settings by its consumer
|
|
* (App\Support\ProvisioningSettings) — see that class for the full list and
|
|
* for the two values (CLUPILOT_WG_SUBNET, CLUPILOT_WG_HUB_IP) deliberately
|
|
* left out because the compose file reads them too.
|
|
*/
|
|
#[Layout('layouts.admin')]
|
|
class Infrastructure extends Component
|
|
{
|
|
public string $dnsZone = '';
|
|
|
|
public string $wgEndpoint = '';
|
|
|
|
public string $wgHubPubkey = '';
|
|
|
|
public string $traefikDynamicPath = '';
|
|
|
|
public string $sshPublicKey = '';
|
|
|
|
public string $monitoringUrl = '';
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->authorize('hosts.manage');
|
|
|
|
$this->dnsZone = ProvisioningSettings::dnsZone();
|
|
$this->wgEndpoint = ProvisioningSettings::wgEndpoint();
|
|
$this->wgHubPubkey = ProvisioningSettings::wgHubPublicKey();
|
|
$this->traefikDynamicPath = ProvisioningSettings::traefikDynamicPath();
|
|
$this->sshPublicKey = ProvisioningSettings::sshPublicKey();
|
|
$this->monitoringUrl = ProvisioningSettings::monitoringUrl();
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$this->authorize('hosts.manage');
|
|
|
|
$data = $this->validate([
|
|
'dnsZone' => ['nullable', 'string', 'max:255'],
|
|
'wgEndpoint' => ['nullable', 'string', 'max:255'],
|
|
'wgHubPubkey' => ['nullable', 'string', 'max:255'],
|
|
'traefikDynamicPath' => ['nullable', 'string', 'max:255'],
|
|
'sshPublicKey' => ['nullable', 'string', 'max:1000'],
|
|
'monitoringUrl' => ['nullable', 'url', 'max:255'],
|
|
]);
|
|
|
|
Settings::set('provisioning.dns_zone', trim((string) $data['dnsZone']));
|
|
Settings::set('provisioning.wg_endpoint', trim((string) $data['wgEndpoint']));
|
|
Settings::set('provisioning.wg_hub_pubkey', trim((string) $data['wgHubPubkey']));
|
|
Settings::set('provisioning.traefik_dynamic_path', trim((string) $data['traefikDynamicPath']));
|
|
Settings::set('provisioning.ssh_public_key', trim((string) $data['sshPublicKey']));
|
|
Settings::set('monitoring.api_url', trim((string) $data['monitoringUrl']));
|
|
|
|
$this->dispatch('notify', message: __('infrastructure.saved'));
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.admin.infrastructure');
|
|
}
|
|
}
|