fix: labels and URL generation when cloning

This commit is contained in:
peaklabs-dev
2025-01-08 17:07:20 +01:00
parent 3d4e8b9867
commit 259d23d4c6

View File

@@ -108,7 +108,14 @@ class CloneMe extends Component
$databases = $this->environment->databases(); $databases = $this->environment->databases();
$services = $this->environment->services; $services = $this->environment->services;
foreach ($applications as $application) { foreach ($applications as $application) {
$applicationSettings = $application->settings;
$uuid = (string) new Cuid2; $uuid = (string) new Cuid2;
$url = $application->fqdn;
if ($this->server->proxyType() !== 'NONE' && $applicationSettings->is_container_label_readonly_enabled === true) {
$url = generateFqdn($this->server, $uuid);
}
$newApplication = $application->replicate([ $newApplication = $application->replicate([
'id', 'id',
'created_at', 'created_at',
@@ -117,21 +124,20 @@ class CloneMe extends Component
'additional_networks_count', 'additional_networks_count',
])->fill([ ])->fill([
'uuid' => $uuid, 'uuid' => $uuid,
'fqdn' => generateFqdn($this->server, $uuid), // this also needs a condition 'fqdn' => $url,
'status' => 'exited', 'status' => 'exited',
'environment_id' => $environment->id, 'environment_id' => $environment->id,
'destination_id' => $this->selectedDestination, 'destination_id' => $this->selectedDestination,
]); ]);
$newApplication->save(); $newApplication->save();
if ($newApplication->destination->server->proxyType() !== 'NONE' || ! $newApplication->application_settings->is_container_label_readonly_enabled) { // fix after switching this logic up if ($newApplication->destination->server->proxyType() !== 'NONE' && $applicationSettings->is_container_label_readonly_enabled === true) {
$customLabels = str(implode('|coolify|', generateLabelsApplication($newApplication)))->replace('|coolify|', "\n"); $customLabels = str(implode('|coolify|', generateLabelsApplication($newApplication)))->replace('|coolify|', "\n");
$newApplication->custom_labels = base64_encode($customLabels); $newApplication->custom_labels = base64_encode($customLabels);
$newApplication->save(); $newApplication->save();
} }
$newApplication->settings()->delete(); $newApplication->settings()->delete();
$applicationSettings = $application->settings;
if ($applicationSettings) { if ($applicationSettings) {
$newApplicationSettings = $applicationSettings->replicate([ $newApplicationSettings = $applicationSettings->replicate([
'id', 'id',