From 0c90d3d0a14d40fdf69eea5e69d1aab44e52359d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 16:15:13 +0100 Subject: [PATCH 1/2] fix: docker compose apps env rewritten --- .../Shared/EnvironmentVariable/Show.php | 8 ++++-- bootstrap/helpers/shared.php | 27 ++++++++++++------- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php index 865ba9bcf..10a8856da 100644 --- a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php +++ b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php @@ -65,7 +65,11 @@ class Show extends Component public function delete() { - $this->env->delete(); - $this->dispatch('refreshEnvs'); + try { + $this->env->delete(); + $this->dispatch('refreshEnvs'); + } catch (\Exception $e) { + return handleError($e); + } } } diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 504bed654..a00727c10 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1330,7 +1330,8 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal if ($value?->startsWith('$')) { $foundEnv = EnvironmentVariable::where([ 'key' => $key, - 'service_id' => $resource->id, + 'application_id' => $resource->id, + 'is_preview' => false, ])->first(); $value = Str::of(replaceVariables($value)); $key = $value; @@ -1397,14 +1398,22 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $defaultValue = data_get($foundEnv, 'value'); } $isBuildTime = data_get($foundEnv, 'is_build_time', false); - EnvironmentVariable::updateOrCreate([ - 'key' => $key->value(), - 'application_id' => $resource->id, - ], [ - 'value' => $defaultValue, - 'is_build_time' => $isBuildTime, - 'application_id' => $resource->id, - ]); + if ($foundEnv) { + $foundEnv->update([ + 'key' => $key, + 'application_id' => $resource->id, + 'is_build_time' => $isBuildTime, + 'value' => $defaultValue, + ]); + } else { + EnvironmentVariable::create([ + 'key' => $key, + 'value' => $defaultValue, + 'is_build_time' => $isBuildTime, + 'application_id' => $resource->id, + 'is_preview' => false, + ]); + } } } } diff --git a/config/sentry.php b/config/sentry.php index b4f65950d..a0aeeb38b 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.168', + 'release' => '4.0.0-beta.169', // 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 cc7516a95..bf8f3671d 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Wed, 20 Dec 2023 16:19:48 +0100 Subject: [PATCH 2/2] fix: storage error on dbs --- app/Livewire/Project/Shared/Storages/Add.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/Livewire/Project/Shared/Storages/Add.php b/app/Livewire/Project/Shared/Storages/Add.php index e2e84c358..2bfbf7baf 100644 --- a/app/Livewire/Project/Shared/Storages/Add.php +++ b/app/Livewire/Project/Shared/Storages/Add.php @@ -31,14 +31,16 @@ class Add extends Component public function mount() { $this->parameters = get_route_parameters(); - $applicationUuid = $this->parameters['application_uuid']; - $application = Application::where('uuid', $applicationUuid)->first(); - if (!$application) { - abort(404); - } - if ($application->destination->server->isSwarm()) { - $this->isSwarm = true; - $this->rules['host_path'] = 'required|string'; + if (data_get($this->parameters, 'application_uuid')) { + $applicationUuid = $this->parameters['application_uuid']; + $application = Application::where('uuid', $applicationUuid)->first(); + if (!$application) { + abort(404); + } + if ($application->destination->server->isSwarm()) { + $this->isSwarm = true; + $this->rules['host_path'] = 'required|string'; + } } }