2017-08-30 03:24:12 +02:00
|
|
|
// Copyright 2017, Pulumi Corporation. All rights reserved.
|
|
|
|
|
2017-08-23 01:56:15 +02:00
|
|
|
package engine
|
|
|
|
|
2017-10-02 20:14:27 +02:00
|
|
|
import (
|
2017-10-05 23:08:46 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/diag"
|
2017-10-02 20:14:27 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/tokens"
|
2017-10-03 01:37:12 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/util/contract"
|
2017-10-02 20:14:27 +02:00
|
|
|
)
|
2017-08-23 01:56:15 +02:00
|
|
|
|
2017-08-24 01:50:20 +02:00
|
|
|
type DestroyOptions struct {
|
2017-10-02 20:14:27 +02:00
|
|
|
Package string
|
|
|
|
DryRun bool
|
|
|
|
Parallel int
|
|
|
|
Summary bool
|
2017-08-24 01:50:20 +02:00
|
|
|
}
|
|
|
|
|
2017-10-16 21:04:35 +02:00
|
|
|
func (eng *Engine) Destroy(stack tokens.QName, events chan<- Event, opts DestroyOptions) error {
|
|
|
|
contract.Require(stack != tokens.QName(""), "stack")
|
2017-10-03 01:37:12 +02:00
|
|
|
|
2017-10-16 21:04:35 +02:00
|
|
|
info, err := eng.planContextFromStack(stack, opts.Package)
|
2017-08-23 01:56:15 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-08-23 19:58:35 +02:00
|
|
|
return eng.deployLatest(info, deployOptions{
|
2017-09-17 17:10:46 +02:00
|
|
|
Destroy: true,
|
|
|
|
DryRun: opts.DryRun,
|
|
|
|
Parallel: opts.Parallel,
|
|
|
|
Summary: opts.Summary,
|
2017-10-05 23:08:46 +02:00
|
|
|
Events: events,
|
2017-10-23 00:22:15 +02:00
|
|
|
Diag: newEventSink(events, diag.FormatOptions{
|
|
|
|
Colors: true,
|
|
|
|
}),
|
2017-08-23 01:56:15 +02:00
|
|
|
})
|
|
|
|
}
|