Skip to content

Commit

Permalink
Merge pull request #1304 from dgageot/simpler-runner-light
Browse files Browse the repository at this point in the history
Simpler Runner
  • Loading branch information
dgageot committed Nov 21, 2018
2 parents ae1ed38 + 8e53167 commit e43c479
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions pkg/skaffold/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ func NewForConfig(opts *config.SkaffoldOptions, cfg *latest.SkaffoldPipeline) (*
func getBuilder(cfg *latest.BuildConfig, kubeContext string) (build.Builder, error) {
switch {
case cfg.LocalBuild != nil:
logrus.Debugf("Using builder: local")
logrus.Debugln("Using builder: local")
return local.NewBuilder(cfg.LocalBuild, kubeContext)

case cfg.GoogleCloudBuild != nil:
logrus.Debugf("Using builder: google cloud")
logrus.Debugln("Using builder: google cloud")
return gcb.NewBuilder(cfg.GoogleCloudBuild), nil

case cfg.KanikoBuild != nil:
logrus.Debugf("Using builder: kaniko")
logrus.Debugln("Using builder: kaniko")
return kaniko.NewBuilder(cfg.KanikoBuild)

case cfg.AzureContainerBuild != nil:
logrus.Debugf("Using builder: acr")
logrus.Debugln("Using builder: acr")
return acr.NewBuilder(cfg.AzureContainerBuild), nil

default:
Expand Down Expand Up @@ -246,16 +246,13 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
// Create watcher and register artifacts to build current state of files.
changed := changes{}
onChange := func() error {
hasError := true

logger.Mute()
defer func() {
changed.reset()
r.Trigger.WatchForChanges(out)
if !hasError {
logger.Unmute()
}
}()

logger.Mute()

for _, a := range changed.dirtyArtifacts {
s, err := sync.NewItem(a.artifact, a.events, r.builds)
if err != nil {
Expand All @@ -277,7 +274,7 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
color.Default.Fprintf(out, "Syncing %d files for %s\n", len(s.Copy)+len(s.Delete), s.Image)

if err := r.Syncer.Sync(ctx, s); err != nil {
logrus.Warnln("Skipping build and deploy due to sync error:", err)
logrus.Warnln("Skipping deploy due to sync error:", err)
return nil
}
}
Expand Down Expand Up @@ -305,7 +302,7 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
}
}

hasError = false
logger.Unmute()
return nil
}

Expand Down

0 comments on commit e43c479

Please sign in to comment.