Skip to content

Commit

Permalink
chore(watch): remove old docker cp implementation
Browse files Browse the repository at this point in the history
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 <milas.bowman@docker.com>
  • Loading branch information
milas committed Feb 13, 2024
1 parent 894ab41 commit d203402
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 379 deletions.
104 changes: 0 additions & 104 deletions internal/sync/docker_cp.go

This file was deleted.

91 changes: 0 additions & 91 deletions internal/sync/writer.go

This file was deleted.

152 changes: 0 additions & 152 deletions internal/sync/writer_test.go

This file was deleted.

21 changes: 13 additions & 8 deletions pkg/compose/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,34 @@ type fileEvent struct {
Action types.WatchAction
}

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

Check warning on line 62 in pkg/compose/watch.go

View check run for this annotation

Codecov / codecov/patch

pkg/compose/watch.go#L62

Added line #L62 was not covered by tests
}

return sync.NewDockerCopy(project.Name, s, s.stdinfo())
return sync.NewTar(project.Name, tarDockerClient{s: s}), nil
}

func (s *composeService) Watch(ctx context.Context, project *types.Project, services []string, options api.WatchOptions) error { //nolint: gocyclo
var err error
if project, err = project.WithSelectedServices(services); err != nil {
return err
}
syncer := s.getSyncImplementation(project)
syncer, err := s.getSyncImplementation(project)
if err != nil {
return err
}

Check warning on line 76 in pkg/compose/watch.go

View check run for this annotation

Codecov / codecov/patch

pkg/compose/watch.go#L75-L76

Added lines #L75 - L76 were not covered by tests
eg, ctx := errgroup.WithContext(ctx)
watching := false
for i := range project.Services {
Expand Down
Loading

0 comments on commit d203402

Please sign in to comment.