From 31576138bf9bd0c7c4a35ae6347945527a108db0 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Sun, 27 Oct 2024 23:18:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=B7=AF=E5=BE=84=E4=B8=BA=E7=A9=BA=E6=97=B6?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=88=A0=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#6862)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/dto/container.go | 2 +- backend/app/service/container_compose.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/dto/container.go b/backend/app/dto/container.go index 1fa107a26..ba71946c8 100644 --- a/backend/app/dto/container.go +++ b/backend/app/dto/container.go @@ -218,7 +218,7 @@ type ComposeCreate struct { } type ComposeOperation struct { Name string `json:"name" validate:"required"` - Path string `json:"path" validate:"required"` + Path string `json:"path"` Operation string `json:"operation" validate:"required,oneof=up start stop down delete"` WithFile bool `json:"withFile"` } diff --git a/backend/app/service/container_compose.go b/backend/app/service/container_compose.go index 3a245efd1..e09a44c5c 100644 --- a/backend/app/service/container_compose.go +++ b/backend/app/service/container_compose.go @@ -252,6 +252,10 @@ func (u *ContainerService) CreateCompose(req dto.ComposeCreate) (string, error) } func (u *ContainerService) ComposeOperation(req dto.ComposeOperation) error { + if len(req.Path) == 0 && req.Operation == "delete" { + _ = composeRepo.DeleteRecord(commonRepo.WithByName(req.Name)) + return nil + } if cmd.CheckIllegal(req.Path, req.Operation) { return buserr.New(constant.ErrCmdIllegal) }