Skip to content

Commit

Permalink
Watch for all devfile dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Aug 11, 2022
1 parent 7dde4e1 commit 21798ac
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/watch/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/redhat-developer/odo/pkg/devfile/adapters"
"github.com/redhat-developer/odo/pkg/kclient"
"github.com/redhat-developer/odo/pkg/labels"
"github.com/redhat-developer/odo/pkg/libdevfile"
"github.com/redhat-developer/odo/pkg/log"
"github.com/redhat-developer/odo/pkg/state"

Expand Down Expand Up @@ -223,7 +224,6 @@ func (o *WatchClient) WatchAndPush(out io.Writer, parameters WatchParameters, ct
var sourcesWatcher *fsnotify.Watcher
var err error
if parameters.WatchFiles {
// TODO(feloy) ignore files included by Devfile?
sourcesWatcher, err = getFullSourcesWatcher(parameters.Path, parameters.FileIgnores)
if err != nil {
return err
Expand All @@ -242,16 +242,23 @@ func (o *WatchClient) WatchAndPush(out io.Writer, parameters WatchParameters, ct
return fmt.Errorf("error watching deployment: %v", err)
}

// TODO(feloy) watch files included by Devfile
devfileWatcher, err := fsnotify.NewWatcher()
if err != nil {
return err
}
if parameters.WatchFiles {
err = devfileWatcher.Add(parameters.DevfilePath)
var devfileFiles []string
devfileFiles, err = libdevfile.GetReferencedLocalFiles(parameters.InitialDevfileObj)
if err != nil {
return err
}
devfileFiles = append(devfileFiles, parameters.DevfilePath)
for _, f := range devfileFiles {
err = devfileWatcher.Add(f)
if err != nil {
return err
}
}
}

podWatcher, err := o.kubeClient.PodWatcher(ctx, selector)
Expand Down

0 comments on commit 21798ac

Please sign in to comment.