From d8b97e06cfdee64a9d4425431e2bb522ab9e3e54 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 11 Dec 2023 23:34:18 +0100 Subject: [PATCH] wip: fix for comma in labels --- app/Jobs/ApplicationDeploymentJob.php | 5 +++-- app/Livewire/Project/Application/General.php | 22 +++++++++++++------- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 08c388084..be38ee581 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -874,11 +874,12 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted $environment_variables = $this->generate_environment_variables($ports); if (data_get($this->application, 'custom_labels')) { - $labels = collect(str($this->application->custom_labels)->explode(',')); + ray(base64_decode($this->application->custom_labels)); + $labels = collect(preg_split("/\r\n|\n|\r/", base64_decode($this->application->custom_labels))); $labels = $labels->filter(function ($value, $key) { return !Str::startsWith($value, 'coolify.'); }); - $this->application->custom_labels = $labels->implode(','); + $this->application->custom_labels = base64_encode($labels); $this->application->save(); } else { $labels = collect(generateLabelsApplication($this->application, $this->preview)); diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index bc6838d5d..3d68771f4 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -95,7 +95,6 @@ class General extends Component 'application.dockerfile_target_build' => 'Dockerfile target build', 'application.settings.is_static' => 'Is static', ]; - public function mount() { try { @@ -110,11 +109,17 @@ class General extends Component $this->application->isConfigurationChanged(true); } $this->isConfigurationChanged = $this->application->isConfigurationChanged(); - if (is_null(data_get($this->application, 'custom_labels'))) { - $this->customLabels = str(implode(",", generateLabelsApplication($this->application)))->replace(',', "\n"); + + if (base64_encode(base64_decode(data_get($this->application, 'custom_labels'), true)) === data_get($this->application, 'custom_labels')) { + ray('custom_labels is base64 encoded'); } else { - $this->customLabels = str($this->application->custom_labels)->replace(',', "\n"); + ray('custom_labels is not base64 encoded'); + $this->application->custom_labels = str($this->application->custom_labels)->replace(',', "\n"); + $this->application->custom_labels = base64_encode(data_get($this->application, 'custom_labels')); + $this->application->save(); } + + $this->customLabels = base64_decode(data_get($this->application, 'custom_labels')); $this->initialDockerComposeLocation = $this->application->docker_compose_location; $this->checkLabelUpdates(); } @@ -233,10 +238,11 @@ class General extends Component if ($this->application->publish_directory && $this->application->publish_directory !== '/') { $this->application->publish_directory = rtrim($this->application->publish_directory, '/'); } - if (gettype($this->customLabels) === 'string') { - $this->customLabels = str($this->customLabels)->replace(',', "\n"); - } - $this->application->custom_labels = $this->customLabels->explode("\n")->implode(','); + $this->application->custom_labels = base64_encode($this->customLabels); + // if (gettype($this->customLabels) === 'string') { + // $this->customLabels = str($this->customLabels)->replace(',', "\n"); + // } + // $this->application->custom_labels = $this->customLabels->explode("\n")->implode(','); if ($this->application->build_pack === 'dockercompose') { $this->application->docker_compose_domains = json_encode($this->parsedServiceDomains); $this->parsedServices = $this->application->parseCompose(); diff --git a/config/sentry.php b/config/sentry.php index 1cd69403b..43ac820bd 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.157', + 'release' => '4.0.0-beta.158', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index 5c2f640e6..5eb844939 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@