Skip to content

Commit

Permalink
manage watch applied to mulitple services
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Jan 16, 2025
1 parent 083f676 commit c95b804
Show file tree
Hide file tree
Showing 11 changed files with 388 additions and 492 deletions.
4 changes: 1 addition & 3 deletions internal/sync/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ package sync

import (
"context"

"github.com/compose-spec/compose-go/v2/types"
)

// PathMapping contains the Compose service and modified host system path.
Expand All @@ -38,5 +36,5 @@ type PathMapping struct {
}

type Syncer interface {
Sync(ctx context.Context, service types.ServiceConfig, paths []PathMapping) error
Sync(ctx context.Context, service string, paths []*PathMapping) error
}
7 changes: 3 additions & 4 deletions internal/sync/tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (

"github.com/hashicorp/go-multierror"

"github.com/compose-spec/compose-go/v2/types"
moby "github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/archive"
)
Expand Down Expand Up @@ -65,8 +64,8 @@ func NewTar(projectName string, client LowLevelClient) *Tar {
}
}

func (t *Tar) Sync(ctx context.Context, service types.ServiceConfig, paths []PathMapping) error {
containers, err := t.client.ContainersForService(ctx, t.projectName, service.Name)
func (t *Tar) Sync(ctx context.Context, service string, paths []*PathMapping) error {
containers, err := t.client.ContainersForService(ctx, t.projectName, service)
if err != nil {
return err
}
Expand All @@ -77,7 +76,7 @@ func (t *Tar) Sync(ctx context.Context, service types.ServiceConfig, paths []Pat
if _, err := os.Stat(p.HostPath); err != nil && errors.Is(err, fs.ErrNotExist) {
pathsToDelete = append(pathsToDelete, p.ContainerPath)
} else {
pathsToCopy = append(pathsToCopy, p)
pathsToCopy = append(pathsToCopy, *p)
}
}

Expand Down
Loading

0 comments on commit c95b804

Please sign in to comment.