mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-14 08:18:08 +00:00
feat: predefined server variables (COOLIFY_SERVER_NAME, COOLIFY_SERVER_UUID)
These are not visible on shared env page but user can use these variables like they use the COOLIFY_RESOURCE_UUID
This commit is contained in:
1 parent
81009c29cf
commit
5ed308dcf0
7 files changed
+62
-8
No files matched your search
@@ -56,7 +56,7 @@ class Environment extends BaseModel
|
||||
|
||||
public function environment_variables()
|
||||
{
|
||||
return $this->hasMany(SharedEnvironmentVariable::class);
|
||||
return $this->hasMany(SharedEnvironmentVariable::class)->where('type', 'environment');
|
||||
}
|
||||
|
||||
public function applications()
|
||||
|
||||
@@ -73,7 +73,7 @@ class Project extends BaseModel
|
||||
|
||||
public function environment_variables()
|
||||
{
|
||||
return $this->hasMany(SharedEnvironmentVariable::class);
|
||||
return $this->hasMany(SharedEnvironmentVariable::class)->where('type', 'project');
|
||||
}
|
||||
|
||||
public function environments()
|
||||
|
||||
+18
-1
@@ -19,6 +19,7 @@ use App\Traits\ClearsGlobalSearchCache;
|
||||
use App\Traits\HasSafeStringAttribute;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -168,9 +169,25 @@ class Server extends BaseModel
|
||||
$standaloneDocker->saveQuietly();
|
||||
}
|
||||
}
|
||||
if (! isset($server->proxy->redirect_enabled)) {
|
||||
if (! isset($server->proxy->redirect_enabled)) {
|
||||
$server->proxy->redirect_enabled = true;
|
||||
}
|
||||
|
||||
// Create predefined server shared variables
|
||||
SharedEnvironmentVariable::create([
|
||||
'key' => 'COOLIFY_SERVER_UUID',
|
||||
'value' => $server->uuid,
|
||||
'type' => 'server',
|
||||
'server_id' => $server->id,
|
||||
'team_id' => $server->team_id,
|
||||
]);
|
||||
SharedEnvironmentVariable::create([
|
||||
'key' => 'COOLIFY_SERVER_NAME',
|
||||
'value' => $server->name,
|
||||
'type' => 'server',
|
||||
'server_id' => $server->id,
|
||||
'team_id' => $server->team_id,
|
||||
]);
|
||||
});
|
||||
static::retrieved(function ($server) {
|
||||
if (! isset($server->proxy->redirect_enabled)) {
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen
|
||||
|
||||
public function environment_variables()
|
||||
{
|
||||
return $this->hasMany(SharedEnvironmentVariable::class)->whereNull('project_id')->whereNull('environment_id');
|
||||
return $this->hasMany(SharedEnvironmentVariable::class)->where('type', 'team');
|
||||
}
|
||||
|
||||
public function members()
|
||||
|
||||
Reference in new issue
Block a user