Enhance Coolify API deployment with improved gateway route handling and extensive test coverage. Add new methods for service updates and ensure Composer vendor sanity checks in PHP container.
This commit is contained in:
@@ -57,14 +57,42 @@ class hetzner_cloud_client
|
||||
]);
|
||||
}
|
||||
|
||||
public function addService(int|string $loadBalancerId, string $protocol, int $listenPort, int $destinationPort): array
|
||||
public function addService(int|string $loadBalancerId, string $protocol, int $listenPort, int $destinationPort, array $options = []): array
|
||||
{
|
||||
return $this->request('POST', '/load_balancers/' . rawurlencode((string)$loadBalancerId) . '/actions/add_service', [
|
||||
return $this->request('POST', '/load_balancers/' . rawurlencode((string)$loadBalancerId) . '/actions/add_service', self::servicePayload(
|
||||
$protocol,
|
||||
$listenPort,
|
||||
$destinationPort,
|
||||
$options
|
||||
));
|
||||
}
|
||||
|
||||
public function updateService(int|string $loadBalancerId, string $protocol, int $listenPort, int $destinationPort, array $options = []): array
|
||||
{
|
||||
return $this->request('POST', '/load_balancers/' . rawurlencode((string)$loadBalancerId) . '/actions/update_service', self::servicePayload(
|
||||
$protocol,
|
||||
$listenPort,
|
||||
$destinationPort,
|
||||
$options
|
||||
));
|
||||
}
|
||||
|
||||
private static function servicePayload(string $protocol, int $listenPort, int $destinationPort, array $options): array
|
||||
{
|
||||
$payload = [
|
||||
'protocol' => strtolower($protocol),
|
||||
'listen_port' => $listenPort,
|
||||
'destination_port' => $destinationPort,
|
||||
'proxyprotocol' => false,
|
||||
]);
|
||||
];
|
||||
|
||||
foreach (['health_check', 'http'] as $key) {
|
||||
if (isset($options[$key]) && is_array($options[$key])) {
|
||||
$payload[$key] = $options[$key];
|
||||
}
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
private function request(string $method, string $path, ?array $payload = null): array
|
||||
|
||||
Reference in New Issue
Block a user