Eliminate needless level of closure indirection (#1085)
This was CR feedback from @swgillespie.
This commit is contained in:
parent
91c550f1e0
commit
be26db3ffa
3 changed files with 37 additions and 41 deletions
|
@ -23,14 +23,13 @@ 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,
|
||||
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 {
|
||||
|
@ -43,4 +42,3 @@ func newDestroySourceFunc() planSourceFunc {
|
|||
// engine to destroy the entire existing state.
|
||||
return deploy.NullSource, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
})
|
||||
|
|
|
@ -41,14 +41,13 @@ 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,
|
||||
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{
|
||||
|
@ -74,7 +73,6 @@ func newUpdateSourceFunc() planSourceFunc {
|
|||
Target: target,
|
||||
}, opts.DryRun), nil
|
||||
}
|
||||
}
|
||||
|
||||
func update(info *planContext, opts planOptions) (ResourceChanges, error) {
|
||||
result, err := plan(info, opts)
|
||||
|
|
Loading…
Reference in a new issue