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-12-18 20:42:32 +01:00
|
|
|
"github.com/pulumi/pulumi/pkg/diag/colors"
|
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
|
|
|
DryRun bool
|
|
|
|
Parallel int
|
|
|
|
Summary bool
|
2017-12-18 20:42:32 +01:00
|
|
|
Color colors.Colorization
|
2017-08-24 01:50:20 +02:00
|
|
|
}
|
|
|
|
|
2018-01-08 23:20:51 +01:00
|
|
|
func Destroy(update Update, events chan<- Event, opts DestroyOptions) error {
|
2018-01-08 22:01:40 +01:00
|
|
|
contract.Require(update != nil, "update")
|
2017-10-03 01:37:12 +02:00
|
|
|
|
2017-10-23 00:52:00 +02:00
|
|
|
defer func() { events <- cancelEvent() }()
|
|
|
|
|
2018-01-08 23:20:51 +01:00
|
|
|
info, err := planContextFromUpdate(update)
|
2017-08-23 01:56:15 +02:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-11-09 02:08:51 +01:00
|
|
|
defer info.Close()
|
2017-08-23 01:56:15 +02:00
|
|
|
|
2018-01-08 23:20:51 +01:00
|
|
|
return deployLatest(info, deployOptions{
|
2017-09-17 17:10:46 +02:00
|
|
|
Destroy: true,
|
|
|
|
DryRun: opts.DryRun,
|
|
|
|
Parallel: opts.Parallel,
|
|
|
|
Summary: opts.Summary,
|
2017-12-14 20:53:02 +01:00
|
|
|
Color: opts.Color,
|
2017-10-05 23:08:46 +02:00
|
|
|
Events: events,
|
2017-10-23 00:22:15 +02:00
|
|
|
Diag: newEventSink(events, diag.FormatOptions{
|
2017-12-14 20:53:02 +01:00
|
|
|
Color: opts.Color,
|
2017-10-23 00:22:15 +02:00
|
|
|
}),
|
2017-08-23 01:56:15 +02:00
|
|
|
})
|
|
|
|
}
|