diff --git a/app/Actions/PHP/UpdatePHPIni.php b/app/Actions/PHP/UpdatePHPIni.php index 41f2ceb..fd9392b 100755 --- a/app/Actions/PHP/UpdatePHPIni.php +++ b/app/Actions/PHP/UpdatePHPIni.php @@ -17,9 +17,12 @@ public function update(Service $service, string $ini): void { $tmpName = Str::random(10).strtotime('now'); try { - Storage::disk('local')->put($tmpName, $ini); + /** @var \Illuminate\Filesystem\FilesystemAdapter $storageDisk */ + $storageDisk = Storage::disk('local'); + + $storageDisk->put($tmpName, $ini); $service->server->ssh('root')->upload( - Storage::disk('local')->path($tmpName), + $storageDisk->path($tmpName), "/etc/php/$service->version/cli/php.ini" ); $this->deleteTempFile($tmpName); diff --git a/app/Models/Server.php b/app/Models/Server.php index 4062246..455e27a 100755 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -343,10 +343,13 @@ public function sshKey(): array ]; } + /** @var \Illuminate\Filesystem\FilesystemAdapter $storageDisk */ + $storageDisk = Storage::disk(config('core.key_pairs_disk')); + 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'), - 'private_key_path' => Storage::disk(config('core.key_pairs_disk'))->path((string) $this->id), + 'public_key_path' => $storageDisk->path($this->id.'.pub'), + 'private_key_path' => $storageDisk->path((string) $this->id), ]; } diff --git a/app/ServerProviders/AWS.php b/app/ServerProviders/AWS.php index de4de80..27a0eda 100755 --- a/app/ServerProviders/AWS.php +++ b/app/ServerProviders/AWS.php @@ -164,10 +164,12 @@ private function createKeyPair(): void $result = $this->ec2Client->createKeyPair([ 'KeyName' => $keyName, ]); - Storage::disk(config('core.key_pairs_disk'))->put((string) $this->server->id, $result['KeyMaterial']); + /** @var \Illuminate\Filesystem\FilesystemAdapter $storageDisk */ + $storageDisk = Storage::disk(config('core.key_pairs_disk')); + $storageDisk->put((string) $this->server->id, $result['KeyMaterial']); generate_public_key( - Storage::disk(config('core.key_pairs_disk'))->path((string) $this->server->id), - Storage::disk(config('core.key_pairs_disk'))->path($this->server->id.'.pub'), + $storageDisk->path((string) $this->server->id), + $storageDisk->path($this->server->id.'.pub'), ); } diff --git a/app/ServerProviders/AbstractProvider.php b/app/ServerProviders/AbstractProvider.php index 1856326..e6b8f93 100755 --- a/app/ServerProviders/AbstractProvider.php +++ b/app/ServerProviders/AbstractProvider.php @@ -17,6 +17,8 @@ public function __construct(?Server $server = null) protected function generateKeyPair(): void { - generate_key_pair(Storage::disk(config('core.key_pairs_disk'))->path((string) $this->server->id)); + /** @var \Illuminate\Filesystem\FilesystemAdapter $storageDisk */ + $storageDisk = Storage::disk(config('core.key_pairs_disk')); + generate_key_pair($storageDisk->path((string) $this->server->id)); } } diff --git a/app/ServerProviders/Custom.php b/app/ServerProviders/Custom.php index 4b0f760..c6dda2c 100755 --- a/app/ServerProviders/Custom.php +++ b/app/ServerProviders/Custom.php @@ -59,13 +59,15 @@ public function regions(): array public function create(): void { + /** @var \Illuminate\Filesystem\FilesystemAdapter $storageDisk */ + $storageDisk = Storage::disk(config('core.key_pairs_disk')); File::copy( storage_path(config('core.ssh_private_key_name')), - Storage::disk(config('core.key_pairs_disk'))->path($this->server->id) + $storageDisk->path($this->server->id) ); File::copy( storage_path(config('core.ssh_public_key_name')), - Storage::disk(config('core.key_pairs_disk'))->path($this->server->id.'.pub') + $storageDisk->path($this->server->id.'.pub') ); } diff --git a/app/ServerProviders/Vultr.php b/app/ServerProviders/Vultr.php index 851233e..2e64ca4 100644 --- a/app/ServerProviders/Vultr.php +++ b/app/ServerProviders/Vultr.php @@ -85,7 +85,9 @@ public function regions(): array public function create(): void { // generate key pair - generate_key_pair(Storage::disk(config('core.key_pairs_disk'))->path((string) $this->server->id)); + /** @var \Illuminate\Filesystem\FilesystemAdapter $storageDisk */ + $storageDisk = Storage::disk(config('core.key_pairs_disk')); + generate_key_pair($storageDisk->path((string) $this->server->id)); $createSshKey = Http::withToken($this->server->serverProvider->credentials['token']) ->post($this->apiUrl.'/ssh-keys', [ diff --git a/config/core.php b/config/core.php index 411b592..1ac8eea 100755 --- a/config/core.php +++ b/config/core.php @@ -39,8 +39,8 @@ 'ssh_user' => env('SSH_USER', 'vito'), 'ssh_public_key_name' => env('SSH_PUBLIC_KEY_NAME', 'ssh-public.key'), 'ssh_private_key_name' => env('SSH_PRIVATE_KEY_NAME', 'ssh-private.pem'), - 'logs_disk' => env('SERVER_LOGS_DISK', 'server-logs-local'), - 'key_pairs_disk' => env('KEY_PAIRS_DISK', 'key-pairs-local'), + 'logs_disk' => env('SERVER_LOGS_DISK', 'server-logs-local'), // should to be FilesystemAdapter storage + 'key_pairs_disk' => env('KEY_PAIRS_DISK', 'key-pairs-local'), // should to be FilesystemAdapter storage /* * General diff --git a/config/filesystems.php b/config/filesystems.php index edb159c..c2e46c0 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -30,6 +30,7 @@ 'disks' => [ + // should be FilesystemAdapter 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), diff --git a/resources/views/livewire/projects/create-project.blade.php b/resources/views/livewire/projects/create-project.blade.php index f1a3472..cc85981 100644 --- a/resources/views/livewire/projects/create-project.blade.php +++ b/resources/views/livewire/projects/create-project.blade.php @@ -1,6 +1,6 @@
- {{ __('Create') }} + {{ __('Connect') }}