mirror of https://github.com/docker/compose.git
improve watch configuration logging
Add action associated to each managed path Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
d646d757a2
commit
e5cd265abb
|
@ -121,13 +121,14 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
|
|||
dotGitIgnore,
|
||||
)
|
||||
|
||||
var paths []string
|
||||
var paths, pathLogs []string
|
||||
for _, trigger := range config.Watch {
|
||||
if checkIfPathAlreadyBindMounted(trigger.Path, service.Volumes) {
|
||||
logrus.Warnf("path '%s' also declared by a bind mount volume, this path won't be monitored!\n", trigger.Path)
|
||||
continue
|
||||
}
|
||||
paths = append(paths, trigger.Path)
|
||||
pathLogs = append(pathLogs, fmt.Sprintf("Action %s for path %q", trigger.Action, trigger.Path))
|
||||
}
|
||||
|
||||
watcher, err := watch.NewWatcher(paths, ignore)
|
||||
|
@ -135,7 +136,12 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(s.stdinfo(), "watching %s\n", paths)
|
||||
fmt.Fprintf(
|
||||
s.stdinfo(),
|
||||
"Watch configuration for service %q:%s\n",
|
||||
service.Name,
|
||||
strings.Join(append([]string{""}, pathLogs...), "\n - "),
|
||||
)
|
||||
err = watcher.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -420,7 +426,7 @@ func (s *composeService) handleWatchBatch(ctx context.Context, project *types.Pr
|
|||
if batch[i].Action == types.WatchActionRebuild {
|
||||
fmt.Fprintf(
|
||||
s.stdinfo(),
|
||||
"Rebuilding %s after changes were detected:%s\n",
|
||||
"Rebuilding service %q after changes were detected:%s\n",
|
||||
serviceName,
|
||||
strings.Join(append([]string{""}, batch[i].HostPath), "\n - "),
|
||||
)
|
||||
|
@ -477,7 +483,7 @@ func writeWatchSyncMessage(w io.Writer, serviceName string, pathMappings []sync.
|
|||
}
|
||||
fmt.Fprintf(
|
||||
w,
|
||||
"Syncing %s after changes were detected:%s\n",
|
||||
"Syncing %q after changes were detected:%s\n",
|
||||
serviceName,
|
||||
strings.Join(append([]string{""}, hostPathsToSync...), "\n - "),
|
||||
)
|
||||
|
@ -488,7 +494,7 @@ func writeWatchSyncMessage(w io.Writer, serviceName string, pathMappings []sync.
|
|||
}
|
||||
fmt.Fprintf(
|
||||
w,
|
||||
"Syncing %s after %d changes were detected\n",
|
||||
"Syncing service %q after %d changes were detected\n",
|
||||
serviceName,
|
||||
len(pathMappings),
|
||||
)
|
||||
|
|
|
@ -106,7 +106,7 @@ func TestRebuildOnDotEnvWithExternalNetwork(t *testing.T) {
|
|||
out := r.String()
|
||||
errors := r.String()
|
||||
return strings.Contains(out,
|
||||
"watching"), fmt.Sprintf("'watching' not found in : \n%s\nStderr: \n%s\n", out,
|
||||
"Watch configuration"), fmt.Sprintf("'Watch configuration' not found in : \n%s\nStderr: \n%s\n", out,
|
||||
errors)
|
||||
}, 30*time.Second, 1*time.Second)
|
||||
|
||||
|
|
Loading…
Reference in New Issue