8d71771391
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.
48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newUpdateCmd() *cobra.Command {
|
|
var detailed bool
|
|
var dryRun bool
|
|
var output string
|
|
var cmd = &cobra.Command{
|
|
Use: "update [snapshot] [blueprint] [-- [args]]",
|
|
Short: "Update an existing environment and its resources",
|
|
Long: "Update an existing environment and its resources.\n" +
|
|
"\n" +
|
|
"This command updates an existing environment whose state is represented by the\n" +
|
|
"existing snapshot file. The new desired state is computed by compiling and evaluating\n" +
|
|
"a MuPackage blueprint, and extracting all resource allocations from its MuGL graph.\n" +
|
|
"This is then compared against the existing state to determine what operations must take\n" +
|
|
"place to achieve the desired state. This command results in a full snapshot of the\n" +
|
|
"environment's new resource state, so that it may be updated incrementally again later.\n" +
|
|
"\n" +
|
|
"By default, the MuPackage blueprint is loaded from the current directory. Optionally,\n" +
|
|
"a path to a MuPackage elsewhere can be provided as the [blueprint] argument.",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
applyExisting(cmd, args, applyOptions{
|
|
Delete: false,
|
|
Detailed: detailed,
|
|
DryRun: dryRun,
|
|
Output: output,
|
|
})
|
|
},
|
|
}
|
|
|
|
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 update resources; just print out the planned updates")
|
|
cmd.PersistentFlags().StringVarP(
|
|
&output, "output", "o", "",
|
|
"Serialize the resulting snapshot to a specific file, instead of overwriting the existing one")
|
|
|
|
return cmd
|
|
}
|