Remove deploy.PlanSummary. (#1809)

Nothing actually uses this information.
This commit is contained in:
Pat Gavlin 2018-08-21 19:33:59 -07:00 committed by GitHub
parent 4dab630a1b
commit 91e20289a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 49 deletions

View file

@ -192,18 +192,17 @@ func (res *planResult) Chdir() (func(), error) {
// Walk enumerates all steps in the plan, calling out to the provided action at each step. It returns four things: the
// resulting Snapshot, no matter whether an error occurs or not; an error, if something went wrong; the step that
// failed, if the error is non-nil; and finally the state of the resource modified in the failing step.
func (res *planResult) Walk(cancelCtx *Context, events deploy.Events, preview bool) (deploy.PlanSummary, error) {
func (res *planResult) Walk(cancelCtx *Context, events deploy.Events, preview bool) error {
ctx, cancelFunc := context.WithCancel(context.Background())
done := make(chan bool)
var summary deploy.PlanSummary
var err error
go func() {
opts := deploy.Options{
Events: events,
Parallel: res.Options.Parallel,
}
summary, err = res.Plan.Execute(ctx, opts, preview)
err = res.Plan.Execute(ctx, opts, preview)
close(done)
}()
@ -220,10 +219,10 @@ func (res *planResult) Walk(cancelCtx *Context, events deploy.Events, preview bo
select {
case <-cancelCtx.Cancel.Terminated():
return summary, cancelCtx.Cancel.TerminateErr()
return cancelCtx.Cancel.TerminateErr()
case <-done:
return summary, err
return err
}
}
@ -237,8 +236,7 @@ func printPlan(ctx *Context, result *planResult, dryRun bool) (ResourceChanges,
// Walk the plan's steps and and pretty-print them out.
actions := newPlanActions(result.Options)
_, err := result.Walk(ctx, actions, true)
if err != nil {
if err := result.Walk(ctx, actions, true); err != nil {
return nil, errors.New("an error occurred while advancing the preview")
}

View file

@ -136,18 +136,15 @@ func update(ctx *Context, info *planContext, opts planOptions, dryRun bool) (Res
defer contract.IgnoreClose(result)
// Make the current working directory the same as the program's, and restore it upon exit.
done, err := result.Chdir()
if err != nil {
return nil, err
done, chErr := result.Chdir()
if chErr != nil {
return nil, chErr
}
defer done()
if dryRun {
// If a dry run, just print the plan, don't actually carry out the deployment.
resourceChanges, err = printPlan(ctx, result, dryRun)
if err != nil {
return resourceChanges, err
}
} else {
// Otherwise, we will actually deploy the latest bits.
opts.Events.preludeEvent(dryRun, result.Ctx.Update.GetTarget().Config)
@ -155,24 +152,17 @@ func update(ctx *Context, info *planContext, opts planOptions, dryRun bool) (Res
// Walk the plan, reporting progress and executing the actual operations as we go.
start := time.Now()
actions := newUpdateActions(ctx, info.Update, opts)
summary, err := result.Walk(ctx, actions, false)
if err != nil && summary == nil {
// Something went wrong, and no changes were made.
return resourceChanges, err
}
contract.Assert(summary != nil)
// Print out the total number of steps performed (and their kinds), the duration, and any summary info.
err = result.Walk(ctx, actions, false)
resourceChanges = ResourceChanges(actions.Ops)
opts.Events.updateSummaryEvent(actions.MaybeCorrupt, time.Since(start), resourceChanges)
if err != nil {
return resourceChanges, err
if len(resourceChanges) != 0 {
// Print out the total number of steps performed (and their kinds), the duration, and any summary info.
opts.Events.updateSummaryEvent(actions.MaybeCorrupt, time.Since(start), resourceChanges)
}
}
}
return resourceChanges, nil
return resourceChanges, err
}
// pluginActions listens for plugin events and persists the set of loaded plugins

View file

@ -52,16 +52,6 @@ type Events interface {
OnResourceOutputs(step Step) error
}
// PlanSummary is an interface for summarizing the progress of a plan.
type PlanSummary interface {
Steps() int
Creates() map[resource.URN]bool
Updates() map[resource.URN]bool
Replaces() map[resource.URN]bool
Deletes() map[resource.URN]bool
Sames() map[resource.URN]bool
}
// PlanPendingOperationsError is an error returned from `NewPlan` if there exist pending operations in the
// snapshot that we are preparing to operate upon. The engine does not allow any operations to be pending
// when operating on a snapshot.
@ -278,7 +268,7 @@ func (p *Plan) generateEventURN(event SourceEvent) resource.URN {
// Execute executes a plan to completion, using the given cancellation context and running a preview
// or update.
func (p *Plan) Execute(ctx context.Context, opts Options, preview bool) (PlanSummary, error) {
func (p *Plan) Execute(ctx context.Context, opts Options, preview bool) error {
planExec := &planExecutor{plan: p}
return planExec.Execute(ctx, opts, preview)
}

View file

@ -53,11 +53,11 @@ func (pe *planExecutor) reportError(urn resource.URN, err error) {
// Execute executes a plan to completion, using the given cancellation context and running a preview
// or update.
func (pe *planExecutor) Execute(parentCtx context.Context, opts Options, preview bool) (PlanSummary, error) {
func (pe *planExecutor) Execute(parentCtx context.Context, opts Options, preview bool) error {
// Begin iterating the source.
src, err := pe.plan.source.Iterate(parentCtx, opts, pe.plan)
if err != nil {
return nil, err
return err
}
// Set up a goroutine that will signal cancellation to the plan's plugins if the parent context is cancelled. We do
@ -167,7 +167,7 @@ func (pe *planExecutor) Execute(parentCtx context.Context, opts Options, preview
} else if canceled {
err = execError("canceled", preview)
}
return pe.stepGen, err
return err
}
// handleSingleEvent handles a single source event. For all incoming events, it produces a chain that needs

View file

@ -524,16 +524,6 @@ func (sg *stepGenerator) issueCheckErrors(new *resource.State, urn resource.URN,
return true
}
func (sg *stepGenerator) Steps() int {
return len(sg.Creates()) + len(sg.Updates()) + len(sg.Replaces()) + len(sg.Deletes())
}
func (sg *stepGenerator) Creates() map[resource.URN]bool { return sg.creates }
func (sg *stepGenerator) Sames() map[resource.URN]bool { return sg.sames }
func (sg *stepGenerator) Updates() map[resource.URN]bool { return sg.updates }
func (sg *stepGenerator) Replaces() map[resource.URN]bool { return sg.replaces }
func (sg *stepGenerator) Deletes() map[resource.URN]bool { return sg.deletes }
// newStepGenerator creates a new step generator that operates on the given plan.
func newStepGenerator(plan *Plan, opts Options) *stepGenerator {
return &stepGenerator{