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

Method CreateCompose

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

Source from the content-addressed store, hash-verified

211}
212
213func (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
247func (u *ContainerService) ComposeOperation(req dto.ComposeOperation) error {
248 if len(req.Path) == 0 && req.Operation == "delete" {

Callers

nothing calls this directly

Calls 6

loadPathMethod · 0.95
newComposeEnvFunction · 0.85
CreateRecordMethod · 0.65
AddSubTaskMethod · 0.45
LogWithStatusMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected