Skip to content

Commit d203402

Browse files
committed
chore(watch): remove old docker cp implementation
This has not been the default for quite a while and required setting an environment variable to revert back. The tar implementation is more performant and addresses several edge cases with the original `docker cp` version, so it's time to fully retire it. The scaffolding for multiple sync implementations remains to support future experimentation here. Signed-off-by: Milas Bowman <[email protected]>
1 parent 894ab41 commit d203402

File tree

5 files changed

+22
-379
lines changed

5 files changed

+22
-379
lines changed

Diff for: internal/sync/docker_cp.go

-104
This file was deleted.

Diff for: internal/sync/writer.go

-91
This file was deleted.

Diff for: internal/sync/writer_test.go

-152
This file was deleted.

Diff for: pkg/compose/watch.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,34 @@ type fileEvent struct {
4646
Action types.WatchAction
4747
}
4848

49-
// getSyncImplementation returns the the tar-based syncer unless it has been explicitly
50-
// disabled with `COMPOSE_EXPERIMENTAL_WATCH_TAR=0`. Note that the absence of the env
51-
// var means enabled.
52-
func (s *composeService) getSyncImplementation(project *types.Project) sync.Syncer {
49+
// getSyncImplementation returns an appropriate sync implementation for the
50+
// project.
51+
//
52+
// Currently, an implementation that batches files and transfers them using
53+
// the Moby `Untar` API.
54+
func (s *composeService) getSyncImplementation(project *types.Project) (sync.Syncer, error) {
5355
var useTar bool
5456
if useTarEnv, ok := os.LookupEnv("COMPOSE_EXPERIMENTAL_WATCH_TAR"); ok {
5557
useTar, _ = strconv.ParseBool(useTarEnv)
5658
} else {
5759
useTar = true
5860
}
59-
if useTar {
60-
return sync.NewTar(project.Name, tarDockerClient{s: s})
61+
if !useTar {
62+
return nil, errors.New("no available sync implementation")
6163
}
6264

63-
return sync.NewDockerCopy(project.Name, s, s.stdinfo())
65+
return sync.NewTar(project.Name, tarDockerClient{s: s}), nil
6466
}
6567

6668
func (s *composeService) Watch(ctx context.Context, project *types.Project, services []string, options api.WatchOptions) error { //nolint: gocyclo
6769
var err error
6870
if project, err = project.WithSelectedServices(services); err != nil {
6971
return err
7072
}
71-
syncer := s.getSyncImplementation(project)
73+
syncer, err := s.getSyncImplementation(project)
74+
if err != nil {
75+
return err
76+
}
7277
eg, ctx := errgroup.WithContext(ctx)
7378
watching := false
7479
for i := range project.Services {

0 commit comments

Comments
 (0)