mirror of https://github.com/docker/compose.git
use tilt watcher to track filesystem changes
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
25576289c8
commit
e63cbfba0e
4
go.mod
4
go.mod
|
@ -16,7 +16,7 @@ require (
|
|||
github.com/docker/docker v20.10.20+incompatible // replaced; see replace rule for actual version
|
||||
github.com/docker/go-connections v0.4.0
|
||||
github.com/docker/go-units v0.5.0
|
||||
github.com/fsnotify/fsnotify v1.6.0
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/golang/mock v1.6.0
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/hashicorp/go-version v1.6.0
|
||||
|
@ -153,8 +153,6 @@ require (
|
|||
|
||||
require go.uber.org/goleak v1.1.12
|
||||
|
||||
require github.com/fsnotify/fsevents v0.1.1
|
||||
|
||||
replace (
|
||||
// Override for e2e tests
|
||||
github.com/cucumber/godog => github.com/laurazard/godog v0.0.0-20220922095256-4c4b17abdae7
|
||||
|
|
2
go.sum
2
go.sum
|
@ -205,8 +205,6 @@ github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw
|
|||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
|
||||
github.com/fsnotify/fsevents v0.1.1 h1:/125uxJvvoSDDBPen6yUZbil8J9ydKZnnl3TWWmvnkw=
|
||||
github.com/fsnotify/fsevents v0.1.1/go.mod h1:+d+hS27T6k5J8CRaPLKFgwKYcpS7GwW3Ule9+SC2ZRc=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/docker/compose/v2/pkg/api"
|
||||
"github.com/docker/compose/v2/pkg/utils"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/docker/compose/v2/pkg/watch"
|
||||
"github.com/jonboulle/clockwork"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -88,25 +88,32 @@ func (s *composeService) Watch(ctx context.Context, project *types.Project, serv
|
|||
}
|
||||
context := service.Build.Context
|
||||
|
||||
watcher, err := fsnotify.NewWatcher()
|
||||
ignore, err := watch.LoadDockerIgnore(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
watcher, err := watch.NewWatcher([]string{context}, ignore)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("watching " + context)
|
||||
err = watcher.Add(context)
|
||||
err = watcher.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
eg.Go(func() error {
|
||||
defer watcher.Close() //nolint:errcheck
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case event := <-watcher.Events:
|
||||
log.Println("fs event :", event.String())
|
||||
case event := <-watcher.Events():
|
||||
log.Println("fs event :", event.Path())
|
||||
needRefresh <- service.Name
|
||||
case err := <-watcher.Errors:
|
||||
case err := <-watcher.Errors():
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ func (i dockerPathMatcher) MatchesEntireDir(f string) (bool, error) {
|
|||
return true, nil
|
||||
}
|
||||
|
||||
func NewDockerIgnoreTester(repoRoot string) (*dockerPathMatcher, error) {
|
||||
func LoadDockerIgnore(repoRoot string) (*dockerPathMatcher, error) {
|
||||
absRoot, err := filepath.Abs(repoRoot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
package watch
|
||||
|
||||
/**
|
||||
FIXME this implementation requires CGO
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
@ -155,3 +158,4 @@ func newFSEventWatcher(paths []string, ignore PathMatcher) (*fseventNotify, erro
|
|||
}
|
||||
|
||||
var _ Notify = &fseventNotify{}
|
||||
**/
|
||||
|
|
Loading…
Reference in New Issue