Add redis username
This commit is contained in:
@@ -166,6 +166,14 @@ class StartRedis
|
||||
$environment_variables->push("$env->key=$env->real_value");
|
||||
}
|
||||
|
||||
$redis_version = $this->get_redis_version();
|
||||
|
||||
if (version_compare($redis_version, '6.0', '>=')) {
|
||||
if ($environment_variables->filter(fn ($env) => str($env)->contains('REDIS_USERNAME'))->isEmpty()) {
|
||||
$environment_variables->push("REDIS_USERNAME={$this->database->redis_username}");
|
||||
}
|
||||
}
|
||||
|
||||
if ($environment_variables->filter(fn ($env) => str($env)->contains('REDIS_PASSWORD'))->isEmpty()) {
|
||||
$environment_variables->push("REDIS_PASSWORD={$this->database->redis_password}");
|
||||
}
|
||||
@@ -173,6 +181,12 @@ class StartRedis
|
||||
return $environment_variables->all();
|
||||
}
|
||||
|
||||
private function get_redis_version()
|
||||
{
|
||||
$image_parts = explode(':', $this->database->image);
|
||||
return $image_parts[1] ?? '0.0';
|
||||
}
|
||||
|
||||
private function add_custom_redis()
|
||||
{
|
||||
if (is_null($this->database->redis_conf) || empty($this->database->redis_conf)) {
|
||||
|
@@ -25,6 +25,7 @@ class General extends Component
|
||||
'database.name' => 'required',
|
||||
'database.description' => 'nullable',
|
||||
'database.redis_conf' => 'nullable',
|
||||
'database.redis_username' => 'required',
|
||||
'database.redis_password' => 'required',
|
||||
'database.image' => 'required',
|
||||
'database.ports_mappings' => 'nullable',
|
||||
@@ -37,6 +38,7 @@ class General extends Component
|
||||
'database.name' => 'Name',
|
||||
'database.description' => 'Description',
|
||||
'database.redis_conf' => 'Redis Configuration',
|
||||
'database.redis_username' => 'Redis Username',
|
||||
'database.redis_password' => 'Redis Password',
|
||||
'database.image' => 'Image',
|
||||
'database.ports_mappings' => 'Port Mapping',
|
||||
@@ -73,16 +75,33 @@ class General extends Component
|
||||
{
|
||||
try {
|
||||
$this->validate();
|
||||
if ($this->database->redis_conf === '') {
|
||||
$this->database->redis_conf = null;
|
||||
|
||||
$redis_version = $this->get_redis_version();
|
||||
|
||||
if (version_compare($redis_version, '6.0', '>=')) {
|
||||
if ($this->database->isDirty('redis_username')) {
|
||||
$this->database->redis_username = $this->database->redis_username;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->database->isDirty('redis_password')) {
|
||||
$this->database->redis_password = $this->database->redis_password;
|
||||
}
|
||||
|
||||
$this->database->save();
|
||||
|
||||
$this->dispatch('success', 'Database updated.');
|
||||
} catch (Exception $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_redis_version()
|
||||
{
|
||||
$image_parts = explode(':', $this->database->image);
|
||||
return $image_parts[1] ?? '0.0';
|
||||
}
|
||||
|
||||
public function instantSave()
|
||||
{
|
||||
try {
|
||||
|
Reference in New Issue
Block a user