refactor(init): standardize method naming conventions and improve command structure in Init.php

This commit is contained in:
Andras Bacsai
2025-07-07 09:50:15 +02:00
parent 7817c9cad7
commit 3b7f4bcbbd

View File

@@ -36,24 +36,20 @@ class Init extends Command
$this->servers = Server::all();
if (! isCloud()) {
$this->send_alive_signal();
$this->sendAliveSignal();
get_public_ips();
}
// Backward compatibility
$this->replace_slash_in_environment_name();
$this->restore_coolify_db_backup();
$this->update_user_emails();
$this->replaceSlashInEnvironmentName();
$this->restoreCoolifyDbBackup();
$this->updateUserEmails();
//
$this->update_traefik_labels();
$this->updateTraefikLabels();
if (! isCloud() || $this->option('force-cloud')) {
$this->cleanup_unused_network_from_coolify_proxy();
}
if (isCloud()) {
$this->cleanup_unnecessary_dynamic_proxy_configuration();
} else {
$this->cleanup_in_progress_application_deployments();
$this->cleanupUnusedNetworkFromCoolifyProxy();
}
$this->call('cleanup:redis');
$this->call('cleanup:stucked-resources');
@@ -66,14 +62,17 @@ class Init extends Command
if (isCloud()) {
try {
$this->cleanupUnnecessaryDynamicProxyConfiguration();
$this->pullTemplatesFromCDN();
} catch (\Throwable $e) {
echo "Could not pull templates from CDN: {$e->getMessage()}\n";
}
return;
}
if (! isCloud()) {
try {
$this->cleanupInProgressApplicationDeployments();
$this->pullTemplatesFromCDN();
} catch (\Throwable $e) {
echo "Could not pull templates from CDN: {$e->getMessage()}\n";
@@ -95,7 +94,6 @@ class Init extends Command
}
}
}
}
private function pullHelperImage()
{
@@ -117,7 +115,7 @@ class Init extends Command
Artisan::call('optimize');
}
private function update_user_emails()
private function updateUserEmails()
{
try {
User::whereRaw('email ~ \'[A-Z]\'')->get()->each(function (User $user) {
@@ -128,7 +126,7 @@ class Init extends Command
}
}
private function update_traefik_labels()
private function updateTraefikLabels()
{
try {
Server::where('proxy->type', 'TRAEFIK_V2')->update(['proxy->type' => 'TRAEFIK']);
@@ -137,7 +135,7 @@ class Init extends Command
}
}
private function cleanup_unnecessary_dynamic_proxy_configuration()
private function cleanupUnnecessaryDynamicProxyConfiguration()
{
foreach ($this->servers as $server) {
try {
@@ -158,7 +156,7 @@ class Init extends Command
}
}
private function cleanup_unused_network_from_coolify_proxy()
private function cleanupUnusedNetworkFromCoolifyProxy()
{
foreach ($this->servers as $server) {
if (! $server->isFunctional()) {
@@ -197,7 +195,7 @@ class Init extends Command
}
}
private function restore_coolify_db_backup()
private function restoreCoolifyDbBackup()
{
if (version_compare('4.0.0-beta.179', config('constants.coolify.version'), '<=')) {
try {
@@ -223,7 +221,7 @@ class Init extends Command
}
}
private function send_alive_signal()
private function sendAliveSignal()
{
$id = config('app.id');
$version = config('constants.coolify.version');
@@ -241,7 +239,7 @@ class Init extends Command
}
}
private function cleanup_in_progress_application_deployments()
private function cleanupInProgressApplicationDeployments()
{
// Cleanup any failed deployments
try {
@@ -258,7 +256,7 @@ class Init extends Command
}
}
private function replace_slash_in_environment_name()
private function replaceSlashInEnvironmentName()
{
if (version_compare('4.0.0-beta.298', config('constants.coolify.version'), '<=')) {
$environments = Environment::all();