Inline many variables.
This commit is contained in:
@@ -58,9 +58,7 @@ class StartProxy
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($async) {
|
if ($async) {
|
||||||
$activity = remote_process($commands, $server, callEventOnFinish: 'ProxyStarted', callEventData: $server);
|
return remote_process($commands, $server, callEventOnFinish: 'ProxyStarted', callEventData: $server);
|
||||||
|
|
||||||
return $activity;
|
|
||||||
} else {
|
} else {
|
||||||
instant_remote_process($commands, $server);
|
instant_remote_process($commands, $server);
|
||||||
$server->proxy->set('status', 'running');
|
$server->proxy->set('status', 'running');
|
||||||
|
@@ -12,8 +12,6 @@ class RunCommand
|
|||||||
|
|
||||||
public function handle(Server $server, $command)
|
public function handle(Server $server, $command)
|
||||||
{
|
{
|
||||||
$activity = remote_process(command: [$command], server: $server, ignore_errors: true, type: ActivityTypes::COMMAND->value);
|
return remote_process(command: [$command], server: $server, ignore_errors: true, type: ActivityTypes::COMMAND->value);
|
||||||
|
|
||||||
return $activity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,8 +33,7 @@ class StartService
|
|||||||
$commands[] = "docker network connect --alias {$serviceName}-{$service->uuid} $network {$serviceName}-{$service->uuid} >/dev/null 2>&1 || true";
|
$commands[] = "docker network connect --alias {$serviceName}-{$service->uuid} $network {$serviceName}-{$service->uuid} >/dev/null 2>&1 || true";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$activity = remote_process($commands, $service->server, type_uuid: $service->uuid, callEventOnFinish: 'ServiceStatusChanged');
|
|
||||||
|
|
||||||
return $activity;
|
return remote_process($commands, $service->server, type_uuid: $service->uuid, callEventOnFinish: 'ServiceStatusChanged');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1691,9 +1691,8 @@ class ApplicationsController extends Controller
|
|||||||
'standalone_postgresql_id',
|
'standalone_postgresql_id',
|
||||||
'standalone_redis_id',
|
'standalone_redis_id',
|
||||||
]);
|
]);
|
||||||
$env = $this->removeSensitiveData($env);
|
|
||||||
|
|
||||||
return $env;
|
return $this->removeSensitiveData($env);
|
||||||
});
|
});
|
||||||
|
|
||||||
return response()->json($envs);
|
return response()->json($envs);
|
||||||
|
@@ -566,9 +566,8 @@ class ServicesController extends Controller
|
|||||||
'standalone_postgresql_id',
|
'standalone_postgresql_id',
|
||||||
'standalone_redis_id',
|
'standalone_redis_id',
|
||||||
]);
|
]);
|
||||||
$env = $this->removeSensitiveData($env);
|
|
||||||
|
|
||||||
return $env;
|
return $this->removeSensitiveData($env);
|
||||||
});
|
});
|
||||||
|
|
||||||
return response()->json($envs);
|
return response()->json($envs);
|
||||||
|
@@ -54,13 +54,9 @@ class ScheduledTaskJob implements ShouldQueue
|
|||||||
private function getServerTimezone(): string
|
private function getServerTimezone(): string
|
||||||
{
|
{
|
||||||
if ($this->resource instanceof Application) {
|
if ($this->resource instanceof Application) {
|
||||||
$timezone = $this->resource->destination->server->settings->server_timezone;
|
return $this->resource->destination->server->settings->server_timezone;
|
||||||
|
|
||||||
return $timezone;
|
|
||||||
} elseif ($this->resource instanceof Service) {
|
} elseif ($this->resource instanceof Service) {
|
||||||
$timezone = $this->resource->server->settings->server_timezone;
|
return $this->resource->server->settings->server_timezone;
|
||||||
|
|
||||||
return $timezone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'UTC';
|
return 'UTC';
|
||||||
|
@@ -119,9 +119,8 @@ class BackupExecutions extends Component
|
|||||||
if (! $server) {
|
if (! $server) {
|
||||||
return 'UTC';
|
return 'UTC';
|
||||||
}
|
}
|
||||||
$serverTimezone = $server->settings->server_timezone;
|
|
||||||
|
|
||||||
return $serverTimezone;
|
return $server->settings->server_timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatDateInServerTimezone($date)
|
public function formatDateInServerTimezone($date)
|
||||||
|
@@ -54,9 +54,8 @@ class Executions extends Component
|
|||||||
if (! $server) {
|
if (! $server) {
|
||||||
return 'UTC';
|
return 'UTC';
|
||||||
}
|
}
|
||||||
$serverTimezone = $server->settings->server_timezone;
|
|
||||||
|
|
||||||
return $serverTimezone;
|
return $server->settings->server_timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatDateInServerTimezone($date)
|
public function formatDateInServerTimezone($date)
|
||||||
|
@@ -34,21 +34,15 @@ class ScheduledTask extends BaseModel
|
|||||||
{
|
{
|
||||||
if ($this->application) {
|
if ($this->application) {
|
||||||
if ($this->application->destination && $this->application->destination->server) {
|
if ($this->application->destination && $this->application->destination->server) {
|
||||||
$server = $this->application->destination->server;
|
return $this->application->destination->server;
|
||||||
|
|
||||||
return $server;
|
|
||||||
}
|
}
|
||||||
} elseif ($this->service) {
|
} elseif ($this->service) {
|
||||||
if ($this->service->destination && $this->service->destination->server) {
|
if ($this->service->destination && $this->service->destination->server) {
|
||||||
$server = $this->service->destination->server;
|
return $this->service->destination->server;
|
||||||
|
|
||||||
return $server;
|
|
||||||
}
|
}
|
||||||
} elseif ($this->database) {
|
} elseif ($this->database) {
|
||||||
if ($this->database->destination && $this->database->destination->server) {
|
if ($this->database->destination && $this->database->destination->server) {
|
||||||
$server = $this->database->destination->server;
|
return $this->database->destination->server;
|
||||||
|
|
||||||
return $server;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -602,11 +602,10 @@ $schema://$host {
|
|||||||
throw new \Exception($error);
|
throw new \Exception($error);
|
||||||
}
|
}
|
||||||
$cpu = json_decode($cpu, true);
|
$cpu = json_decode($cpu, true);
|
||||||
$parsedCollection = collect($cpu)->map(function ($metric) {
|
|
||||||
|
return collect($cpu)->map(function ($metric) {
|
||||||
return [(int) $metric['time'], (float) $metric['percent']];
|
return [(int) $metric['time'], (float) $metric['percent']];
|
||||||
});
|
});
|
||||||
|
|
||||||
return $parsedCollection;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -837,9 +836,7 @@ $schema://$host {
|
|||||||
{
|
{
|
||||||
return Attribute::make(
|
return Attribute::make(
|
||||||
get: function ($value) {
|
get: function ($value) {
|
||||||
$sanitizedValue = preg_replace('/[^A-Za-z0-9\-_]/', '', $value);
|
return preg_replace('/[^A-Za-z0-9\-_]/', '', $value);
|
||||||
|
|
||||||
return $sanitizedValue;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1096,9 +1093,7 @@ $schema://$host {
|
|||||||
|
|
||||||
public function installDocker()
|
public function installDocker()
|
||||||
{
|
{
|
||||||
$activity = InstallDocker::run($this);
|
return InstallDocker::run($this);
|
||||||
|
|
||||||
return $activity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateDockerEngine($throwError = false)
|
public function validateDockerEngine($throwError = false)
|
||||||
|
@@ -1307,9 +1307,7 @@ class Service extends BaseModel
|
|||||||
|
|
||||||
public function networks()
|
public function networks()
|
||||||
{
|
{
|
||||||
$networks = getTopLevelNetworks($this);
|
return getTopLevelNetworks($this);
|
||||||
|
|
||||||
return $networks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function isDeployable(): Attribute
|
protected function isDeployable(): Attribute
|
||||||
|
@@ -131,9 +131,7 @@ class Team extends Model implements SendsDiscord, SendsEmail
|
|||||||
{
|
{
|
||||||
$recipients = data_get($notification, 'emails', null);
|
$recipients = data_get($notification, 'emails', null);
|
||||||
if (is_null($recipients)) {
|
if (is_null($recipients)) {
|
||||||
$recipients = $this->members()->pluck('email')->toArray();
|
return $this->members()->pluck('email')->toArray();
|
||||||
|
|
||||||
return $recipients;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return explode(',', $recipients);
|
return explode(',', $recipients);
|
||||||
@@ -251,9 +249,8 @@ class Team extends Model implements SendsDiscord, SendsEmail
|
|||||||
$sources = collect([]);
|
$sources = collect([]);
|
||||||
$github_apps = $this->hasMany(GithubApp::class)->whereisPublic(false)->get();
|
$github_apps = $this->hasMany(GithubApp::class)->whereisPublic(false)->get();
|
||||||
$gitlab_apps = $this->hasMany(GitlabApp::class)->whereisPublic(false)->get();
|
$gitlab_apps = $this->hasMany(GitlabApp::class)->whereisPublic(false)->get();
|
||||||
$sources = $sources->merge($github_apps)->merge($gitlab_apps);
|
|
||||||
|
|
||||||
return $sources;
|
return $sources->merge($github_apps)->merge($gitlab_apps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function s3s()
|
public function s3s()
|
||||||
|
@@ -58,14 +58,12 @@ class StatusChanged extends Notification implements ShouldQueue
|
|||||||
|
|
||||||
public function toDiscord(): DiscordMessage
|
public function toDiscord(): DiscordMessage
|
||||||
{
|
{
|
||||||
$message = new DiscordMessage(
|
return new DiscordMessage(
|
||||||
title: ':cross_mark: Application stopped',
|
title: ':cross_mark: Application stopped',
|
||||||
description: '[Open Application in Coolify]('.$this->resource_url.')',
|
description: '[Open Application in Coolify]('.$this->resource_url.')',
|
||||||
color: DiscordMessage::errorColor(),
|
color: DiscordMessage::errorColor(),
|
||||||
isCritical: true,
|
isCritical: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toTelegram(): array
|
public function toTelegram(): array
|
||||||
|
@@ -21,7 +21,7 @@ function invalidTokenResponse()
|
|||||||
function serializeApiResponse($data)
|
function serializeApiResponse($data)
|
||||||
{
|
{
|
||||||
if ($data instanceof Collection) {
|
if ($data instanceof Collection) {
|
||||||
$data = $data->map(function ($d) {
|
return $data->map(function ($d) {
|
||||||
$d = collect($d)->sortKeys();
|
$d = collect($d)->sortKeys();
|
||||||
$created_at = data_get($d, 'created_at');
|
$created_at = data_get($d, 'created_at');
|
||||||
$updated_at = data_get($d, 'updated_at');
|
$updated_at = data_get($d, 'updated_at');
|
||||||
@@ -49,8 +49,6 @@ function serializeApiResponse($data)
|
|||||||
|
|
||||||
return $d;
|
return $d;
|
||||||
});
|
});
|
||||||
|
|
||||||
return $data;
|
|
||||||
} else {
|
} else {
|
||||||
$d = collect($data)->sortKeys();
|
$d = collect($data)->sortKeys();
|
||||||
$created_at = data_get($d, 'created_at');
|
$created_at = data_get($d, 'created_at');
|
||||||
|
@@ -32,9 +32,8 @@ function getCurrentApplicationContainerStatus(Server $server, int $id, ?int $pul
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
$containers = $containers->filter();
|
|
||||||
|
|
||||||
return $containers;
|
return $containers->filter();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $containers;
|
return $containers;
|
||||||
@@ -46,9 +45,8 @@ function getCurrentServiceContainerStatus(Server $server, int $id): Collection
|
|||||||
if (! $server->isSwarm()) {
|
if (! $server->isSwarm()) {
|
||||||
$containers = instant_remote_process(["docker ps -a --filter='label=coolify.serviceId={$id}' --format '{{json .}}' "], $server);
|
$containers = instant_remote_process(["docker ps -a --filter='label=coolify.serviceId={$id}' --format '{{json .}}' "], $server);
|
||||||
$containers = format_docker_command_output_to_json($containers);
|
$containers = format_docker_command_output_to_json($containers);
|
||||||
$containers = $containers->filter();
|
|
||||||
|
|
||||||
return $containers;
|
return $containers->filter();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $containers;
|
return $containers;
|
||||||
|
@@ -43,14 +43,13 @@ function generate_github_jwt_token(GithubApp $source)
|
|||||||
$tokenBuilder = (new Builder(new JoseEncoder, ChainedFormatter::default()));
|
$tokenBuilder = (new Builder(new JoseEncoder, ChainedFormatter::default()));
|
||||||
$now = CarbonImmutable::now();
|
$now = CarbonImmutable::now();
|
||||||
$now = $now->setTime($now->format('H'), $now->format('i'));
|
$now = $now->setTime($now->format('H'), $now->format('i'));
|
||||||
$issuedToken = $tokenBuilder
|
|
||||||
|
return $tokenBuilder
|
||||||
->issuedBy($source->app_id)
|
->issuedBy($source->app_id)
|
||||||
->issuedAt($now->modify('-1 minute'))
|
->issuedAt($now->modify('-1 minute'))
|
||||||
->expiresAt($now->modify('+10 minutes'))
|
->expiresAt($now->modify('+10 minutes'))
|
||||||
->getToken($algorithm, $signingKey)
|
->getToken($algorithm, $signingKey)
|
||||||
->toString();
|
->toString();
|
||||||
|
|
||||||
return $issuedToken;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function githubApi(GithubApp|GitlabApp|null $source, string $endpoint, string $method = 'get', ?array $data = null, bool $throwError = true)
|
function githubApi(GithubApp|GitlabApp|null $source, string $endpoint, string $method = 'get', ?array $data = null, bool $throwError = true)
|
||||||
|
@@ -16,11 +16,10 @@ function collectProxyDockerNetworksByServer(Server $server)
|
|||||||
return collect();
|
return collect();
|
||||||
}
|
}
|
||||||
$networks = instant_remote_process(['docker inspect --format="{{json .NetworkSettings.Networks }}" coolify-proxy'], $server, false);
|
$networks = instant_remote_process(['docker inspect --format="{{json .NetworkSettings.Networks }}" coolify-proxy'], $server, false);
|
||||||
$networks = collect($networks)->map(function ($network) {
|
|
||||||
|
return collect($networks)->map(function ($network) {
|
||||||
return collect(json_decode($network))->keys();
|
return collect(json_decode($network))->keys();
|
||||||
})->flatten()->unique();
|
})->flatten()->unique();
|
||||||
|
|
||||||
return $networks;
|
|
||||||
}
|
}
|
||||||
function collectDockerNetworksByServer(Server $server)
|
function collectDockerNetworksByServer(Server $server)
|
||||||
{
|
{
|
||||||
|
@@ -245,8 +245,5 @@ function updateCompose(ServiceApplication|ServiceDatabase $resource)
|
|||||||
}
|
}
|
||||||
function serviceKeys()
|
function serviceKeys()
|
||||||
{
|
{
|
||||||
$services = get_service_templates();
|
return get_service_templates()->keys();
|
||||||
$serviceKeys = $services->keys();
|
|
||||||
|
|
||||||
return $serviceKeys;
|
|
||||||
}
|
}
|
||||||
|
@@ -501,9 +501,8 @@ function generateFqdn(Server $server, string $random, bool $forceHttps = false):
|
|||||||
if ($forceHttps) {
|
if ($forceHttps) {
|
||||||
$scheme = 'https';
|
$scheme = 'https';
|
||||||
}
|
}
|
||||||
$finalFqdn = "$scheme://{$random}.$host$path";
|
|
||||||
|
|
||||||
return $finalFqdn;
|
return "$scheme://{$random}.$host$path";
|
||||||
}
|
}
|
||||||
function sslip(Server $server)
|
function sslip(Server $server)
|
||||||
{
|
{
|
||||||
@@ -653,9 +652,8 @@ function generateTagDeployWebhook($tag_name)
|
|||||||
$baseUrl = base_url();
|
$baseUrl = base_url();
|
||||||
$api = Url::fromString($baseUrl).'/api/v1';
|
$api = Url::fromString($baseUrl).'/api/v1';
|
||||||
$endpoint = "/deploy?tag=$tag_name";
|
$endpoint = "/deploy?tag=$tag_name";
|
||||||
$url = $api.$endpoint;
|
|
||||||
|
|
||||||
return $url;
|
return $api.$endpoint;
|
||||||
}
|
}
|
||||||
function generateDeployWebhook($resource)
|
function generateDeployWebhook($resource)
|
||||||
{
|
{
|
||||||
@@ -663,9 +661,8 @@ function generateDeployWebhook($resource)
|
|||||||
$api = Url::fromString($baseUrl).'/api/v1';
|
$api = Url::fromString($baseUrl).'/api/v1';
|
||||||
$endpoint = '/deploy';
|
$endpoint = '/deploy';
|
||||||
$uuid = data_get($resource, 'uuid');
|
$uuid = data_get($resource, 'uuid');
|
||||||
$url = $api.$endpoint."?uuid=$uuid&force=false";
|
|
||||||
|
|
||||||
return $url;
|
return $api.$endpoint."?uuid=$uuid&force=false";
|
||||||
}
|
}
|
||||||
function generateGitManualWebhook($resource, $type)
|
function generateGitManualWebhook($resource, $type)
|
||||||
{
|
{
|
||||||
@@ -674,9 +671,8 @@ function generateGitManualWebhook($resource, $type)
|
|||||||
}
|
}
|
||||||
if ($resource->getMorphClass() === \App\Models\Application::class) {
|
if ($resource->getMorphClass() === \App\Models\Application::class) {
|
||||||
$baseUrl = base_url();
|
$baseUrl = base_url();
|
||||||
$api = Url::fromString($baseUrl)."/webhooks/source/$type/events/manual";
|
|
||||||
|
|
||||||
return $api;
|
return Url::fromString($baseUrl)."/webhooks/source/$type/events/manual";
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@@ -55,12 +55,11 @@ function getStripeCustomerPortalSession(Team $team)
|
|||||||
if (! $stripe_customer_id) {
|
if (! $stripe_customer_id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$session = \Stripe\BillingPortal\Session::create([
|
|
||||||
|
return \Stripe\BillingPortal\Session::create([
|
||||||
'customer' => $stripe_customer_id,
|
'customer' => $stripe_customer_id,
|
||||||
'return_url' => $return_url,
|
'return_url' => $return_url,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $session;
|
|
||||||
}
|
}
|
||||||
function allowedPathsForUnsubscribedAccounts()
|
function allowedPathsForUnsubscribedAccounts()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user