mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 08:51:02 -06:00
command/apply: ask for user variables before validation [GH-736]
This commit is contained in:
parent
63344a37c6
commit
fb3f10efb0
@ -19,6 +19,7 @@ BUG FIXES:
|
||||
* core: JSON TF configurations can configure provisioners. [GH-807]
|
||||
* command/apply: Won't try to initialize modules in some cases when
|
||||
no arguments are given. [GH-780]
|
||||
* command/apply: Fix regression where user variables weren't asked [GH-736]
|
||||
* provider/aws: ELB subnet change doesn't force new resource. [GH-804]
|
||||
|
||||
PLUGIN CHANGES:
|
||||
|
@ -120,15 +120,15 @@ func (c *ApplyCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
if !validateContext(ctx, c.Ui) {
|
||||
return 1
|
||||
}
|
||||
if !planned {
|
||||
if err := ctx.Input(c.InputMode()); err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error configuring: %s", err))
|
||||
return 1
|
||||
}
|
||||
}
|
||||
if !validateContext(ctx, c.Ui) {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Plan if we haven't already
|
||||
if !planned {
|
||||
|
@ -268,6 +268,39 @@ func TestApply_init(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestApply_input(t *testing.T) {
|
||||
// Disable test mode so input would be asked
|
||||
test = false
|
||||
defer func() { test = true }()
|
||||
|
||||
// Set some default reader/writers for the inputs
|
||||
defaultInputReader = bytes.NewBufferString("foo\n")
|
||||
defaultInputWriter = new(bytes.Buffer)
|
||||
|
||||
statePath := testTempFile(t)
|
||||
|
||||
p := testProvider()
|
||||
ui := new(cli.MockUi)
|
||||
c := &ApplyCommand{
|
||||
Meta: Meta{
|
||||
ContextOpts: testCtxConfig(p),
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
||||
args := []string{
|
||||
"-state", statePath,
|
||||
testFixturePath("apply-input"),
|
||||
}
|
||||
if code := c.Run(args); code != 0 {
|
||||
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
|
||||
}
|
||||
|
||||
if !p.InputCalled {
|
||||
t.Fatal("input should be called")
|
||||
}
|
||||
}
|
||||
|
||||
func TestApply_noArgs(t *testing.T) {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
|
3
command/test-fixtures/apply-input/main.tf
Normal file
3
command/test-fixtures/apply-input/main.tf
Normal file
@ -0,0 +1,3 @@
|
||||
variable "foo" {}
|
||||
|
||||
resource "test_instance" "foo" {}
|
Loading…
Reference in New Issue
Block a user