refactoring

This commit is contained in:
Saeed Vaziry
2023-08-04 18:28:04 +02:00
parent 8444323cf4
commit 643318fcfc
349 changed files with 3189 additions and 2729 deletions

View File

@ -3,6 +3,7 @@
namespace App\Models;
use App\Contracts\ServerType;
use App\Enums\ServerStatus;
use App\Facades\SSH;
use App\Jobs\Installation\Upgrade;
use App\Jobs\Server\CheckConnection;
@ -232,9 +233,9 @@ public function install(): void
// $this->team->notify(new ServerInstallationStarted($this));
}
public function ssh(string $user = null, bool $defaultKeys = false): \App\Helpers\SSH|SSHFake
public function ssh(string $user = null): \App\Helpers\SSH|SSHFake
{
return SSH::init($this, $user, $defaultKeys);
return SSH::init($this, $user);
}
public function installedPHPVersions(): array
@ -323,7 +324,7 @@ public function getSshUserAttribute(string $value): string
return config('core.ssh_user');
}
public function sshKey(bool $default = false): array
public function sshKey(): array
{
if (app()->environment() == 'testing') {
return [
@ -333,14 +334,6 @@ public function sshKey(bool $default = false): array
];
}
if ($default) {
return [
'public_key' => Str::replace("\n", '', File::get(storage_path(config('core.ssh_public_key_name')))),
'public_key_path' => storage_path(config('core.ssh_public_key_name')),
'private_key_path' => storage_path(config('core.ssh_private_key_name')),
];
}
return [
'public_key' => Str::replace("\n", '', Storage::disk(config('core.key_pairs_disk'))->get($this->id.'.pub')),
'public_key_path' => Storage::disk(config('core.key_pairs_disk'))->path($this->id.'.pub'),
@ -385,4 +378,9 @@ public function getHostnameAttribute(): string
{
return Str::of($this->name)->slug();
}
public function isReady(): bool
{
return $this->status == ServerStatus::READY;
}
}