An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Refactor shared variable type validation
Andras Bacsaif1e4395a83ee
diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Add.php b/app/Livewire/Project/Shared/EnvironmentVariable/Add.phpindex 0b6a3897d1..923f0d455c 100644--- a/app/Livewire/Project/Shared/EnvironmentVariable/Add.php+++ b/app/Livewire/Project/Shared/EnvironmentVariable/Add.php@@ -34,7 +34,7 @@ class Add extends Component$this->validate();if (str($this->value)->startsWith('{{') && str($this->value)->endsWith('}}')) {$type = str($this->value)->after("{{")->before(".")->value;- if (!collect(['team', 'project', 'environment'])->contains($type)) {+ if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");return;}diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/All.php b/app/Livewire/Project/Shared/EnvironmentVariable/All.phpindex 0a9e734612..c30011a4a0 100644--- a/app/Livewire/Project/Shared/EnvironmentVariable/All.php+++ b/app/Livewire/Project/Shared/EnvironmentVariable/All.php@@ -73,7 +73,7 @@ class All extends Component$found->value = $variable;if (str($found->value)->startsWith('{{') && str($found->value)->endsWith('}}')) {$type = str($found->value)->after("{{")->before(".")->value;- if (!collect(['team', 'project', 'environment'])->contains($type)) {+ if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");return;}@@ -86,7 +86,7 @@ class All extends Component$environment->value = $variable;if (str($environment->value)->startsWith('{{') && str($environment->value)->endsWith('}}')) {$type = str($environment->value)->after("{{")->before(".")->value;- if (!collect(['team', 'project', 'environment'])->contains($type)) {+ if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");return;}diff --git a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php b/app/Livewire/Project/Shared/EnvironmentVariable/Show.phpindex b0c57e2522..1494707e78 100644--- a/app/Livewire/Project/Shared/EnvironmentVariable/Show.php+++ b/app/Livewire/Project/Shared/EnvironmentVariable/Show.php@@ -83,7 +83,7 @@ class Show extends Component}if (str($this->env->value)->startsWith('{{') && str($this->env->value)->endsWith('}}')) {$type = str($this->env->value)->after("{{")->before(".")->value;- if (!collect(['team', 'project', 'environment'])->contains($type)) {+ if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {$this->dispatch('error', 'Invalid shared variable type.', "Valid types are: team, project, environment.");return;}diff --git a/app/Models/EnvironmentVariable.php b/app/Models/EnvironmentVariable.phpindex b5ecffabaf..fafa6f30c9 100644--- a/app/Models/EnvironmentVariable.php+++ b/app/Models/EnvironmentVariable.php@@ -100,7 +100,7 @@ class EnvironmentVariable extends Model$variable = Str::after($environment_variable, "{$type}.");$variable = Str::before($variable, '}}');$variable = Str::of($variable)->trim()->value;- if (!collect(['team', 'project', 'environment'])->contains($type)) {+ if (!collect(SHARED_VARIABLE_TYPES)->contains($type)) {return $variable;}if ($type === 'environment') {diff --git a/bootstrap/helpers/constants.php b/bootstrap/helpers/constants.phpindex 380168005f..9b16ebfed4 100644--- a/bootstrap/helpers/constants.php+++ b/bootstrap/helpers/constants.php@@ -34,3 +34,5 @@ const SUPPORTED_OS = ['centos fedora rhel ol rocky','sles opensuse-leap opensuse-tumbleweed'];++const SHARED_VARIABLE_TYPES = ['team', 'project', 'environment'];