From 79caa3c26bcf0224cdfb3de30170d3fde884c66f Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:02:37 +0200 Subject: [PATCH] fix: allow setting standalone redis variables via ENVs (team variables...) --- app/Actions/Database/StartRedis.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php index 3e3c5b3b9..45a031e70 100644 --- a/app/Actions/Database/StartRedis.php +++ b/app/Actions/Database/StartRedis.php @@ -159,12 +159,29 @@ class StartRedis private function generate_environment_variables() { $environment_variables = collect(); + $redis_password = null; + $redis_username = null; + foreach ($this->database->runtime_environment_variables as $env) { $environment_variables->push("$env->key=$env->real_value"); + + if ($env->key === 'REDIS_PASSWORD') { + $redis_password = $env->real_value; + } elseif ($env->key === 'REDIS_USERNAME') { + $redis_username = $env->real_value; + } } - if ($environment_variables->filter(fn ($env) => str($env)->contains('REDIS_PASSWORD'))->isEmpty()) { + if (is_null($redis_password)) { $environment_variables->push("REDIS_PASSWORD={$this->database->redis_password}"); + } else { + $this->database->update(['redis_password' => $redis_password]); + } + + if (is_null($redis_username)) { + $environment_variables->push("REDIS_USERNAME={$this->database->redis_username}"); + } else { + $this->database->update(['redis_username' => $redis_username]); } add_coolify_default_environment_variables($this->database, $environment_variables, $environment_variables);