MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / TestCompose

Method TestCompose

agent/app/service/container_compose.go:191–211  ·  view source on GitHub ↗
(req dto.ComposeCreate)

Source from the content-addressed store, hash-verified

189}
190
191func (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
213func (u *ContainerService) CreateCompose(req dto.ComposeCreate) error {
214 if cmd.CheckIllegal(req.Name, req.Path) {

Callers

nothing calls this directly

Calls 4

loadPathMethod · 0.95
newComposeEnvFunction · 0.85
getComposeCmdFunction · 0.85
GetRecordMethod · 0.65

Tested by

no test coverage detected