Merge pull request #2863 from lorenzomigliorero/feat/labels-by-proxy-type
Generate labels by proxy type
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Enums\ProxyTypes;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationPreview;
|
use App\Models\ApplicationPreview;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
@@ -539,6 +540,8 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview
|
|||||||
if ($pull_request_id === 0) {
|
if ($pull_request_id === 0) {
|
||||||
if ($application->fqdn) {
|
if ($application->fqdn) {
|
||||||
$domains = str(data_get($application, 'fqdn'))->explode(',');
|
$domains = str(data_get($application, 'fqdn'))->explode(',');
|
||||||
|
switch ($application->destination->server->proxyType()) {
|
||||||
|
case ProxyTypes::TRAEFIK_V2->value:
|
||||||
$labels = $labels->merge(fqdnLabelsForTraefik(
|
$labels = $labels->merge(fqdnLabelsForTraefik(
|
||||||
uuid: $appUuid,
|
uuid: $appUuid,
|
||||||
domains: $domains,
|
domains: $domains,
|
||||||
@@ -548,7 +551,8 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview
|
|||||||
is_stripprefix_enabled: $application->isStripprefixEnabled(),
|
is_stripprefix_enabled: $application->isStripprefixEnabled(),
|
||||||
redirect_direction: $application->redirect
|
redirect_direction: $application->redirect
|
||||||
));
|
));
|
||||||
// Add Caddy labels
|
break;
|
||||||
|
case ProxyTypes::CADDY->value:
|
||||||
$labels = $labels->merge(fqdnLabelsForCaddy(
|
$labels = $labels->merge(fqdnLabelsForCaddy(
|
||||||
network: $application->destination->network,
|
network: $application->destination->network,
|
||||||
uuid: $appUuid,
|
uuid: $appUuid,
|
||||||
@@ -559,6 +563,8 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview
|
|||||||
is_stripprefix_enabled: $application->isStripprefixEnabled(),
|
is_stripprefix_enabled: $application->isStripprefixEnabled(),
|
||||||
redirect_direction: $application->redirect
|
redirect_direction: $application->redirect
|
||||||
));
|
));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (data_get($preview, 'fqdn')) {
|
if (data_get($preview, 'fqdn')) {
|
||||||
@@ -566,6 +572,9 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview
|
|||||||
} else {
|
} else {
|
||||||
$domains = collect([]);
|
$domains = collect([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch ($application->destination->server->proxyType()) {
|
||||||
|
case ProxyTypes::TRAEFIK_V2->value:
|
||||||
$labels = $labels->merge(fqdnLabelsForTraefik(
|
$labels = $labels->merge(fqdnLabelsForTraefik(
|
||||||
uuid: $appUuid,
|
uuid: $appUuid,
|
||||||
domains: $domains,
|
domains: $domains,
|
||||||
@@ -574,7 +583,8 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview
|
|||||||
is_gzip_enabled: $application->isGzipEnabled(),
|
is_gzip_enabled: $application->isGzipEnabled(),
|
||||||
is_stripprefix_enabled: $application->isStripprefixEnabled()
|
is_stripprefix_enabled: $application->isStripprefixEnabled()
|
||||||
));
|
));
|
||||||
// Add Caddy labels
|
break;
|
||||||
|
case ProxyTypes::CADDY->value:
|
||||||
$labels = $labels->merge(fqdnLabelsForCaddy(
|
$labels = $labels->merge(fqdnLabelsForCaddy(
|
||||||
network: $application->destination->network,
|
network: $application->destination->network,
|
||||||
uuid: $appUuid,
|
uuid: $appUuid,
|
||||||
@@ -584,6 +594,8 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview
|
|||||||
is_gzip_enabled: $application->isGzipEnabled(),
|
is_gzip_enabled: $application->isGzipEnabled(),
|
||||||
is_stripprefix_enabled: $application->isStripprefixEnabled()
|
is_stripprefix_enabled: $application->isStripprefixEnabled()
|
||||||
));
|
));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Enums\ApplicationDeploymentStatus;
|
use App\Enums\ApplicationDeploymentStatus;
|
||||||
|
use App\Enums\ProxyTypes;
|
||||||
use App\Jobs\ServerFilesFromServerJob;
|
use App\Jobs\ServerFilesFromServerJob;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationDeploymentQueue;
|
use App\Models\ApplicationDeploymentQueue;
|
||||||
@@ -1304,6 +1305,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
$serviceLabels = $serviceLabels->merge($defaultLabels);
|
$serviceLabels = $serviceLabels->merge($defaultLabels);
|
||||||
if (! $isDatabase && $fqdns->count() > 0) {
|
if (! $isDatabase && $fqdns->count() > 0) {
|
||||||
if ($fqdns) {
|
if ($fqdns) {
|
||||||
|
switch ($resource->destination->server->proxyType()) {
|
||||||
|
case ProxyTypes::TRAEFIK_V2->value:
|
||||||
$serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(
|
$serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(
|
||||||
uuid: $resource->uuid,
|
uuid: $resource->uuid,
|
||||||
domains: $fqdns,
|
domains: $fqdns,
|
||||||
@@ -1314,6 +1317,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
service_name: $serviceName,
|
service_name: $serviceName,
|
||||||
image: data_get($service, 'image')
|
image: data_get($service, 'image')
|
||||||
));
|
));
|
||||||
|
break;
|
||||||
|
case ProxyTypes::CADDY->value:
|
||||||
$serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy(
|
$serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy(
|
||||||
network: $resource->destination->network,
|
network: $resource->destination->network,
|
||||||
uuid: $resource->uuid,
|
uuid: $resource->uuid,
|
||||||
@@ -1325,6 +1330,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
service_name: $serviceName,
|
service_name: $serviceName,
|
||||||
image: data_get($service, 'image')
|
image: data_get($service, 'image')
|
||||||
));
|
));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($resource->server->isLogDrainEnabled() && $savedService->isLogDrainEnabled()) {
|
if ($resource->server->isLogDrainEnabled() && $savedService->isLogDrainEnabled()) {
|
||||||
@@ -2030,7 +2037,10 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$serviceLabels = $serviceLabels->merge(fqdnLabelsForTraefik(
|
switch ($server->proxyType()) {
|
||||||
|
case ProxyTypes::TRAEFIK_V2->value:
|
||||||
|
$serviceLabels = $serviceLabels->merge(
|
||||||
|
fqdnLabelsForTraefik(
|
||||||
uuid: $resource->uuid,
|
uuid: $resource->uuid,
|
||||||
domains: $fqdns,
|
domains: $fqdns,
|
||||||
serviceLabels: $serviceLabels,
|
serviceLabels: $serviceLabels,
|
||||||
@@ -2039,8 +2049,12 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
is_force_https_enabled: $resource->isForceHttpsEnabled(),
|
is_force_https_enabled: $resource->isForceHttpsEnabled(),
|
||||||
is_gzip_enabled: $resource->isGzipEnabled(),
|
is_gzip_enabled: $resource->isGzipEnabled(),
|
||||||
is_stripprefix_enabled: $resource->isStripprefixEnabled(),
|
is_stripprefix_enabled: $resource->isStripprefixEnabled(),
|
||||||
));
|
)
|
||||||
$serviceLabels = $serviceLabels->merge(fqdnLabelsForCaddy(
|
);
|
||||||
|
break;
|
||||||
|
case ProxyTypes::CADDY->value:
|
||||||
|
$serviceLabels = $serviceLabels->merge(
|
||||||
|
fqdnLabelsForCaddy(
|
||||||
network: $resource->destination->network,
|
network: $resource->destination->network,
|
||||||
uuid: $resource->uuid,
|
uuid: $resource->uuid,
|
||||||
domains: $fqdns,
|
domains: $fqdns,
|
||||||
@@ -2049,7 +2063,10 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
|
|||||||
is_force_https_enabled: $resource->isForceHttpsEnabled(),
|
is_force_https_enabled: $resource->isForceHttpsEnabled(),
|
||||||
is_gzip_enabled: $resource->isGzipEnabled(),
|
is_gzip_enabled: $resource->isGzipEnabled(),
|
||||||
is_stripprefix_enabled: $resource->isStripprefixEnabled(),
|
is_stripprefix_enabled: $resource->isStripprefixEnabled(),
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user