Skip to content

Commit

Permalink
Add logs when listing files to be watched (#2743)
Browse files Browse the repository at this point in the history
Fixes #2742

Signed-off-by: David Gageot <[email protected]>
  • Loading branch information
dgageot authored Aug 30, 2019
1 parent c2943c3 commit 13a5d59
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions pkg/skaffold/runner/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,28 +120,38 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
defer r.forwarderManager.Stop()

// Watch artifacts
start := time.Now()
color.Default.Fprintln(out, "Listing files to watch...")

for i := range artifacts {
artifact := artifacts[i]
if !r.runCtx.Opts.IsTargetImage(artifact) {
continue
}

if err := r.monitor.Register(
func() ([]string, error) { return r.builder.DependenciesForArtifact(ctx, artifact) },
func(e filemon.Events) {
syncMap := func() (map[string][]string, error) { return r.builder.SyncMap(ctx, artifact) }
s, err := sync.NewItem(artifact, e, r.builds, r.runCtx.InsecureRegistries, syncMap)
switch {
case err != nil:
logrus.Warnf("error adding dirty artifact to changeset: %s", err.Error())
case s != nil:
r.changeSet.AddResync(s)
default:
r.changeSet.AddRebuild(artifact)
}
},
); err != nil {
return errors.Wrapf(err, "watching files for artifact %s", artifact.ImageName)
color.Default.Fprintf(out, " - %s\n", artifact.ImageName)

select {
case <-ctx.Done():
return context.Canceled
default:
if err := r.monitor.Register(
func() ([]string, error) { return r.builder.DependenciesForArtifact(ctx, artifact) },
func(e filemon.Events) {
syncMap := func() (map[string][]string, error) { return r.builder.SyncMap(ctx, artifact) }
s, err := sync.NewItem(artifact, e, r.builds, r.runCtx.InsecureRegistries, syncMap)
switch {
case err != nil:
logrus.Warnf("error adding dirty artifact to changeset: %s", err.Error())
case s != nil:
r.changeSet.AddResync(s)
default:
r.changeSet.AddRebuild(artifact)
}
},
); err != nil {
return errors.Wrapf(err, "watching files for artifact %s", artifact.ImageName)
}
}
}

Expand Down Expand Up @@ -169,6 +179,8 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
return errors.Wrapf(err, "watching skaffold configuration %s", r.runCtx.Opts.ConfigurationFile)
}

color.Default.Fprintln(out, "List generated in", time.Since(start))

// First build
if _, err := r.BuildAndTest(ctx, out, artifacts); err != nil {
return errors.Wrap(err, "exiting dev mode because first build failed")
Expand Down

0 comments on commit 13a5d59

Please sign in to comment.