testing php storm code cleanup and styling
This commit is contained in:
@@ -11,8 +11,6 @@
|
||||
|
|
||||
*/
|
||||
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@ function queue_application_deployment(int $application_id, string $deployment_uu
|
||||
]);
|
||||
$queued_deployments = ApplicationDeploymentQueue::where('application_id', $application_id)->where('status', 'queued')->get()->sortByDesc('created_at');
|
||||
$running_deployments = ApplicationDeploymentQueue::where('application_id', $application_id)->where('status', 'in_progress')->get()->sortByDesc('created_at');
|
||||
ray('Q:' . $queued_deployments->count() . 'R:' . $running_deployments->count() . '| Queuing deployment: ' . $deployment_uuid . ' of applicationID: ' . $application_id . ' pull request: ' . $pull_request_id . ' with commit: ' . $commit . ' and is it forced: ' . $force_rebuild);
|
||||
ray('Q:' . $queued_deployments->count() . 'R:' . $running_deployments->count() . '| Queuing deployment: ' . $deployment_uuid . ' of applicationID: ' . $application_id . ' pull request: ' . $pull_request_id . ' with commit: ' . $commit . ' and is it forced: ' . $force_rebuild);
|
||||
if ($queued_deployments->count() > 1) {
|
||||
$queued_deployments = $queued_deployments->skip(1);
|
||||
$queued_deployments->each(function ($queued_deployment, $key) {
|
||||
|
||||
@@ -8,15 +8,16 @@ function format_docker_command_output_to_json($rawOutput): Collection
|
||||
$outputLines = explode(PHP_EOL, $rawOutput);
|
||||
|
||||
return collect($outputLines)
|
||||
->reject(fn ($line) => empty($line))
|
||||
->map(fn ($outputLine) => json_decode($outputLine, true, flags: JSON_THROW_ON_ERROR));
|
||||
->reject(fn($line) => empty($line))
|
||||
->map(fn($outputLine) => json_decode($outputLine, true, flags: JSON_THROW_ON_ERROR));
|
||||
}
|
||||
|
||||
function format_docker_labels_to_json($rawOutput): Collection
|
||||
{
|
||||
$outputLines = explode(PHP_EOL, $rawOutput);
|
||||
|
||||
return collect($outputLines)
|
||||
->reject(fn ($line) => empty($line))
|
||||
->reject(fn($line) => empty($line))
|
||||
->map(function ($outputLine) {
|
||||
$outputArray = explode(',', $outputLine);
|
||||
return collect($outputArray)
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
use App\Models\GithubApp;
|
||||
use App\Models\GitlabApp;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Lcobucci\JWT\Encoding\ChainedFormatter;
|
||||
use Lcobucci\JWT\Encoding\JoseEncoder;
|
||||
use Lcobucci\JWT\Signer\Key\InMemory;
|
||||
@@ -33,6 +33,7 @@ function generate_github_installation_token(GithubApp $source)
|
||||
}
|
||||
return $token->json()['token'];
|
||||
}
|
||||
|
||||
function generate_github_jwt_token(GithubApp $source)
|
||||
{
|
||||
$signingKey = InMemory::plainText($source->privateKey->private_key);
|
||||
@@ -65,7 +66,7 @@ function git_api(GithubApp|GitlabApp $source, string $endpoint, string $method =
|
||||
}
|
||||
$json = $response->json();
|
||||
if ($response->failed() && $throwError) {
|
||||
throw new \Exception("Failed to get data from {$source->name} with error:<br><br>" . $json['message'] . "<br><br>Rate Limit resets at: " . Carbon::parse((int)$response->header('X-RateLimit-Reset'))->format('Y-m-d H:i:s') . 'UTC');
|
||||
throw new \Exception("Failed to get data from {$source->name} with error:<br><br>" . $json['message'] . "<br><br>Rate Limit resets at: " . Carbon::parse((int)$response->header('X-RateLimit-Reset'))->format('Y-m-d H:i:s') . 'UTC');
|
||||
}
|
||||
return [
|
||||
'rate_limit_remaining' => $response->header('X-RateLimit-Remaining'),
|
||||
@@ -73,6 +74,7 @@ function git_api(GithubApp|GitlabApp $source, string $endpoint, string $method =
|
||||
'data' => collect($json)
|
||||
];
|
||||
}
|
||||
|
||||
function get_installation_path(GithubApp $source)
|
||||
{
|
||||
$github = GithubApp::where('uuid', $source->uuid)->first();
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Server;
|
||||
use Spatie\Url\Url;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
function get_proxy_path() {
|
||||
function get_proxy_path()
|
||||
{
|
||||
$base_path = config('coolify.base_config_path');
|
||||
$proxy_path = "$base_path/proxy";
|
||||
return $proxy_path;
|
||||
}
|
||||
|
||||
function generate_default_proxy_configuration(Server $server)
|
||||
{
|
||||
$proxy_path = get_proxy_path();
|
||||
@@ -90,6 +90,7 @@ function generate_default_proxy_configuration(Server $server)
|
||||
}
|
||||
return Yaml::dump($config, 4, 2);
|
||||
}
|
||||
|
||||
function setup_default_redirect_404(string|null $redirect_url, Server $server)
|
||||
{
|
||||
ray('called');
|
||||
@@ -103,52 +104,52 @@ function setup_default_redirect_404(string|null $redirect_url, Server $server)
|
||||
} else {
|
||||
$traefik_dynamic_conf = [
|
||||
'http' =>
|
||||
[
|
||||
'routers' =>
|
||||
[
|
||||
'catchall' =>
|
||||
[
|
||||
'entryPoints' => [
|
||||
0 => 'http',
|
||||
1 => 'https',
|
||||
],
|
||||
'service' => 'noop',
|
||||
'rule' => "HostRegexp(`{catchall:.*}`)",
|
||||
'priority' => 1,
|
||||
'middlewares' => [
|
||||
0 => 'redirect-regexp@file',
|
||||
],
|
||||
],
|
||||
],
|
||||
'services' =>
|
||||
[
|
||||
'noop' =>
|
||||
[
|
||||
'loadBalancer' =>
|
||||
'routers' =>
|
||||
[
|
||||
'servers' =>
|
||||
[
|
||||
0 =>
|
||||
'catchall' =>
|
||||
[
|
||||
'url' => '',
|
||||
'entryPoints' => [
|
||||
0 => 'http',
|
||||
1 => 'https',
|
||||
],
|
||||
'service' => 'noop',
|
||||
'rule' => "HostRegexp(`{catchall:.*}`)",
|
||||
'priority' => 1,
|
||||
'middlewares' => [
|
||||
0 => 'redirect-regexp@file',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'middlewares' =>
|
||||
[
|
||||
'redirect-regexp' =>
|
||||
[
|
||||
'redirectRegex' =>
|
||||
'services' =>
|
||||
[
|
||||
'regex' => '(.*)',
|
||||
'replacement' => $redirect_url,
|
||||
'permanent' => false,
|
||||
'noop' =>
|
||||
[
|
||||
'loadBalancer' =>
|
||||
[
|
||||
'servers' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'url' => '',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'middlewares' =>
|
||||
[
|
||||
'redirect-regexp' =>
|
||||
[
|
||||
'redirectRegex' =>
|
||||
[
|
||||
'regex' => '(.*)',
|
||||
'replacement' => $redirect_url,
|
||||
'permanent' => false,
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$yaml = Yaml::dump($traefik_dynamic_conf, 12, 2);
|
||||
$yaml =
|
||||
@@ -167,4 +168,4 @@ function setup_default_redirect_404(string|null $redirect_url, Server $server)
|
||||
ray($yaml);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,12 @@ use Spatie\Activitylog\Models\Activity;
|
||||
function remote_process(
|
||||
array $command,
|
||||
Server $server,
|
||||
string $type = ActivityTypes::INLINE->value,
|
||||
string $type = ActivityTypes::INLINE->value,
|
||||
?string $type_uuid = null,
|
||||
?Model $model = null,
|
||||
bool $ignore_errors = false,
|
||||
): Activity {
|
||||
): Activity
|
||||
{
|
||||
|
||||
$command_string = implode("\n", $command);
|
||||
if (auth()->user()) {
|
||||
@@ -55,11 +56,13 @@ function remote_process(
|
||||
),
|
||||
])();
|
||||
}
|
||||
|
||||
function get_private_key_for_server(Server $server)
|
||||
{
|
||||
$temp_file = "id.root@{$server->ip}";
|
||||
return '/var/www/html/storage/app/ssh/keys/' . $temp_file;
|
||||
}
|
||||
|
||||
function save_private_key_for_server(Server $server)
|
||||
{
|
||||
if (data_get($server, 'privateKey.private_key') === null) {
|
||||
@@ -138,10 +141,10 @@ function decode_remote_command_output(?ApplicationDeploymentQueue $application_d
|
||||
}
|
||||
$formatted = collect($decoded);
|
||||
if (!$is_debug_enabled) {
|
||||
$formatted = $formatted->filter(fn ($i) => $i['hidden'] === false ?? false);
|
||||
$formatted = $formatted->filter(fn($i) => $i['hidden'] === false ?? false);
|
||||
}
|
||||
$formatted = $formatted
|
||||
->sortBy(fn ($i) => $i['order'])
|
||||
->sortBy(fn($i) => $i['order'])
|
||||
->map(function ($i) {
|
||||
$i['timestamp'] = Carbon::parse($i['timestamp'])->format('Y-M-d H:i:s.u');
|
||||
return $i;
|
||||
|
||||
@@ -3,20 +3,21 @@
|
||||
use App\Models\S3Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
function set_s3_target(S3Storage $s3) {
|
||||
function set_s3_target(S3Storage $s3)
|
||||
{
|
||||
$is_digital_ocean = false;
|
||||
if ($s3->endpoint) {
|
||||
$is_digital_ocean = Str::contains($s3->endpoint,'digitaloceanspaces.com');
|
||||
$is_digital_ocean = Str::contains($s3->endpoint, 'digitaloceanspaces.com');
|
||||
}
|
||||
config()->set('filesystems.disks.custom-s3', [
|
||||
'driver' => 's3',
|
||||
'region' => $s3['region'],
|
||||
'key' => $s3['key'],
|
||||
'secret' => $s3['secret'],
|
||||
'bucket' => $s3['bucket'],
|
||||
'endpoint' => $s3['endpoint'],
|
||||
'use_path_style_endpoint' => true,
|
||||
'bucket_endpoint' => $is_digital_ocean,
|
||||
'aws_url' => $s3->awsUrl(),
|
||||
'driver' => 's3',
|
||||
'region' => $s3['region'],
|
||||
'key' => $s3['key'],
|
||||
'secret' => $s3['secret'],
|
||||
'bucket' => $s3['bucket'],
|
||||
'endpoint' => $s3['endpoint'],
|
||||
'use_path_style_endpoint' => true,
|
||||
'bucket_endpoint' => $is_digital_ocean,
|
||||
'aws_url' => $s3->awsUrl(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ use App\Models\InstanceSettings;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
use Illuminate\Support\Str;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
|
||||
function general_error_handler(\Throwable|null $err = null, $that = null, $isJson = false, $customErrorMessage = null)
|
||||
{
|
||||
@@ -62,6 +61,7 @@ function generate_random_name()
|
||||
$cuid = new Cuid2(7);
|
||||
return Str::kebab("{$generator->getName()}-{$cuid}");
|
||||
}
|
||||
|
||||
function generate_application_name(string $git_repository, string $git_branch)
|
||||
{
|
||||
$cuid = new Cuid2(7);
|
||||
@@ -91,6 +91,7 @@ function set_transanctional_email_settings()
|
||||
"local_domain" => null,
|
||||
]);
|
||||
}
|
||||
|
||||
function base_ip()
|
||||
{
|
||||
if (isDev()) {
|
||||
@@ -99,6 +100,7 @@ function base_ip()
|
||||
$settings = InstanceSettings::get();
|
||||
return "http://{$settings->public_ipv4}";
|
||||
}
|
||||
|
||||
function base_url(bool $withPort = true)
|
||||
{
|
||||
$settings = InstanceSettings::get();
|
||||
@@ -131,7 +133,8 @@ function isDev()
|
||||
{
|
||||
return config('app.env') === 'local';
|
||||
}
|
||||
|
||||
function isCloud()
|
||||
{
|
||||
return !config('coolify.self_hosted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,18 +27,22 @@ function getSubscriptionLink($id)
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
function getPaymentLink()
|
||||
{
|
||||
return auth()->user()->currentTeam()->subscription->lemon_update_payment_menthod_url;
|
||||
}
|
||||
|
||||
function getRenewDate()
|
||||
{
|
||||
return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');
|
||||
}
|
||||
|
||||
function getEndDate()
|
||||
{
|
||||
return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');
|
||||
}
|
||||
|
||||
function isSubscribed()
|
||||
{
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user