(req dto.ComposeCreate)
| 189 | } |
| 190 | |
| 191 | func (u *ContainerService) TestCompose(req dto.ComposeCreate) (bool, error) { |
| 192 | if cmd.CheckIllegal(req.Path) { |
| 193 | return false, buserr.New("ErrCmdIllegal") |
| 194 | } |
| 195 | composeItem, _ := composeRepo.GetRecord(repo.WithByName(req.Name)) |
| 196 | if composeItem.ID != 0 { |
| 197 | return false, buserr.New("ErrRecordExist") |
| 198 | } |
| 199 | if err := u.loadPath(&req); err != nil { |
| 200 | return false, err |
| 201 | } |
| 202 | if err := newComposeEnv(req.Path, req.Env); err != nil { |
| 203 | return false, err |
| 204 | } |
| 205 | cmd := getComposeCmd(req.Path, "config") |
| 206 | stdout, err := cmd.CombinedOutput() |
| 207 | if err != nil { |
| 208 | return false, fmt.Errorf("docker-compose config failed, std: %s, err: %v", string(stdout), err) |
| 209 | } |
| 210 | return true, nil |
| 211 | } |
| 212 | |
| 213 | func (u *ContainerService) CreateCompose(req dto.ComposeCreate) error { |
| 214 | if cmd.CheckIllegal(req.Name, req.Path) { |
nothing calls this directly
no test coverage detected