diff --git a/app/Http/Controllers/Api/EnvironmentVariablesController.php b/app/Http/Controllers/Api/EnvironmentVariablesController.php deleted file mode 100644 index d127d0525..000000000 --- a/app/Http/Controllers/Api/EnvironmentVariablesController.php +++ /dev/null @@ -1,35 +0,0 @@ -env_uuid)->first(); - if (! $env) { - return response()->json([ - 'message' => 'Environment variable not found.', - ], 404); - } - $found_app = $env->resource()->whereRelation('environment.project.team', 'id', $teamId)->first(); - if (! $found_app) { - return response()->json([ - 'message' => 'Environment variable not found.', - ], 404); - } - $env->delete(); - - return response()->json([ - 'message' => 'Environment variable deleted.', - ]); - } -} diff --git a/app/Models/EnvironmentVariable.php b/app/Models/EnvironmentVariable.php index 5e1d8ae13..3cd8c3140 100644 --- a/app/Models/EnvironmentVariable.php +++ b/app/Models/EnvironmentVariable.php @@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use OpenApi\Attributes as OA; -use Symfony\Component\Yaml\Yaml; use Visus\Cuid2\Cuid2; #[OA\Schema( @@ -97,8 +96,22 @@ public function resource() $resource = Application::find($this->application_id); } elseif ($this->service_id) { $resource = Service::find($this->service_id); - } elseif ($this->database_id) { - $resource = getResourceByUuid($this->parameters['database_uuid'], data_get(auth()->user()->currentTeam(), 'id')); + } elseif ($this->standalone_postgresql_id) { + $resource = StandalonePostgresql::find($this->standalone_postgresql_id); + } elseif ($this->standalone_redis_id) { + $resource = StandaloneRedis::find($this->standalone_redis_id); + } elseif ($this->standalone_mongodb_id) { + $resource = StandaloneMongodb::find($this->standalone_mongodb_id); + } elseif ($this->standalone_mysql_id) { + $resource = StandaloneMysql::find($this->standalone_mysql_id); + } elseif ($this->standalone_mariadb_id) { + $resource = StandaloneMariadb::find($this->standalone_mariadb_id); + } elseif ($this->standalone_keydb_id) { + $resource = StandaloneKeydb::find($this->standalone_keydb_id); + } elseif ($this->standalone_dragonfly_id) { + $resource = StandaloneDragonfly::find($this->standalone_dragonfly_id); + } elseif ($this->standalone_clickhouse_id) { + $resource = StandaloneClickhouse::find($this->standalone_clickhouse_id); } return $resource; @@ -122,63 +135,6 @@ public function realValue(): Attribute ); } - protected function isFoundInCompose(): Attribute - { - return Attribute::make( - get: function () { - if (! $this->application_id) { - return true; - } - $found_in_compose = false; - $found_in_args = false; - $resource = $this->resource(); - $compose = data_get($resource, 'docker_compose_raw'); - if (! $compose) { - return true; - } - $yaml = Yaml::parse($compose); - $services = collect(data_get($yaml, 'services')); - if ($services->isEmpty()) { - return false; - } - foreach ($services as $service) { - $environments = collect(data_get($service, 'environment')); - $args = collect(data_get($service, 'build.args')); - if ($environments->isEmpty() && $args->isEmpty()) { - $found_in_compose = false; - break; - } - - $found_in_compose = $environments->contains(function ($item) { - if (str($item)->contains('=')) { - $item = str($item)->before('='); - } - - return strpos($item, $this->key) !== false; - }); - - if ($found_in_compose) { - break; - } - - $found_in_args = $args->contains(function ($item) { - if (str($item)->contains('=')) { - $item = str($item)->before('='); - } - - return strpos($item, $this->key) !== false; - }); - - if ($found_in_args) { - break; - } - } - - return $found_in_compose || $found_in_args; - } - ); - } - protected function isShared(): Attribute { return Attribute::make( @@ -195,14 +151,17 @@ protected function isShared(): Attribute private function get_real_environment_variables(?string $environment_variable = null, $resource = null) { + ray($environment_variable, $resource); if ((is_null($environment_variable) && $environment_variable == '') || is_null($resource)) { return null; } $environment_variable = trim($environment_variable); $sharedEnvsFound = str($environment_variable)->matchAll('/{{(.*?)}}/'); if ($sharedEnvsFound->isEmpty()) { + return $environment_variable; } + foreach ($sharedEnvsFound as $sharedEnv) { $type = str($sharedEnv)->match('/(.*?)\./'); if (! collect(SHARED_VARIABLE_TYPES)->contains($type)) { diff --git a/resources/views/livewire/project/shared/environment-variable/show.blade.php b/resources/views/livewire/project/shared/environment-variable/show.blade.php index 1cb2f222c..3499d8c00 100644 --- a/resources/views/livewire/project/shared/environment-variable/show.blade.php +++ b/resources/views/livewire/project/shared/environment-variable/show.blade.php @@ -1,15 +1,6 @@
- {{-- @if (!$env->isFoundInCompose && !$isSharedVariable) -
This variable is not found in the compose file, so it won't be used.
- @endif --}} @if ($isLocked)
diff --git a/routes/api.php b/routes/api.php index 93db2001f..c2c2f12ef 100644 --- a/routes/api.php +++ b/routes/api.php @@ -120,8 +120,6 @@ Route::match(['get', 'post'], '/services/{uuid}/restart', [ServicesController::class, 'action_restart'])->middleware([IgnoreReadOnlyApiToken::class]); Route::match(['get', 'post'], '/services/{uuid}/stop', [ServicesController::class, 'action_stop'])->middleware([IgnoreReadOnlyApiToken::class]); - // Route::delete('/envs/{env_uuid}', [EnvironmentVariablesController::class, 'delete_env_by_uuid'])->middleware([IgnoreReadOnlyApiToken::class]); - }); Route::any('/{any}', function () {