pulumi/pkg/engine/destroy.go
CyrusNajmabadi e4946a6620
Allow users to control if and how output is colorized. (#718)
Part of the work to make it easier to tests of diff output.  Specifically, we now allow users to pass --color=option for several pulumi commands.  'option' can be one of 'always', 'never', 'raw', and 'auto' (the default).  

The meaning of these flags are:

1. auto: colorize normally, unless in --debug 
2. always: always colorize no matter what
3. never: never colorize no matter what.
4. raw: colorize, but preserve the original "<{%%}>" style control codes and not the translated platform specific codes.   This is for testing purposes and ensures we can have test for this stuff across platform.
2017-12-14 11:53:02 -08:00

42 lines
906 B
Go

// Copyright 2017, Pulumi Corporation. All rights reserved.
package engine
import (
"github.com/pulumi/pulumi/pkg/diag"
"github.com/pulumi/pulumi/pkg/tokens"
"github.com/pulumi/pulumi/pkg/util/contract"
)
type DestroyOptions struct {
Package string
DryRun bool
Parallel int
Summary bool
Color diag.Color
}
func (eng *Engine) Destroy(stack tokens.QName, events chan<- Event, opts DestroyOptions) error {
contract.Require(stack != tokens.QName(""), "stack")
defer func() { events <- cancelEvent() }()
info, err := eng.planContextFromStack(stack, opts.Package)
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,
}),
})
}