// Copyright 2017 Pulumi, Inc. All rights reserved. package cmd import ( "github.com/spf13/cobra" ) func newPlanCmd() *cobra.Command { var analyzers []string var showConfig bool var showReplaceSteps bool var showUnchanged bool var summary bool var output string var cmd = &cobra.Command{ Use: "plan [] [-- []]", 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: runFunc(func(cmd *cobra.Command, args []string) error { info, err := initEnvCmd(cmd, 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, Output: output, }) return nil }), } cmd.PersistentFlags().StringSliceVar( &analyzers, "analyzer", []string{}, "Run one or more analyzers as part of this deployment") 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 }