pulumi/pkg/engine/destroy.go
pat@pulumi.com c56e716c31 Refactor the engine's entrypoints.
These changes refactor the engine's entrypoints--Deploy, Destroy, and
Preview--to be update-centric rather than stack-centric. Each of these
methods now takes a value of a new type, Update, that abstracts away the
vagaries of fetching and maintaining the update's state. This
refactoring also reinforces Pulumi.yaml as a CLI concept rather than an
engine concept; the CLI is now the only reader/writer of this format.

These changes will smooth the way for a few refactorings on the service
side that will aid in update isolation.
2018-01-08 14:15:16 -08:00

41 lines
875 B
Go

// Copyright 2017, Pulumi Corporation. All rights reserved.
package engine
import (
"github.com/pulumi/pulumi/pkg/diag"
"github.com/pulumi/pulumi/pkg/diag/colors"
"github.com/pulumi/pulumi/pkg/util/contract"
)
type DestroyOptions struct {
DryRun bool
Parallel int
Summary bool
Color colors.Colorization
}
func (eng *Engine) Destroy(update Update, events chan<- Event, opts DestroyOptions) error {
contract.Require(update != nil, "update")
defer func() { events <- cancelEvent() }()
info, err := eng.planContextFromUpdate(update)
if err != nil {
return err
}
defer info.Close()
return eng.deployLatest(info, deployOptions{
Destroy: true,
DryRun: opts.DryRun,
Parallel: opts.Parallel,
Summary: opts.Summary,
Color: opts.Color,
Events: events,
Diag: newEventSink(events, diag.FormatOptions{
Color: opts.Color,
}),
})
}