mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-04 15:32:35 +00:00
Plugins base (#613)
* wip * wip * cleanup * notification channels * phpstan * services * remove server types * refactoring * refactoring
This commit is contained in:
@ -2,19 +2,21 @@
|
||||
|
||||
namespace App\SiteTypes;
|
||||
|
||||
use App\DTOs\DynamicFieldDTO;
|
||||
use App\DTOs\DynamicFieldsCollectionDTO;
|
||||
use App\Enums\LoadBalancerMethod;
|
||||
use App\Enums\SiteFeature;
|
||||
use App\Exceptions\SSHError;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class LoadBalancer extends AbstractSiteType
|
||||
{
|
||||
public static function id(): string
|
||||
{
|
||||
return 'load-balancer';
|
||||
}
|
||||
|
||||
public static function make(): self
|
||||
{
|
||||
return new self(new Site(['type' => \App\Enums\SiteType::LOAD_BALANCER]));
|
||||
return new self(new Site(['type' => self::id()]));
|
||||
}
|
||||
|
||||
public function language(): string
|
||||
@ -22,27 +24,6 @@ public function language(): string
|
||||
return 'yaml';
|
||||
}
|
||||
|
||||
public function supportedFeatures(): array
|
||||
{
|
||||
return [
|
||||
SiteFeature::SSL,
|
||||
];
|
||||
}
|
||||
|
||||
public function fields(): DynamicFieldsCollectionDTO
|
||||
{
|
||||
return new DynamicFieldsCollectionDTO([
|
||||
DynamicFieldDTO::make('method')
|
||||
->select()
|
||||
->label('Load Balancing Method')
|
||||
->options([
|
||||
LoadBalancerMethod::IP_HASH,
|
||||
LoadBalancerMethod::ROUND_ROBIN,
|
||||
LoadBalancerMethod::LEAST_CONNECTIONS,
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function createRules(array $input): array
|
||||
{
|
||||
return [
|
||||
@ -73,4 +54,36 @@ public function install(): void
|
||||
|
||||
$this->site->webserver()->createVHost($this->site);
|
||||
}
|
||||
|
||||
public function vhost(string $webserver): string
|
||||
{
|
||||
if ($webserver === 'nginx') {
|
||||
return view('ssh.services.webserver.nginx.vhost', [
|
||||
'header' => [
|
||||
view('ssh.services.webserver.nginx.vhost-blocks.force-ssl', ['site' => $this->site]),
|
||||
view('ssh.services.webserver.nginx.vhost-blocks.load-balancer-upstream', ['site' => $this->site]),
|
||||
],
|
||||
'main' => [
|
||||
view('ssh.services.webserver.nginx.vhost-blocks.port', ['site' => $this->site]),
|
||||
view('ssh.services.webserver.nginx.vhost-blocks.core', ['site' => $this->site]),
|
||||
view('ssh.services.webserver.nginx.vhost-blocks.load-balancer', ['site' => $this->site]),
|
||||
view('ssh.services.webserver.nginx.vhost-blocks.redirects', ['site' => $this->site]),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($webserver === 'caddy') {
|
||||
return view('ssh.services.webserver.caddy.vhost', [
|
||||
'main' => implode("\n", [
|
||||
view('ssh.services.webserver.caddy.vhost-blocks.force-ssl', ['site' => $this->site]),
|
||||
view('ssh.services.webserver.caddy.vhost-blocks.port', ['site' => $this->site]),
|
||||
view('ssh.services.webserver.caddy.vhost-blocks.core', ['site' => $this->site]),
|
||||
view('ssh.services.webserver.caddy.vhost-blocks.load-balancer', ['site' => $this->site]),
|
||||
view('ssh.services.webserver.caddy.vhost-blocks.redirects', ['site' => $this->site]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user