Skip to content

Commit

Permalink
Merge pull request #11497 from milas/rm-docker-cp-syncer
Browse files Browse the repository at this point in the history
chore(watch): remove old `docker cp` implementation
  • Loading branch information
glours committed Feb 14, 2024
2 parents e330f59 + d203402 commit a220043
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")
}

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
}
eg, ctx := errgroup.WithContext(ctx)
watching := false
for i := range project.Services {
Expand Down

0 comments on commit a220043

Please sign in to comment.