fix: delete persistent storages on resource deletion

This commit is contained in:
Andras Bacsai
2023-09-22 11:34:27 +02:00
parent 53d1fa0331
commit 9c2fea4b2e
4 changed files with 22 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Http\Livewire\Project\Shared;
use App\Actions\Service\StopService;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
@@ -22,14 +23,15 @@ class Danger extends Component
try {
if ($this->resource->type() === 'service') {
$server = $this->resource->server;
StopService::run($this->resource);
} else {
$destination = data_get($this->resource, 'destination');
if ($destination) {
$destination = $this->resource->destination->getMorphClass()::where('id', $this->resource->destination->id)->first();
$server = $destination->server;
}
instant_remote_process(["docker rm -f {$this->resource->uuid}"], $server);
}
instant_remote_process(["docker rm -f {$this->resource->uuid}"], $server);
$this->resource->delete();
return redirect()->route('project.resources', [
'project_uuid' => $this->parameters['project_uuid'],