Clean up Destroy API boundary

This commit is contained in:
Matt Ellis 2017-08-23 16:50:20 -07:00
parent 73d64dc686
commit b7388fa99a
2 changed files with 20 additions and 6 deletions

View file

@ -3,6 +3,7 @@
package main
import (
"github.com/pulumi/pulumi-fabric/pkg/engine"
"github.com/spf13/cobra"
"github.com/pulumi/pulumi-fabric/pkg/util/cmdutil"
@ -33,7 +34,12 @@ func newDestroyCmd() *cobra.Command {
if dryRun || yes ||
confirmPrompt("This will permanently destroy all resources in the '%v' environment!", env) {
return lumiEngine.Destroy(env, pkgargFromArgs(args), dryRun, debug, summary)
return lumiEngine.Destroy(engine.DestroyOptions{
Environment: env,
Package: pkgargFromArgs(args),
DryRun: dryRun,
Debug: debug,
Summary: summary})
}
return nil

View file

@ -2,16 +2,24 @@ package engine
import "github.com/pulumi/pulumi-fabric/pkg/tokens"
func (eng *Engine) Destroy(envName string, pkgarg string, dryRun bool, debug bool, summary bool) error {
info, err := eng.initEnvCmdName(tokens.QName(envName), pkgarg)
type DestroyOptions struct {
Environment string
Package string
DryRun bool
Debug bool
Summary bool
}
func (eng *Engine) Destroy(opts DestroyOptions) error {
info, err := eng.initEnvCmdName(tokens.QName(opts.Environment), opts.Package)
if err != nil {
return err
}
return eng.deployLatest(info, deployOptions{
Debug: debug,
Debug: opts.Debug,
Destroy: true,
DryRun: dryRun,
Summary: summary,
DryRun: opts.DryRun,
Summary: opts.Summary,
})
}