mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-22 08:04:19 +02:00
test add_coolif_default_environment_variables
This commit is contained in:
parent
b51065a003
commit
f6d649307c
@ -160,20 +160,7 @@ private function generate_environment_variables()
|
||||
$environment_variables->push("CLICKHOUSE_ADMIN_PASSWORD={$this->database->clickhouse_admin_password}");
|
||||
}
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_APP_NAME={$this->database->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}");
|
||||
}
|
||||
|
||||
add_coolify_default_environment_variables($this->database, $environment_variables, $environment_variables);
|
||||
|
||||
return $environment_variables->all();
|
||||
}
|
||||
|
@ -163,20 +163,7 @@ private function generate_environment_variables()
|
||||
$environment_variables->push("REDIS_PASSWORD={$this->database->keydb_password}");
|
||||
}
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_APP_NAME={$this->database->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}");
|
||||
}
|
||||
|
||||
add_coolify_default_environment_variables($this->database, $environment_variables, $environment_variables);
|
||||
|
||||
return $environment_variables->all();
|
||||
}
|
||||
|
@ -169,20 +169,7 @@ private function generate_environment_variables()
|
||||
$environment_variables->push("MARIADB_PASSWORD={$this->database->mariadb_password}");
|
||||
}
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_APP_NAME={$this->database->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}");
|
||||
}
|
||||
|
||||
add_coolify_default_environment_variables($this->database, $environment_variables, $environment_variables);
|
||||
|
||||
return $environment_variables->all();
|
||||
}
|
||||
|
@ -182,20 +182,7 @@ private function generate_environment_variables()
|
||||
$environment_variables->push("MONGO_INITDB_DATABASE={$this->database->mongo_initdb_database}");
|
||||
}
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_APP_NAME={$this->database->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}");
|
||||
}
|
||||
|
||||
add_coolify_default_environment_variables($this->database, $environment_variables, $environment_variables);
|
||||
|
||||
return $environment_variables->all();
|
||||
}
|
||||
|
@ -169,20 +169,7 @@ private function generate_environment_variables()
|
||||
$environment_variables->push("MYSQL_PASSWORD={$this->database->mysql_password}");
|
||||
}
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_APP_NAME={$this->database->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}");
|
||||
}
|
||||
|
||||
add_coolify_default_environment_variables($this->database, $environment_variables, $environment_variables);
|
||||
|
||||
return $environment_variables->all();
|
||||
}
|
||||
|
@ -191,20 +191,7 @@ private function generate_environment_variables()
|
||||
$environment_variables->push("POSTGRES_DB={$this->database->postgres_db}");
|
||||
}
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_APP_NAME={$this->database->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}");
|
||||
}
|
||||
|
||||
add_coolify_default_environment_variables($this->database, $environment_variables, $environment_variables);
|
||||
|
||||
return $environment_variables->all();
|
||||
}
|
||||
|
@ -168,20 +168,7 @@ private function generate_environment_variables()
|
||||
$environment_variables->push("REDIS_PASSWORD={$this->database->redis_password}");
|
||||
}
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if ($environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_APP_NAME={$this->database->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}");
|
||||
}
|
||||
if ($environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$environment_variables->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}");
|
||||
}
|
||||
|
||||
add_coolify_default_environment_variables($this->database, $environment_variables, $environment_variables);
|
||||
|
||||
return $environment_variables->all();
|
||||
}
|
||||
|
@ -906,19 +906,7 @@ private function save_environment_variables()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$envs->push("COOLIFY_APP_NAME={$this->application->name}");
|
||||
}
|
||||
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$envs->push("COOLIFY_SERVER_IP={$this->application->destination->server->ip}");
|
||||
}
|
||||
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$envs->push("COOLIFY_ENVIRONMENT_NAME={$this->application->environment->name}");
|
||||
}
|
||||
if ($this->application->environment_variables_preview->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$envs->push("COOLIFY_PROJECT_NAME={$this->application->project()->name}");
|
||||
}
|
||||
add_coolify_default_environment_variables($this->application, $environment, $this->application->environment_variables_preview);
|
||||
|
||||
foreach ($sorted_environment_variables_preview as $env) {
|
||||
$real_value = $env->real_value;
|
||||
@ -969,19 +957,7 @@ private function save_environment_variables()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move this in a shared function
|
||||
if ($this->application->environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$envs->push("COOLIFY_APP_NAME={$this->application->name}");
|
||||
}
|
||||
if ($this->application->environment_variables->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$envs->push("COOLIFY_SERVER_IP={$this->application->destination->server->ip}");
|
||||
}
|
||||
if ($this->application->environment_variables->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$envs->push("COOLIFY_ENVIRONMENT_NAME={$this->application->environment->name}");
|
||||
}
|
||||
if ($this->application->environment_variables->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$envs->push("COOLIFY_PROJECT_NAME={$this->application->project()->name}");
|
||||
}
|
||||
add_coolify_default_environment_variables($this->application, $envs, $this->application->environment_variables);
|
||||
|
||||
foreach ($sorted_environment_variables as $env) {
|
||||
$real_value = $env->real_value;
|
||||
|
@ -1464,19 +1464,7 @@ public function newParser(int $pull_request_id = 0, ?int $preview_id = null)
|
||||
if ($this->environment_variables->where('key', 'COOLIFY_CONTAINER_NAME')->isEmpty()) {
|
||||
$environment->put('COOLIFY_CONTAINER_NAME', $containerName);
|
||||
}
|
||||
// TODO: move this in a shared function
|
||||
if ($this->environment_variables->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$environment->push("COOLIFY_APP_NAME={$this->database->name}");
|
||||
}
|
||||
if ($this->environment->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$environment->push("COOLIFY_SERVER_IP={$this->database->destination->server->ip}");
|
||||
}
|
||||
if ($this->environment->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$environment->push("COOLIFY_ENVIRONMENT_NAME={$this->database->environment->name}");
|
||||
}
|
||||
if ($this->environment->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$environment->push("COOLIFY_PROJECT_NAME={$this->database->project()->name}");
|
||||
}
|
||||
add_coolify_default_environment_variables($this->database, $environment, $this->environment_variables);
|
||||
|
||||
// Remove SERVICE_FQDN and SERVICE_URL from environment
|
||||
$environment = $environment->filter(function ($value, $key) {
|
||||
|
@ -3346,3 +3346,32 @@ function generate_fluentd_configuration() : array {
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds the default environment variables to the resource.
|
||||
* - COOLIFY_APP_NAME
|
||||
* - COOLIFY_PROJECT_NAME
|
||||
* - COOLIFY_SERVER_IP
|
||||
* - COOLIFY_ENVIRONMENT_NAME
|
||||
*
|
||||
* Theses variables are added in place to the $where_to_add array.
|
||||
*
|
||||
* @param StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|Application $resource
|
||||
* @param Collection $where_to_add
|
||||
* @param Collection|null $where_to_check
|
||||
*
|
||||
*/
|
||||
function add_coolify_default_environment_variables(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse|Application $resource, Collection &$where_to_add, ?Collection $where_to_check = null) {
|
||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_APP_NAME')->isEmpty()) {
|
||||
$where_to_add->push("COOLIFY_APP_NAME={$resource->name}");
|
||||
}
|
||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_SERVER_IP')->isEmpty()) {
|
||||
$where_to_add->push("COOLIFY_SERVER_IP={$resource->destination->server->ip}");
|
||||
}
|
||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_ENVIRONMENT_NAME')->isEmpty()) {
|
||||
$where_to_add->push("COOLIFY_ENVIRONMENT_NAME={$resource->environment->name}");
|
||||
}
|
||||
if ($where_to_check != null && $where_to_check->where('key', 'COOLIFY_PROJECT_NAME')->isEmpty()) {
|
||||
$where_to_add->push("COOLIFY_PROJECT_NAME={$resource->project()->name}");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user