Add PULUMI_SKIP_CONFIRMATIONS env var (#4477)
This commit is contained in:
parent
8a38ce2cb2
commit
71910a1c52
|
@ -23,6 +23,10 @@ CHANGELOG
|
|||
- Allow secrets to be decrypted when exporting a stack
|
||||
[#4046](https://github.com/pulumi/pulumi/pull/4046)
|
||||
|
||||
- Commands checking for a confirmation or requiring a `--yes` flag can now be
|
||||
skipped by setting `PULUMI_SKIP_CONFIRMATIONS` to `1` or `true`.
|
||||
[#4477](https://github.com/pulumi/pulumi/pull/4477)
|
||||
|
||||
## 2.1.1 (2020-05-11)
|
||||
|
||||
- Add retry support when writing to state buckets
|
||||
|
|
|
@ -62,6 +62,7 @@ func newDestroyCmd() *cobra.Command {
|
|||
"Warning: this command is generally irreversible and should be used with great care.",
|
||||
Args: cmdutil.NoArgs,
|
||||
Run: cmdutil.RunResultFunc(func(cmd *cobra.Command, args []string) result.Result {
|
||||
yes = yes || skipConfirmations()
|
||||
interactive := cmdutil.Interactive()
|
||||
if !interactive && !yes {
|
||||
return result.FromError(errors.New("--yes must be passed in to proceed when running in non-interactive mode"))
|
||||
|
|
|
@ -352,6 +352,7 @@ func newNewCmd() *cobra.Command {
|
|||
if len(cliArgs) > 0 {
|
||||
args.templateNameOrURL = cliArgs[0]
|
||||
}
|
||||
args.yes = args.yes || skipConfirmations()
|
||||
return runNew(args)
|
||||
}),
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ func newPluginRmCmd() *cobra.Command {
|
|||
"in order to execute a Pulumi program, it must be re-downloaded and installed\n" +
|
||||
"using the plugin install command.",
|
||||
Run: cmdutil.RunFunc(func(cmd *cobra.Command, args []string) error {
|
||||
yes = yes || skipConfirmations()
|
||||
opts := display.Options{
|
||||
Color: cmdutil.GetGlobalColorization(),
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ func newRefreshCmd() *cobra.Command {
|
|||
"`--cwd` flag to use a different directory.",
|
||||
Args: cmdutil.NoArgs,
|
||||
Run: cmdutil.RunResultFunc(func(cmd *cobra.Command, args []string) result.Result {
|
||||
yes = yes || skipConfirmations()
|
||||
interactive := cmdutil.Interactive()
|
||||
if !interactive && !yes {
|
||||
return result.FromError(errors.New("--yes must be passed in to proceed when running in non-interactive mode"))
|
||||
|
|
|
@ -46,6 +46,7 @@ func newStackRmCmd() *cobra.Command {
|
|||
"\n" +
|
||||
"After this command completes, the stack will no longer be available for updates.",
|
||||
Run: cmdutil.RunResultFunc(func(cmd *cobra.Command, args []string) result.Result {
|
||||
yes = yes || skipConfirmations()
|
||||
// Use the stack provided or, if missing, default to the current one.
|
||||
if len(args) > 0 {
|
||||
if stack != "" {
|
||||
|
|
|
@ -50,6 +50,7 @@ pulumi state delete 'urn:pulumi:stage::demo::eks:index:Cluster$pulumi:providers:
|
|||
`,
|
||||
Args: cmdutil.ExactArgs(1),
|
||||
Run: cmdutil.RunResultFunc(func(cmd *cobra.Command, args []string) result.Result {
|
||||
yes = yes || skipConfirmations()
|
||||
urn := resource.URN(args[0])
|
||||
// Show the confirmation prompt if the user didn't pass the --yes parameter to skip it.
|
||||
showPrompt := !yes
|
||||
|
|
|
@ -41,6 +41,7 @@ func newStateUnprotectCommand() *cobra.Command {
|
|||
This command clears the 'protect' bit on one or more resources, allowing those resources to be deleted.`,
|
||||
Args: cmdutil.MaximumNArgs(1),
|
||||
Run: cmdutil.RunResultFunc(func(cmd *cobra.Command, args []string) result.Result {
|
||||
yes = yes || skipConfirmations()
|
||||
// Show the confirmation prompt if the user didn't pass the --yes parameter to skip it.
|
||||
showPrompt := !yes
|
||||
|
||||
|
|
|
@ -331,6 +331,8 @@ func newUpCmd() *cobra.Command {
|
|||
"`--cwd` flag to use a different directory.",
|
||||
Args: cmdutil.MaximumNArgs(1),
|
||||
Run: cmdutil.RunResultFunc(func(cmd *cobra.Command, args []string) result.Result {
|
||||
yes = yes || skipConfirmations()
|
||||
|
||||
interactive := cmdutil.Interactive()
|
||||
if !interactive && !yes {
|
||||
return result.FromError(errors.New("--yes must be passed in to proceed when running in non-interactive mode"))
|
||||
|
|
|
@ -66,6 +66,16 @@ func useLegacyDiff() bool {
|
|||
return cmdutil.IsTruthy(os.Getenv("PULUMI_ENABLE_LEGACY_DIFF"))
|
||||
}
|
||||
|
||||
// skipConfirmations returns whether or not confirmation prompts should
|
||||
// be skipped. This should be used by pass any requirement that a --yes
|
||||
// parameter has been set for non-interactive scenarios.
|
||||
//
|
||||
// This should NOT be used to bypass protections for destructive
|
||||
// operations, such as those that will fail without a --force parameter.
|
||||
func skipConfirmations() bool {
|
||||
return cmdutil.IsTruthy(os.Getenv("PULUMI_SKIP_CONFIRMATIONS"))
|
||||
}
|
||||
|
||||
// backendInstance is used to inject a backend mock from tests.
|
||||
var backendInstance backend.Backend
|
||||
|
||||
|
|
Loading…
Reference in a new issue