refactor: Improve handling of COOLIFY_URL in shared.php

This commit is contained in:
Andras Bacsai
2024-09-03 17:13:13 +02:00
parent 8150b6fdaf
commit 7b041f3f22

View File

@@ -3425,7 +3425,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
$defaultLabels = defaultLabels($resource->id, $containerName, type: 'service', subType: $isDatabase ? 'database' : 'application', subId: $savedService->id); $defaultLabels = defaultLabels($resource->id, $containerName, type: 'service', subType: $isDatabase ? 'database' : 'application', subId: $savedService->id);
} }
// Add COOLIFY_FQDN & COOLIFY_URL to environment // Add COOLIFY_FQDN & COOLIFY_URL to environment
if (! $isDatabase && $fqdns?->count() > 0) { if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) {
$environment->put('COOLIFY_URL', $fqdns->implode(',')); $environment->put('COOLIFY_URL', $fqdns->implode(','));
$urls = $fqdns->map(function ($fqdn) { $urls = $fqdns->map(function ($fqdn) {
@@ -3436,7 +3436,7 @@ function newParser(Application|Service $resource, int $pull_request_id = 0, ?int
add_coolify_default_environment_variables($resource, $environment, $resource->environment_variables); add_coolify_default_environment_variables($resource, $environment, $resource->environment_variables);
$serviceLabels = $labels->merge($defaultLabels); $serviceLabels = $labels->merge($defaultLabels);
if (! $isDatabase && $fqdns?->count() > 0) { if (! $isDatabase && $fqdns instanceof Collection && $fqdns->count() > 0) {
if ($isApplication) { if ($isApplication) {
$shouldGenerateLabelsExactly = $resource->destination->server->settings->generate_exact_labels; $shouldGenerateLabelsExactly = $resource->destination->server->settings->generate_exact_labels;
$uuid = $resource->uuid; $uuid = $resource->uuid;
@@ -3667,7 +3667,9 @@ function convertComposeEnvironmentToArray($environment)
} }
} }
} }
$convertedServiceVariables->put($key->value(), $value?->value() ?? null); if ($key) {
$convertedServiceVariables->put($key->value(), $value?->value() ?? null);
}
} }
return $convertedServiceVariables; return $convertedServiceVariables;