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) }