2017-06-26 23:46:34 +02:00
|
|
|
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
2017-03-06 15:32:39 +01:00
|
|
|
|
2017-09-22 04:18:21 +02:00
|
|
|
package cmd
|
2017-03-06 15:32:39 +01:00
|
|
|
|
|
|
|
import (
|
2017-04-19 23:46:50 +02:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/spf13/cobra"
|
2017-03-07 14:47:42 +01:00
|
|
|
|
2017-09-22 04:18:21 +02:00
|
|
|
"github.com/pulumi/pulumi/pkg/util/cmdutil"
|
2017-03-06 15:32:39 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func newEnvRmCmd() *cobra.Command {
|
|
|
|
var yes bool
|
|
|
|
var force bool
|
|
|
|
var cmd = &cobra.Command{
|
|
|
|
Use: "rm <env>",
|
|
|
|
Short: "Remove an environment and its configuration",
|
|
|
|
Long: "Remove an environment and its configuration\n" +
|
|
|
|
"\n" +
|
|
|
|
"This command removes an environment and its configuration state. Please refer to the\n" +
|
|
|
|
"`destroy` command for removing a resources, as this is a distinct operation.\n" +
|
|
|
|
"\n" +
|
|
|
|
"After this command completes, the environment will no longer be available for deployments.",
|
2017-04-12 20:12:25 +02:00
|
|
|
Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error {
|
2017-08-22 19:07:25 +02:00
|
|
|
|
|
|
|
if len(args) == 0 || args[0] == "" {
|
|
|
|
return errors.Errorf("missing required environment name")
|
|
|
|
}
|
|
|
|
|
2017-08-23 01:23:50 +02:00
|
|
|
envName := args[0]
|
2017-03-07 14:47:42 +01:00
|
|
|
|
|
|
|
// Ensure the user really wants to do this.
|
2017-03-06 15:32:39 +01:00
|
|
|
if yes ||
|
2017-08-23 01:23:50 +02:00
|
|
|
confirmPrompt("This will permanently remove the '%v' environment!", envName) {
|
2017-08-23 19:58:35 +02:00
|
|
|
return lumiEngine.RemoveEnv(envName, force)
|
2017-03-06 15:32:39 +01:00
|
|
|
}
|
2017-03-07 14:47:42 +01:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}),
|
2017-03-06 15:32:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd.PersistentFlags().BoolVarP(
|
|
|
|
&force, "force", "f", false,
|
|
|
|
"By default, removal of a environment with resources will be rejected; this forces it")
|
|
|
|
cmd.PersistentFlags().BoolVar(
|
|
|
|
&yes, "yes", false,
|
|
|
|
"Skip confirmation prompts, and proceed with removal anyway")
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|