diff --git a/pkg/engine/destroy.go b/pkg/engine/destroy.go index 3829c1c16..9b67bcd5f 100644 --- a/pkg/engine/destroy.go +++ b/pkg/engine/destroy.go @@ -23,24 +23,22 @@ func Destroy(u UpdateInfo, events chan<- Event, opts UpdateOptions) (ResourceCha emitter := makeEventEmitter(events, u) return update(ctx, planOptions{ UpdateOptions: opts, - SourceFunc: newDestroySourceFunc(), + SourceFunc: newDestroySource, Events: emitter, Diag: newEventSink(emitter), }) } -func newDestroySourceFunc() planSourceFunc { - return func(opts planOptions, proj *workspace.Project, pwd, main string, - target *deploy.Target, plugctx *plugin.Context) (deploy.Source, error) { - // For destroy, we consult the manifest for the plugin versions/ required to destroy it. - if target != nil && target.Snapshot != nil { - if err := plugctx.Host.EnsurePlugins(target.Snapshot.Manifest.Plugins); err != nil { - return nil, err - } +func newDestroySource(opts planOptions, proj *workspace.Project, pwd, main string, + target *deploy.Target, plugctx *plugin.Context) (deploy.Source, error) { + // For destroy, we consult the manifest for the plugin versions/ required to destroy it. + if target != nil && target.Snapshot != nil { + if err := plugctx.Host.EnsurePlugins(target.Snapshot.Manifest.Plugins); err != nil { + return nil, err } - - // Create a nil source. This simply returns "nothing" as the new state, which will cause the - // engine to destroy the entire existing state. - return deploy.NullSource, nil } + + // Create a nil source. This simply returns "nothing" as the new state, which will cause the + // engine to destroy the entire existing state. + return deploy.NullSource, nil } diff --git a/pkg/engine/preview.go b/pkg/engine/preview.go index 539862612..bb873e554 100644 --- a/pkg/engine/preview.go +++ b/pkg/engine/preview.go @@ -29,7 +29,7 @@ func Preview(u UpdateInfo, events chan<- Event, opts UpdateOptions) error { emitter := makeEventEmitter(events, u) return preview(ctx, planOptions{ UpdateOptions: opts, - SourceFunc: newUpdateSourceFunc(), + SourceFunc: newUpdateSource, Events: emitter, Diag: newEventSink(emitter), }) diff --git a/pkg/engine/update.go b/pkg/engine/update.go index 3af787f90..7f9042d38 100644 --- a/pkg/engine/update.go +++ b/pkg/engine/update.go @@ -41,39 +41,37 @@ func Update(u UpdateInfo, events chan<- Event, opts UpdateOptions) (ResourceChan emitter := makeEventEmitter(events, u) return update(ctx, planOptions{ UpdateOptions: opts, - SourceFunc: newUpdateSourceFunc(), + SourceFunc: newUpdateSource, Events: emitter, Diag: newEventSink(emitter), }) } -func newUpdateSourceFunc() planSourceFunc { - return func(opts planOptions, proj *workspace.Project, pwd, main string, - target *deploy.Target, plugctx *plugin.Context) (deploy.Source, error) { - // Figure out which plugins to load by inspecting the program contents. - plugins, err := plugctx.Host.GetRequiredPlugins(plugin.ProgInfo{ - Proj: proj, - Pwd: pwd, - Program: main, - }) - if err != nil { - return nil, err - } - - // Now ensure that we have loaded up any plugins that the program will need in advance. - if err = plugctx.Host.EnsurePlugins(plugins); err != nil { - return nil, err - } - - // If that succeeded, create a new source that will perform interpretation of the compiled program. - // TODO[pulumi/pulumi#88]: we are passing `nil` as the arguments map; we need to allow a way to pass these. - return deploy.NewEvalSource(plugctx, &deploy.EvalRunInfo{ - Proj: proj, - Pwd: pwd, - Program: main, - Target: target, - }, opts.DryRun), nil +func newUpdateSource(opts planOptions, proj *workspace.Project, pwd, main string, + target *deploy.Target, plugctx *plugin.Context) (deploy.Source, error) { + // Figure out which plugins to load by inspecting the program contents. + plugins, err := plugctx.Host.GetRequiredPlugins(plugin.ProgInfo{ + Proj: proj, + Pwd: pwd, + Program: main, + }) + if err != nil { + return nil, err } + + // Now ensure that we have loaded up any plugins that the program will need in advance. + if err = plugctx.Host.EnsurePlugins(plugins); err != nil { + return nil, err + } + + // If that succeeded, create a new source that will perform interpretation of the compiled program. + // TODO[pulumi/pulumi#88]: we are passing `nil` as the arguments map; we need to allow a way to pass these. + return deploy.NewEvalSource(plugctx, &deploy.EvalRunInfo{ + Proj: proj, + Pwd: pwd, + Program: main, + Target: target, + }, opts.DryRun), nil } func update(info *planContext, opts planOptions) (ResourceChanges, error) {