2017-03-15 23:40:06 +01:00
|
|
|
// Copyright 2017 Pulumi, Inc. All rights reserved.
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
Make major commands more pleasant
This change eliminates the need to constantly type in the environment
name when performing major commands like configuration, planning, and
deployment. It's probably due to my age, however, I keep fat-fingering
simple commands in front of investors and I am embarrassed!
In the new model, there is a notion of a "current environment", and
I have modeled it kinda sorta just like Git's notion of "current branch."
By default, the current environment is set when you `init` something.
Otherwise, there is the `coco env select <env>` command to change it.
(Running this command w/out a new <env> will show you the current one.)
The major commands `config`, `plan`, `deploy`, and `destroy` will prefer
to use the current environment, unless it is overridden by using the
--env flag. All of the `coco env <cmd> <env>` commands still require the
explicit passing of an environment which seems reasonable since they are,
after all, about manipulating environments.
As part of this, I've overhauled the aging workspace settings cruft,
which had fallen into disrepair since the initial prototype.
2017-03-22 03:23:32 +01:00
|
|
|
|
|
|
|
"github.com/pulumi/coconut/pkg/tokens"
|
2017-03-15 23:40:06 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func newPlanCmd() *cobra.Command {
|
|
|
|
var analyzers []string
|
2017-03-23 16:10:33 +01:00
|
|
|
var dotOutput bool
|
Make major commands more pleasant
This change eliminates the need to constantly type in the environment
name when performing major commands like configuration, planning, and
deployment. It's probably due to my age, however, I keep fat-fingering
simple commands in front of investors and I am embarrassed!
In the new model, there is a notion of a "current environment", and
I have modeled it kinda sorta just like Git's notion of "current branch."
By default, the current environment is set when you `init` something.
Otherwise, there is the `coco env select <env>` command to change it.
(Running this command w/out a new <env> will show you the current one.)
The major commands `config`, `plan`, `deploy`, and `destroy` will prefer
to use the current environment, unless it is overridden by using the
--env flag. All of the `coco env <cmd> <env>` commands still require the
explicit passing of an environment which seems reasonable since they are,
after all, about manipulating environments.
As part of this, I've overhauled the aging workspace settings cruft,
which had fallen into disrepair since the initial prototype.
2017-03-22 03:23:32 +01:00
|
|
|
var env string
|
2017-03-15 23:40:06 +01:00
|
|
|
var showConfig bool
|
|
|
|
var showReplaceSteps bool
|
|
|
|
var showUnchanged bool
|
|
|
|
var summary bool
|
|
|
|
var output string
|
|
|
|
var cmd = &cobra.Command{
|
Make major commands more pleasant
This change eliminates the need to constantly type in the environment
name when performing major commands like configuration, planning, and
deployment. It's probably due to my age, however, I keep fat-fingering
simple commands in front of investors and I am embarrassed!
In the new model, there is a notion of a "current environment", and
I have modeled it kinda sorta just like Git's notion of "current branch."
By default, the current environment is set when you `init` something.
Otherwise, there is the `coco env select <env>` command to change it.
(Running this command w/out a new <env> will show you the current one.)
The major commands `config`, `plan`, `deploy`, and `destroy` will prefer
to use the current environment, unless it is overridden by using the
--env flag. All of the `coco env <cmd> <env>` commands still require the
explicit passing of an environment which seems reasonable since they are,
after all, about manipulating environments.
As part of this, I've overhauled the aging workspace settings cruft,
which had fallen into disrepair since the initial prototype.
2017-03-22 03:23:32 +01:00
|
|
|
Use: "plan [<package>] [-- [<args>]]",
|
2017-03-15 23:40:06 +01:00
|
|
|
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 {
|
Make major commands more pleasant
This change eliminates the need to constantly type in the environment
name when performing major commands like configuration, planning, and
deployment. It's probably due to my age, however, I keep fat-fingering
simple commands in front of investors and I am embarrassed!
In the new model, there is a notion of a "current environment", and
I have modeled it kinda sorta just like Git's notion of "current branch."
By default, the current environment is set when you `init` something.
Otherwise, there is the `coco env select <env>` command to change it.
(Running this command w/out a new <env> will show you the current one.)
The major commands `config`, `plan`, `deploy`, and `destroy` will prefer
to use the current environment, unless it is overridden by using the
--env flag. All of the `coco env <cmd> <env>` commands still require the
explicit passing of an environment which seems reasonable since they are,
after all, about manipulating environments.
As part of this, I've overhauled the aging workspace settings cruft,
which had fallen into disrepair since the initial prototype.
2017-03-22 03:23:32 +01:00
|
|
|
info, err := initEnvCmdName(tokens.QName(env), args)
|
2017-03-15 23:40:06 +01:00
|
|
|
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,
|
2017-03-23 16:10:33 +01:00
|
|
|
DOT: dotOutput,
|
2017-03-15 23:40:06 +01:00
|
|
|
Output: output,
|
|
|
|
})
|
|
|
|
return nil
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.PersistentFlags().StringSliceVar(
|
|
|
|
&analyzers, "analyzer", []string{},
|
|
|
|
"Run one or more analyzers as part of this deployment")
|
2017-03-23 16:10:33 +01:00
|
|
|
cmd.PersistentFlags().BoolVar(
|
|
|
|
&dotOutput, "dot", false,
|
|
|
|
"Output the plan as a DOT digraph (graph description language)")
|
Make major commands more pleasant
This change eliminates the need to constantly type in the environment
name when performing major commands like configuration, planning, and
deployment. It's probably due to my age, however, I keep fat-fingering
simple commands in front of investors and I am embarrassed!
In the new model, there is a notion of a "current environment", and
I have modeled it kinda sorta just like Git's notion of "current branch."
By default, the current environment is set when you `init` something.
Otherwise, there is the `coco env select <env>` command to change it.
(Running this command w/out a new <env> will show you the current one.)
The major commands `config`, `plan`, `deploy`, and `destroy` will prefer
to use the current environment, unless it is overridden by using the
--env flag. All of the `coco env <cmd> <env>` commands still require the
explicit passing of an environment which seems reasonable since they are,
after all, about manipulating environments.
As part of this, I've overhauled the aging workspace settings cruft,
which had fallen into disrepair since the initial prototype.
2017-03-22 03:23:32 +01:00
|
|
|
cmd.PersistentFlags().StringVarP(
|
|
|
|
&env, "env", "e", "",
|
|
|
|
"Choose an environment other than the currently selected one")
|
2017-03-15 23:40:06 +01:00
|
|
|
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
|
|
|
|
}
|