feat: variabel sync and support shared vars

This commit is contained in:
peaklabs-dev
2024-10-16 13:29:13 +02:00
parent b9c9c1041a
commit 6f97d589ae
3 changed files with 56 additions and 27 deletions

View File

@@ -1,5 +1,6 @@
<?php
use App\Models\EnvironmentVariable;
use App\Models\Server;
use App\Models\StandaloneClickhouse;
use App\Models\StandaloneDocker;
@@ -49,6 +50,7 @@ function create_standalone_redis($environment_id, $destination_uuid, ?array $oth
$database = new StandaloneRedis;
$database->name = generate_database_name('redis');
$database->redis_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
$database->redis_username = 'default';
$database->environment_id = $environment_id;
$database->destination_id = $destination->id;
$database->destination_type = $destination->getMorphClass();
@@ -57,6 +59,20 @@ function create_standalone_redis($environment_id, $destination_uuid, ?array $oth
}
$database->save();
EnvironmentVariable::create([
'key' => 'REDIS_PASSWORD',
'value' => $database->redis_password,
'standalone_redis_id' => $database->id,
'is_shared' => false,
]);
EnvironmentVariable::create([
'key' => 'REDIS_USERNAME',
'value' => $database->redis_username,
'standalone_redis_id' => $database->id,
'is_shared' => false,
]);
return $database;
}