Update service and shared helper files

This commit is contained in:
Andras Bacsai 2024-02-21 12:22:32 +01:00
parent 74b24a0690
commit 4d319a8caa
2 changed files with 13 additions and 9 deletions

View File

@ -4,8 +4,8 @@
use App\Models\Service;
use App\Models\ServiceApplication;
use App\Models\ServiceDatabase;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Spatie\Url\Url;
use Symfony\Component\Yaml\Yaml;
function replaceRegex(?string $name = null)
@ -95,12 +95,17 @@ function updateCompose($resource)
// Update FQDN
$variableName = "SERVICE_FQDN_" . Str::of($resource->name)->upper();
$generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first();
$fqdn = Url::fromString($resource->fqdn);
$fqdn = $fqdn->getScheme() . '://' . $fqdn->getHost();
if ($generatedEnv) {
$generatedEnv->value = $resource->fqdn;
$generatedEnv->value = $fqdn;
$generatedEnv->save();
}
$variableName = "SERVICE_URL_" . Str::of($resource->name)->upper();
$generatedEnv = EnvironmentVariable::where('service_id', $resource->service_id)->where('key', $variableName)->first();
$url = Url::fromString($resource->fqdn);
$url = $url->getHost();
ray($url);
if ($generatedEnv) {
$url = Str::of($resource->fqdn)->after('://');
$generatedEnv->value = $url;

View File

@ -974,13 +974,12 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal
'is_preview' => false,
]);
}
// if (!$isDatabase) {
// ray($savedService,$fqdn);
// if ($command->value() === 'FQDN' && is_null($savedService->fqdn)) {
// $savedService->fqdn = $fqdn;
// $savedService->save();
// }
// }
if (!$isDatabase) {
if ($command->value() === 'FQDN' && is_null($savedService->fqdn) && !$foundEnv) {
$savedService->fqdn = $fqdn;
$savedService->save();
}
}
} else {
$generatedValue = generateEnvValue($command);
if (!$foundEnv) {