This change repivots the plan/apply commands slightly. This is largely in preparation for performing deletes and updates of existing environments. The old way was slightly confusing and made things appear more "magical" than they actually are. Namely, different things are needed for different kinds of deployment operations, and trying to present them each underneath a single pair of CLI commands just leads to weird modality and options. The new way is to offer three commands: create, update, and delete. Each does what it says on the tin: create provisions a new environment, update makes resource updates to an existing one, and delete tears down an existing one entirely. The arguments are what make this interesting: create demands a MuPackage to evaluate (producing the new desired state snapshot), update takes *both* an existing snapshot file plus a MuPackage to evaluate (producing the new desired state snapshot to diff against the existing one), and delete merely takes an existing snapshot file and no MuPackage, since all it must do is tear down an existing known environment. Replacing the plan functionality is the --dry-run (-n) flag that may be passed to any of the above commands. This will print out the plan without actually performing any opterations. All commands produce serializable resource files in the MuGL file format, and attempt to do smart things with respect to backups, etc., to support the intended "Git-oriented" workflow of the pure CLI dev experience.
36 lines
1,014 B
Go
36 lines
1,014 B
Go
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newDeleteCmd() *cobra.Command {
|
|
var detailed bool
|
|
var dryRun bool
|
|
var cmd = &cobra.Command{
|
|
Use: "delete [snapshot]",
|
|
Short: "Delete an existing environment and its resources",
|
|
Long: "Delete an existing environment and its resources.\n" +
|
|
"\n" +
|
|
"This command deletes an entire existing environment whose state is represented by the\n" +
|
|
"existing snapshot file. After running to completion, this environment will be gone.",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
applyExisting(cmd, args, applyOptions{
|
|
Delete: true,
|
|
Detailed: detailed,
|
|
DryRun: dryRun,
|
|
})
|
|
},
|
|
}
|
|
|
|
cmd.PersistentFlags().BoolVar(
|
|
&detailed, "detailed", false,
|
|
"Display detailed output during the application of changes")
|
|
cmd.PersistentFlags().BoolVarP(
|
|
&dryRun, "dry-run", "n", false,
|
|
"Don't actually delete resources; just print out the planned deletions")
|
|
|
|
return cmd
|
|
}
|