(req dto.ComposeCreate)
| 211 | } |
| 212 | |
| 213 | func (u *ContainerService) CreateCompose(req dto.ComposeCreate) error { |
| 214 | if cmd.CheckIllegal(req.Name, req.Path) { |
| 215 | return buserr.New("ErrCmdIllegal") |
| 216 | } |
| 217 | if err := u.loadPath(&req); err != nil { |
| 218 | return err |
| 219 | } |
| 220 | if req.From == "path" { |
| 221 | req.Name = path.Base(path.Dir(req.Path)) |
| 222 | } |
| 223 | taskItem, err := task.NewTaskWithOps(req.Name, task.TaskCreate, task.TaskScopeCompose, req.TaskID, 1) |
| 224 | if err != nil { |
| 225 | return fmt.Errorf("new task for image build failed, err: %v", err) |
| 226 | } |
| 227 | if err := newComposeEnv(req.Path, req.Env); err != nil { |
| 228 | return err |
| 229 | } |
| 230 | go func() { |
| 231 | taskItem.AddSubTask(i18n.GetMsgByKey("ComposeCreate"), func(t *task.Task) error { |
| 232 | err := compose.UpWithTask(req.Path, t, req.ForcePull) |
| 233 | t.LogWithStatus(i18n.GetMsgByKey("ComposeCreate"), err) |
| 234 | if err != nil { |
| 235 | _, _ = compose.Down(req.Path) |
| 236 | return err |
| 237 | } |
| 238 | _ = composeRepo.CreateRecord(&model.Compose{Name: strings.ToLower(req.Name), Path: req.Path}) |
| 239 | return nil |
| 240 | }, nil) |
| 241 | _ = taskItem.Execute() |
| 242 | }() |
| 243 | |
| 244 | return nil |
| 245 | } |
| 246 | |
| 247 | func (u *ContainerService) ComposeOperation(req dto.ComposeOperation) error { |
| 248 | if len(req.Path) == 0 && req.Operation == "delete" { |
nothing calls this directly
no test coverage detected