ae1e43ce5d
This paves the way for more Go-based command line tools that can share some of the common utility functions around diagnostics and exit codes.
82 lines
3 KiB
Go
82 lines
3 KiB
Go
// Copyright 2017 Pulumi, Inc. All rights reserved.
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/pulumi/coconut/pkg/tokens"
|
|
"github.com/pulumi/coconut/pkg/util/cmdutil"
|
|
)
|
|
|
|
func newPlanCmd() *cobra.Command {
|
|
var analyzers []string
|
|
var dotOutput bool
|
|
var env string
|
|
var showConfig bool
|
|
var showReplaceSteps bool
|
|
var showUnchanged bool
|
|
var summary bool
|
|
var output string
|
|
var cmd = &cobra.Command{
|
|
Use: "plan [<package>] [-- [<args>]]",
|
|
Aliases: []string{"dryrun"},
|
|
Short: "Show a plan to update, create, and delete an environment's resources",
|
|
Long: "Show a plan to update, create, and delete an environment's resources\n" +
|
|
"\n" +
|
|
"This command displays a plan to update an existing environment whose state is represented by\n" +
|
|
"an existing snapshot file. The new desired state is computed by compiling and evaluating an\n" +
|
|
"executable package, and extracting all resource allocations from its resulting object graph.\n" +
|
|
"This graph is compared against the existing state to determine what operations must take\n" +
|
|
"place to achieve the desired state. No changes to the environment will actually take place.\n" +
|
|
"\n" +
|
|
"By default, the package to execute is loaded from the current directory. Optionally, an\n" +
|
|
"explicit path can be provided using the [package] argument.",
|
|
Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error {
|
|
info, err := initEnvCmdName(tokens.QName(env), args)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer info.Close()
|
|
apply(cmd, info, applyOptions{
|
|
Delete: false,
|
|
DryRun: true,
|
|
Analyzers: analyzers,
|
|
ShowConfig: showConfig,
|
|
ShowReplaceSteps: showReplaceSteps,
|
|
ShowUnchanged: showUnchanged,
|
|
Summary: summary,
|
|
DOT: dotOutput,
|
|
Output: output,
|
|
})
|
|
return nil
|
|
}),
|
|
}
|
|
|
|
cmd.PersistentFlags().StringSliceVar(
|
|
&analyzers, "analyzer", []string{},
|
|
"Run one or more analyzers as part of this deployment")
|
|
cmd.PersistentFlags().BoolVar(
|
|
&dotOutput, "dot", false,
|
|
"Output the plan as a DOT digraph (graph description language)")
|
|
cmd.PersistentFlags().StringVarP(
|
|
&env, "env", "e", "",
|
|
"Choose an environment other than the currently selected one")
|
|
cmd.PersistentFlags().BoolVar(
|
|
&showConfig, "show-config", false,
|
|
"Show configuration keys and variables")
|
|
cmd.PersistentFlags().BoolVar(
|
|
&showReplaceSteps, "show-replace-steps", false,
|
|
"Show detailed resource replacement creates and deletes; normally shows as a single step")
|
|
cmd.PersistentFlags().BoolVar(
|
|
&showUnchanged, "show-unchanged", false,
|
|
"Show resources that needn't be updated because they haven't changed, alongside those that do")
|
|
cmd.PersistentFlags().BoolVarP(
|
|
&summary, "summary", "s", false,
|
|
"Only display summarization of resources and plan operations")
|
|
cmd.PersistentFlags().StringVarP(
|
|
&output, "output", "o", "",
|
|
"Serialize the resulting plan to a file instead of simply printing it")
|
|
|
|
return cmd
|
|
}
|