From e918c6457eeffd82d51b94843407992c4754e044 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Fri, 13 Sep 2024 15:22:53 +0300 Subject: [PATCH] update --- .../App/Filament/Resources/GitRepositoryResource.php | 5 +++++ web/app/Models/GitRepository.php | 11 ++++++----- web/resources/views/actions/git/clone-repo.blade.php | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/web/Modules/Customer/App/Filament/Resources/GitRepositoryResource.php b/web/Modules/Customer/App/Filament/Resources/GitRepositoryResource.php index a1e262d..7495185 100644 --- a/web/Modules/Customer/App/Filament/Resources/GitRepositoryResource.php +++ b/web/Modules/Customer/App/Filament/Resources/GitRepositoryResource.php @@ -33,6 +33,11 @@ class GitRepositoryResource extends Resource ->required() ->columnSpanFull(), + Forms\Components\Select::make('git_ssh_key_id') + ->label('SSH Key') + ->options(fn () => \App\Models\GitSshKey::pluck('name', 'id')) + ->columnSpanFull(), + ]); } diff --git a/web/app/Models/GitRepository.php b/web/app/Models/GitRepository.php index 1e3a5ab..7bb62c0 100644 --- a/web/app/Models/GitRepository.php +++ b/web/app/Models/GitRepository.php @@ -71,10 +71,12 @@ class GitRepository extends Model return $this->belongsTo(Domain::class); } - private function _getSSHKey($findHostingSubscription) + private function _getSSHKey($gitSshKeyId, $findHostingSubscription) { + $gitSSHKey = GitSshKey::where('id', $gitSshKeyId) + ->where('hosting_subscription_id', $findHostingSubscription->id) + ->first(); - $gitSSHKey = GitSshKey::find($this->git_ssh_key_id); if ($gitSSHKey) { $sshPath = '/home/'.$findHostingSubscription->system_username .'/.ssh'; $privateKeyFile = $sshPath.'/id_rsa_'. $gitSSHKey->id; @@ -131,12 +133,11 @@ class GitRepository extends Model $projectDir = $findDomain->domain_root . '/' . $this->dir; $privateKeyFile = null; - $getSSHKey = $this->_getSSHKey($findHostingSubscription); + $getSSHKey = $this->_getSSHKey($this->git_ssh_key_id, $findHostingSubscription); if (isset($getSSHKey['privateKeyFile'])) { $privateKeyFile = $getSSHKey['privateKeyFile']; } - $gitSSHUrl = GitClient::parseGitUrl($this->url); if (!isset($gitSSHUrl['provider'])) { $this->status = self::STATUS_FAILED; @@ -190,7 +191,7 @@ class GitRepository extends Model $projectDir = $findDomain->domain_root . '/' . $this->dir; $privateKeyFile = null; - $getSSHKey = $this->_getSSHKey($findHostingSubscription); + $getSSHKey = $this->_getSSHKey($this->git_ssh_key_id, $findHostingSubscription); if (isset($getSSHKey['privateKeyFile'])) { $privateKeyFile = $getSSHKey['privateKeyFile']; } diff --git a/web/resources/views/actions/git/clone-repo.blade.php b/web/resources/views/actions/git/clone-repo.blade.php index dba9768..fc0aad2 100644 --- a/web/resources/views/actions/git/clone-repo.blade.php +++ b/web/resources/views/actions/git/clone-repo.blade.php @@ -18,4 +18,4 @@ su -m {{$systemUsername}} -c 'git clone {{$cloneUrl}} {{$projectDir}}' phyre-php /usr/local/phyre/web/artisan git-repository:mark-as-cloned {{$gitRepositoryId}} -# rm -rf /tmp/git-clone-{{$gitRepositoryId}}.sh +rm -rf /tmp/git-clone-{{$gitRepositoryId}}.sh