mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Backport/v1.8/1826 (#1829)
Signed-off-by: James Humphries <james@james-humphries.co.uk> Co-authored-by: James Humphries <james@james-humphries.co.uk>
This commit is contained in:
parent
f668c48ffd
commit
0b2384a3ef
@ -280,7 +280,7 @@ func (b *Local) localRunForPlanFile(op *backend.Operation, pf *planfile.Reader,
|
||||
return variable.Default, nil
|
||||
}
|
||||
|
||||
parsed, parsedErr := v.Decode(variable.Type)
|
||||
parsed, parsedErr := v.Decode(cty.DynamicPseudoType)
|
||||
if parsedErr != nil {
|
||||
diags = diags.Append(&hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
|
@ -6,6 +6,7 @@
|
||||
package e2etest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@ -15,7 +16,13 @@ import (
|
||||
// This is an e2e test as it relies on very specific configuration
|
||||
// within the meta object that is currently very hard to mock out.
|
||||
func TestStaticPlanVariables(t *testing.T) {
|
||||
fixturePath := filepath.Join("testdata", "static_plan_variables")
|
||||
fixtures := []string{
|
||||
"static_plan_variables",
|
||||
"static_plan_typed_variables",
|
||||
}
|
||||
for _, fixture := range fixtures {
|
||||
t.Run(fmt.Sprintf("TestStaticPlanVariables/%s", fixture), func(t *testing.T) {
|
||||
fixturePath := filepath.Join("testdata", fixture)
|
||||
tf := e2e.NewBinary(t, tofuBin, fixturePath)
|
||||
|
||||
run := func(args ...string) tofuResult {
|
||||
@ -132,4 +139,6 @@ func TestStaticPlanVariables(t *testing.T) {
|
||||
// Destroy
|
||||
run("destroy", "-auto-approve").Failure().StderrContains(backendErr)
|
||||
run("destroy", stateVar, modVar, "-auto-approve").Success().Contains("You can apply this plan to save these new output values")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
19
internal/command/e2etest/testdata/static_plan_typed_variables/main.tf
vendored
Normal file
19
internal/command/e2etest/testdata/static_plan_typed_variables/main.tf
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
variable "state_path" {}
|
||||
|
||||
variable "src" {
|
||||
type = string
|
||||
}
|
||||
|
||||
terraform {
|
||||
backend "local" {
|
||||
path = var.state_path
|
||||
}
|
||||
}
|
||||
|
||||
module "mod" {
|
||||
source = var.src
|
||||
}
|
||||
|
||||
output "out" {
|
||||
value = module.mod.out
|
||||
}
|
3
internal/command/e2etest/testdata/static_plan_typed_variables/mod/mod.tf
vendored
Normal file
3
internal/command/e2etest/testdata/static_plan_typed_variables/mod/mod.tf
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
output "out" {
|
||||
value = "placeholder"
|
||||
}
|
@ -13,6 +13,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/hcl/v2"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
|
||||
"github.com/opentofu/opentofu/internal/backend"
|
||||
"github.com/opentofu/opentofu/internal/cloud"
|
||||
"github.com/opentofu/opentofu/internal/cloud/cloudplan"
|
||||
@ -27,7 +29,6 @@ import (
|
||||
"github.com/opentofu/opentofu/internal/tfdiags"
|
||||
"github.com/opentofu/opentofu/internal/tofu"
|
||||
"github.com/opentofu/opentofu/internal/tofumigrate"
|
||||
"github.com/zclconf/go-cty/cty"
|
||||
)
|
||||
|
||||
// Many of the methods we get data from can emit special error types if they're
|
||||
@ -382,7 +383,7 @@ func getDataFromPlanfileReader(planReader *planfile.Reader, rootCall configs.Sta
|
||||
return variable.Default, nil
|
||||
}
|
||||
|
||||
parsed, parsedErr := v.Decode(variable.Type)
|
||||
parsed, parsedErr := v.Decode(cty.DynamicPseudoType)
|
||||
if parsedErr != nil {
|
||||
diags = diags.Append(&hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
|
Loading…
Reference in New Issue
Block a user