mirror of https://github.com/hashicorp/terraform
For non-interactive contexts, Terraform is typically executed with the flag -input=false. However for runs that are not set to auto approve, the cloud integration will prompt a user for approval input even with input being set to false. This commit enables the cloud integration to know the value of the input flag and use it to determine whether or not to ask the user for input. If -input is set to false and the run cannot be auto approved, the cloud integration will throw an error stating run confirmation can no longer be handled in the CLI and that they must do so through the browser.sebasslash/err-approval-input-false
parent
c557078704
commit
9d7fdbea2d
@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_apply_no_input_flag(t *testing.T) {
|
||||
t.Parallel()
|
||||
skipIfMissingEnvVar(t)
|
||||
|
||||
cases := testCases{
|
||||
"terraform apply with -input=false": {
|
||||
operations: []operationSets{
|
||||
{
|
||||
prep: func(t *testing.T, orgName, dir string) {
|
||||
wsName := "new-workspace"
|
||||
tfBlock := terraformConfigCloudBackendName(orgName, wsName)
|
||||
writeMainTF(t, tfBlock, dir)
|
||||
},
|
||||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-input=false"},
|
||||
expectedCmdOutput: `Terraform Cloud has been successfully initialized`,
|
||||
},
|
||||
{
|
||||
command: []string{"apply", "-input=false"},
|
||||
expectedCmdOutput: `Cannot confirm apply due to -input=false. Please handle run confirmation in the UI.`,
|
||||
expectError: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"terraform apply with auto approve and -input=false": {
|
||||
operations: []operationSets{
|
||||
{
|
||||
prep: func(t *testing.T, orgName, dir string) {
|
||||
wsName := "cloud-workspace"
|
||||
tfBlock := terraformConfigCloudBackendName(orgName, wsName)
|
||||
writeMainTF(t, tfBlock, dir)
|
||||
},
|
||||
commands: []tfCommand{
|
||||
{
|
||||
command: []string{"init", "-input=false"},
|
||||
expectedCmdOutput: `Terraform Cloud has been successfully initialized`,
|
||||
},
|
||||
{
|
||||
command: []string{"apply", "-auto-approve", "-input=false"},
|
||||
expectedCmdOutput: `Apply complete!`,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
testRunner(t, cases, 1)
|
||||
}
|
||||
Loading…
Reference in new issue