MCPcopy
hub / github.com/docker/compose / loadDevelopmentConfig

Function loadDevelopmentConfig

pkg/compose/watch.go:395–434  ·  view source on GitHub ↗
(service types.ServiceConfig, project *types.Project)

Source from the content-addressed store, hash-verified

393}
394
395func loadDevelopmentConfig(service types.ServiceConfig, project *types.Project) (*types.DevelopConfig, error) {
396 var config types.DevelopConfig
397 y, ok := service.Extensions["x-develop"]
398 if !ok {
399 return nil, nil
400 }
401 logrus.Warnf("x-develop is DEPRECATED, please use the official `develop` attribute")
402 err := mapstructure.Decode(y, &config)
403 if err != nil {
404 return nil, err
405 }
406 baseDir, err := filepath.EvalSymlinks(project.WorkingDir)
407 if err != nil {
408 return nil, fmt.Errorf("resolving symlink for %q: %w", project.WorkingDir, err)
409 }
410
411 for i, trigger := range config.Watch {
412 if !filepath.IsAbs(trigger.Path) {
413 trigger.Path = filepath.Join(baseDir, trigger.Path)
414 }
415 if p, err := filepath.EvalSymlinks(trigger.Path); err == nil {
416 // this might fail because the path doesn't exist, etc.
417 trigger.Path = p
418 }
419 trigger.Path = filepath.Clean(trigger.Path)
420 if trigger.Path == "" {
421 return nil, errors.New("watch rules MUST define a path")
422 }
423
424 if trigger.Action == types.WatchActionRebuild && service.Build == nil {
425 return nil, fmt.Errorf("service %s doesn't have a build section, can't apply %s on watch", types.WatchActionRebuild, service.Name)
426 }
427 if trigger.Action == types.WatchActionSyncExec && len(trigger.Exec.Command) == 0 {
428 return nil, fmt.Errorf("can't watch with action %q on service %s without a command", types.WatchActionSyncExec, service.Name)
429 }
430
431 config.Watch[i] = trigger
432 }
433 return &config, nil
434}
435
436func checkIfPathAlreadyBindMounted(watchPath string, volumes []types.ServiceVolumeConfig) bool {
437 for _, volume := range volumes {

Callers 1

watchMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected