Integrate Coolify API client and module for managing Coolify services, enhancing automation and deployment processes.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace modules\coolify\config;
|
||||
|
||||
use traits\module_config_variable;
|
||||
|
||||
class coolify_enabled_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setupConfigVariable(
|
||||
'Coolify',
|
||||
'enabled',
|
||||
'bool',
|
||||
false,
|
||||
null,
|
||||
'Enable Coolify-managed replicated infrastructure targets.',
|
||||
'true',
|
||||
false,
|
||||
'false'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace modules\coolify\config;
|
||||
|
||||
use classes\replication_secret_box;
|
||||
use traits\module_config_variable;
|
||||
|
||||
class coolify_hetzner_cloud_api_token_c
|
||||
{
|
||||
use module_config_variable {
|
||||
setVariableValue as private traitSetVariableValue;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setupConfigVariable(
|
||||
'Coolify',
|
||||
'hetzner_cloud_api_token',
|
||||
'string',
|
||||
false,
|
||||
null,
|
||||
'Hetzner Cloud API token with Load Balancer read/write permissions.',
|
||||
'pat_...',
|
||||
true,
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
public function setVariableValue(mixed $value): void
|
||||
{
|
||||
$value = trim((string)($value ?? ''));
|
||||
if ($value !== '' && !str_starts_with($value, 'twsec:v1:')) {
|
||||
$value = replication_secret_box::encrypt($value);
|
||||
}
|
||||
|
||||
$this->traitSetVariableValue($value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace modules\coolify\config;
|
||||
|
||||
use traits\module_config_variable;
|
||||
|
||||
class coolify_hetzner_load_balancer_id_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setupConfigVariable(
|
||||
'Coolify',
|
||||
'hetzner_load_balancer_id',
|
||||
'string',
|
||||
false,
|
||||
null,
|
||||
'Hetzner Cloud Load Balancer ID used as the public Coolify gateway.',
|
||||
'1234567',
|
||||
false,
|
||||
''
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace modules\coolify\config;
|
||||
|
||||
use traits\module_config_variable;
|
||||
|
||||
class coolify_lb_automation_enabled_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setupConfigVariable(
|
||||
'Coolify',
|
||||
'lb_automation_enabled',
|
||||
'bool',
|
||||
false,
|
||||
null,
|
||||
'Enable automated Hetzner Load Balancer reconciliation for the Coolify public gateway.',
|
||||
'false',
|
||||
false,
|
||||
'false'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace modules\coolify\config;
|
||||
|
||||
use traits\module_config_variable;
|
||||
|
||||
class coolify_lb_automation_mode_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setupConfigVariable(
|
||||
'Coolify',
|
||||
'lb_automation_mode',
|
||||
'string',
|
||||
false,
|
||||
['report_only', 'enforce'],
|
||||
'Controls whether Hetzner Load Balancer reconciliation reports drift only or applies changes.',
|
||||
'report_only',
|
||||
false,
|
||||
'report_only'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace modules\coolify\config;
|
||||
|
||||
use traits\module_config_variable;
|
||||
|
||||
class coolify_public_gateway_host_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setupConfigVariable(
|
||||
'Coolify',
|
||||
'public_gateway_host',
|
||||
'string',
|
||||
false,
|
||||
null,
|
||||
'Public DNS hostname served by the replicated Coolify gateway Load Balancer.',
|
||||
'api-v2.truckwash.io',
|
||||
false,
|
||||
'api-v2.truckwash.io'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace modules\coolify;
|
||||
|
||||
require_once WD . '/modules/coolify/config/coolify_enabled_c.php';
|
||||
require_once WD . '/modules/coolify/config/coolify_hetzner_cloud_api_token_c.php';
|
||||
require_once WD . '/modules/coolify/config/coolify_hetzner_load_balancer_id_c.php';
|
||||
require_once WD . '/modules/coolify/config/coolify_lb_automation_enabled_c.php';
|
||||
require_once WD . '/modules/coolify/config/coolify_lb_automation_mode_c.php';
|
||||
require_once WD . '/modules/coolify/config/coolify_public_gateway_host_c.php';
|
||||
|
||||
use modules\coolify\config\coolify_hetzner_cloud_api_token_c;
|
||||
use modules\coolify\config\coolify_hetzner_load_balancer_id_c;
|
||||
use modules\coolify\config\coolify_enabled_c;
|
||||
use modules\coolify\config\coolify_lb_automation_enabled_c;
|
||||
use modules\coolify\config\coolify_lb_automation_mode_c;
|
||||
use modules\coolify\config\coolify_public_gateway_host_c;
|
||||
use traits\module_config_t;
|
||||
|
||||
class coolify_c
|
||||
{
|
||||
use module_config_t {
|
||||
getConfigRequest as private traitGetConfigRequest;
|
||||
}
|
||||
|
||||
public coolify_enabled_c $enabled;
|
||||
public coolify_lb_automation_enabled_c $lb_automation_enabled;
|
||||
public coolify_lb_automation_mode_c $lb_automation_mode;
|
||||
public coolify_hetzner_load_balancer_id_c $hetzner_load_balancer_id;
|
||||
public coolify_hetzner_cloud_api_token_c $hetzner_cloud_api_token;
|
||||
public coolify_public_gateway_host_c $public_gateway_host;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setupConfig('Coolify');
|
||||
$this->allowUpdate([
|
||||
coolify_enabled_c::class,
|
||||
coolify_lb_automation_enabled_c::class,
|
||||
coolify_lb_automation_mode_c::class,
|
||||
coolify_hetzner_load_balancer_id_c::class,
|
||||
coolify_hetzner_cloud_api_token_c::class,
|
||||
coolify_public_gateway_host_c::class,
|
||||
]);
|
||||
$this->enabled = new coolify_enabled_c();
|
||||
$this->lb_automation_enabled = new coolify_lb_automation_enabled_c();
|
||||
$this->lb_automation_mode = new coolify_lb_automation_mode_c();
|
||||
$this->hetzner_load_balancer_id = new coolify_hetzner_load_balancer_id_c();
|
||||
$this->hetzner_cloud_api_token = new coolify_hetzner_cloud_api_token_c();
|
||||
$this->public_gateway_host = new coolify_public_gateway_host_c();
|
||||
}
|
||||
|
||||
public function getConfigRequest(): array
|
||||
{
|
||||
return array_map(static function (array $row): array {
|
||||
if (($row['variable'] ?? '') === 'hetzner_cloud_api_token') {
|
||||
$secretSet = trim((string)($row['value'] ?? '')) !== '';
|
||||
$row['value'] = $secretSet ? '[redacted]' : '';
|
||||
$row['secret_set'] = $secretSet;
|
||||
}
|
||||
return $row;
|
||||
}, $this->traitGetConfigRequest());
|
||||
}
|
||||
}
|
||||
@@ -364,6 +364,7 @@ class edge_gateway_manager
|
||||
}
|
||||
|
||||
$gatewayPayload = $this->getGateway($gatewayId);
|
||||
$gatewayPayload['broker_url'] = $this->buildBrokerPublicUrl();
|
||||
edge_gateway_view_cache::syncGateway($gatewayPayload);
|
||||
|
||||
return $gatewayPayload;
|
||||
|
||||
@@ -21,9 +21,9 @@ class edgegateway_public_broker_url_c
|
||||
false,
|
||||
null,
|
||||
'The browser-routable edge broker URL, including the proxy path prefix.',
|
||||
'https://api.truckwash.io:4433/edge-broker',
|
||||
'https://api-v2.truckwash.io/edge-broker',
|
||||
false,
|
||||
trim((string)(getenv('EDGE_PUBLIC_BROKER_URL') ?: ''))
|
||||
trim((string)(getenv('EDGE_PUBLIC_BROKER_URL') ?: '')) ?: 'https://api-v2.truckwash.io/edge-broker'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace failover\config;
|
||||
|
||||
use Exception;
|
||||
use traits\module_config_variable;
|
||||
|
||||
class failover_database_enabled_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
self::setupConfigVariable(
|
||||
'Failover',
|
||||
'database_enabled',
|
||||
'bool',
|
||||
true,
|
||||
null,
|
||||
'Whether automatic database replica failover is enabled.',
|
||||
'false',
|
||||
false,
|
||||
'false'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace failover\config;
|
||||
|
||||
use Exception;
|
||||
use traits\module_config_variable;
|
||||
|
||||
class failover_enabled_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
self::setupConfigVariable(
|
||||
'Failover',
|
||||
'enabled',
|
||||
'bool',
|
||||
true,
|
||||
null,
|
||||
'Whether automatic failover is enabled.',
|
||||
'false',
|
||||
false,
|
||||
'false'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace failover\config;
|
||||
|
||||
use Exception;
|
||||
use traits\module_config_variable;
|
||||
|
||||
class failover_max_status_age_seconds_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
self::setupConfigVariable(
|
||||
'Failover',
|
||||
'max_status_age_seconds',
|
||||
'int',
|
||||
true,
|
||||
null,
|
||||
'Maximum age in seconds for a stored replica status to be eligible for automatic failover.',
|
||||
'90',
|
||||
false,
|
||||
'90'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace failover\config;
|
||||
|
||||
use Exception;
|
||||
use traits\module_config_variable;
|
||||
|
||||
class failover_minio_enabled_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
self::setupConfigVariable(
|
||||
'Failover',
|
||||
'minio_enabled',
|
||||
'bool',
|
||||
true,
|
||||
null,
|
||||
'Whether automatic MinIO replica failover is enabled.',
|
||||
'false',
|
||||
false,
|
||||
'false'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace failover\config;
|
||||
|
||||
use Exception;
|
||||
use traits\module_config_variable;
|
||||
|
||||
class failover_redis_enabled_c
|
||||
{
|
||||
use module_config_variable;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
self::setupConfigVariable(
|
||||
'Failover',
|
||||
'redis_enabled',
|
||||
'bool',
|
||||
true,
|
||||
null,
|
||||
'Whether automatic Redis replica failover is enabled.',
|
||||
'false',
|
||||
false,
|
||||
'false'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace failover;
|
||||
|
||||
require_once WD . '/modules/failover/config/failover_enabled_c.php';
|
||||
require_once WD . '/modules/failover/config/failover_database_enabled_c.php';
|
||||
require_once WD . '/modules/failover/config/failover_redis_enabled_c.php';
|
||||
require_once WD . '/modules/failover/config/failover_minio_enabled_c.php';
|
||||
require_once WD . '/modules/failover/config/failover_max_status_age_seconds_c.php';
|
||||
|
||||
use failover\config\failover_database_enabled_c;
|
||||
use failover\config\failover_enabled_c;
|
||||
use failover\config\failover_max_status_age_seconds_c;
|
||||
use failover\config\failover_minio_enabled_c;
|
||||
use failover\config\failover_redis_enabled_c;
|
||||
use traits\module_config_t;
|
||||
|
||||
class failover_c
|
||||
{
|
||||
use module_config_t;
|
||||
|
||||
public failover_enabled_c $enabled;
|
||||
public failover_database_enabled_c $database_enabled;
|
||||
public failover_redis_enabled_c $redis_enabled;
|
||||
public failover_minio_enabled_c $minio_enabled;
|
||||
public failover_max_status_age_seconds_c $max_status_age_seconds;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setupConfig('Failover');
|
||||
$this->allowUpdate([
|
||||
failover_enabled_c::class,
|
||||
failover_database_enabled_c::class,
|
||||
failover_redis_enabled_c::class,
|
||||
failover_minio_enabled_c::class,
|
||||
failover_max_status_age_seconds_c::class,
|
||||
]);
|
||||
|
||||
$this->enabled = new failover_enabled_c();
|
||||
$this->database_enabled = new failover_database_enabled_c();
|
||||
$this->redis_enabled = new failover_redis_enabled_c();
|
||||
$this->minio_enabled = new failover_minio_enabled_c();
|
||||
$this->max_status_age_seconds = new failover_max_status_age_seconds_c();
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ require_once 'twc_spreadsheet_class.php';
|
||||
// Set CORS headers
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST");
|
||||
header("Access-Control-Allow-Headers: Content-Type, X-Customer-Number");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Customer-Number, X-Release-Trace, X-Release-Channel, X-Frontend-Version");
|
||||
|
||||
// Set the timezone
|
||||
date_default_timezone_set('Europe/Copenhagen');
|
||||
|
||||
Reference in New Issue
Block a user