Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logs when listing files to be watched #2743

Merged
merged 1 commit into from
Aug 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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