Skip to content

Commit 59702c6

Browse files
committed
refactor: Update ProxyTypes enum values to use TRAEFIK instead of TRAEFIK_V2
1 parent 13e8d3c commit 59702c6

File tree

11 files changed

+28
-22
lines changed

11 files changed

+28
-22
lines changed

app/Enums/ProxyTypes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
enum ProxyTypes: string
66
{
77
case NONE = 'NONE';
8-
case TRAEFIK_V2 = 'TRAEFIK_V2';
8+
case TRAEFIK = 'TRAEFIK';
99
case NGINX = 'NGINX';
1010
case CADDY = 'CADDY';
1111
}

app/Http/Controllers/Api/ServersController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ public function create_server(Request $request)
525525
'private_key_id' => $privateKey->id,
526526
'team_id' => $teamId,
527527
'proxy' => [
528-
'type' => ProxyTypes::TRAEFIK_V2->value,
528+
'type' => ProxyTypes::TRAEFIK->value,
529529
'status' => ProxyStatus::EXITED->value,
530530
],
531531
]);

app/Livewire/Boarding/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function selectExistingServer()
179179
public function getProxyType()
180180
{
181181
// Set Default Proxy Type
182-
$this->selectProxy(ProxyTypes::TRAEFIK_V2->value);
182+
$this->selectProxy(ProxyTypes::TRAEFIK->value);
183183
// $proxyTypeSet = $this->createdServer->proxy->type;
184184
// if (!$proxyTypeSet) {
185185
// $this->currentState = 'select-proxy';

app/Livewire/Server/New/ByIp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function submit()
104104
'private_key_id' => $this->private_key_id,
105105
'proxy' => [
106106
// set default proxy type to traefik v2
107-
'type' => ProxyTypes::TRAEFIK_V2->value,
107+
'type' => ProxyTypes::TRAEFIK->value,
108108
'status' => ProxyStatus::EXITED->value,
109109
],
110110
];

app/Livewire/Server/Proxy/NewDynamicConfiguration.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Livewire\Server\Proxy;
44

5+
use App\Enums\ProxyTypes;
56
use App\Models\Server;
67
use Livewire\Component;
78
use Symfony\Component\Yaml\Yaml;
@@ -45,7 +46,7 @@ public function addDynamicConfiguration()
4546
return redirect()->route('server.index');
4647
}
4748
$proxy_type = $this->server->proxyType();
48-
if ($proxy_type === 'TRAEFIK_V2') {
49+
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
4950
if (! str($this->fileName)->endsWith('.yaml') && ! str($this->fileName)->endsWith('.yml')) {
5051
$this->fileName = "{$this->fileName}.yaml";
5152
}
@@ -69,7 +70,7 @@ public function addDynamicConfiguration()
6970
return;
7071
}
7172
}
72-
if ($proxy_type === 'TRAEFIK_V2') {
73+
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
7374
$yaml = Yaml::parse($this->value);
7475
$yaml = Yaml::dump($yaml, 10, 2);
7576
$this->value = $yaml;

app/Models/Server.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function setupDefault404Redirect()
151151
$dynamic_conf_path = $this->proxyPath().'/dynamic';
152152
$proxy_type = $this->proxyType();
153153
$redirect_url = $this->proxy->redirect_url;
154-
if ($proxy_type === 'TRAEFIK_V2') {
154+
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
155155
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.yaml";
156156
} elseif ($proxy_type === 'CADDY') {
157157
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.caddy";
@@ -181,7 +181,7 @@ public function setupDefault404Redirect()
181181

182182
return;
183183
}
184-
if ($proxy_type === 'TRAEFIK_V2') {
184+
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
185185
$dynamic_conf = [
186186
'http' => [
187187
'routers' => [
@@ -255,7 +255,7 @@ public function setupDynamicProxyConfiguration()
255255
{
256256
$settings = \App\Models\InstanceSettings::get();
257257
$dynamic_config_path = $this->proxyPath().'/dynamic';
258-
if ($this->proxyType() === 'TRAEFIK_V2') {
258+
if ($this->proxyType() === ProxyTypes::TRAEFIK->value) {
259259
$file = "$dynamic_config_path/coolify.yaml";
260260
if (empty($settings->fqdn) || (isCloud() && $this->id !== 0) || ! $this->isLocalhost()) {
261261
instant_remote_process([
@@ -403,7 +403,7 @@ public function proxyPath()
403403
// TODO: should use /traefik for already exisiting configurations?
404404
// Should move everything except /caddy and /nginx to /traefik
405405
// The code needs to be modified as well, so maybe it does not worth it
406-
if ($proxyType === ProxyTypes::TRAEFIK_V2->value) {
406+
if ($proxyType === ProxyTypes::TRAEFIK->value) {
407407
$proxy_path = $proxy_path;
408408
} elseif ($proxyType === ProxyTypes::CADDY->value) {
409409
$proxy_path = $proxy_path.'/caddy';
@@ -421,7 +421,7 @@ public function proxyType()
421421
// return $proxyType;
422422
// }
423423
// if (is_null($proxyType)) {
424-
// $this->proxy->type = ProxyTypes::TRAEFIK_V2->value;
424+
// $this->proxy->type = ProxyTypes::TRAEFIK->value;
425425
// $this->proxy->status = ProxyStatus::EXITED->value;
426426
// $this->save();
427427
// }

bootstrap/helpers/proxy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function generate_default_proxy_configuration(Server $server)
136136
'external' => true,
137137
];
138138
});
139-
if ($proxy_type === 'TRAEFIK_V2') {
139+
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
140140
$labels = [
141141
'traefik.enable=true',
142142
'traefik.http.routers.traefik.entrypoints=http',

database/seeders/ProductionSeeder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function run(): void
100100
'private_key_id' => 0,
101101
];
102102
$server_details['proxy'] = ServerMetadata::from([
103-
'type' => ProxyTypes::TRAEFIK_V2->value,
103+
'type' => ProxyTypes::TRAEFIK->value,
104104
'status' => ProxyStatus::EXITED->value,
105105
]);
106106
$server = Server::create($server_details);
@@ -153,7 +153,7 @@ public function run(): void
153153
'private_key_id' => 0,
154154
];
155155
$server_details['proxy'] = ServerMetadata::from([
156-
'type' => ProxyTypes::TRAEFIK_V2->value,
156+
'type' => ProxyTypes::TRAEFIK->value,
157157
'status' => ProxyStatus::EXITED->value,
158158
]);
159159
$server = Server::create($server_details);

resources/views/components/server/sidebar.blade.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<button>Configuration</button>
66
</a>
77
@if ($server->proxyType() !== 'NONE')
8-
{{-- @if ($server->proxyType() === 'TRAEFIK_V2') --}}
9-
<a class="{{ request()->routeIs('server.proxy.dynamic-confs') ? 'dark:text-white' : '' }}"
10-
href="{{ route('server.proxy.dynamic-confs', $parameters) }}">
11-
<button>Dynamic Configurations</button>
12-
</a>
8+
{{-- @if ($server->proxyType() === 'TRAEFIK') --}}
9+
<a class="{{ request()->routeIs('server.proxy.dynamic-confs') ? 'dark:text-white' : '' }}"
10+
href="{{ route('server.proxy.dynamic-confs', $parameters) }}">
11+
<button>Dynamic Configurations</button>
12+
</a>
1313
{{-- @endif --}}
1414
<a class="{{ request()->routeIs('server.proxy.logs') ? 'dark:text-white' : '' }}"
1515
href="{{ route('server.proxy.logs', $parameters) }}">

resources/views/livewire/server/proxy.blade.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@php use App\Enums\ProxyTypes; @endphp
12
<div>
23
@if ($server->proxyType())
34
<div x-init="$wire.loadProxyConfiguration">
@@ -20,7 +21,7 @@
2021
</svg>Before switching proxies, please read <a class="underline dark:text-white"
2122
href="https://coolify.io/docs/knowledge-base/server/proxies#switch-between-proxies">this</a>.
2223
</div>
23-
@if ($server->proxyType() === 'TRAEFIK_V2')
24+
@if ($server->proxyType() === ProxyTypes::TRAEFIK->value)
2425
<h4>Traefik</h4>
2526
@elseif ($server->proxyType() === 'CADDY')
2627
<h4>Caddy</h4>
@@ -69,7 +70,7 @@
6970
<x-forms.button class="box" wire:click="select_proxy('NONE')">
7071
Custom (None)
7172
</x-forms.button>
72-
<x-forms.button class="box" wire:click="select_proxy('TRAEFIK_V2')">
73+
<x-forms.button class="box" wire:click="select_proxy('TRAEFIK')">
7374
Traefik
7475
</x-forms.button>
7576
<x-forms.button class="box" wire:click="select_proxy('CADDY')">

0 commit comments

Comments
 (0)