5
5
6
6
hcl "github.com/hashicorp/hcl/v2"
7
7
"github.com/terraform-linters/tflint-plugin-sdk/terraform/configs"
8
- "github.com/zclconf/go-cty/cty"
8
+ "github.com/zclconf/go-cty/cty/json "
9
9
"github.com/zclconf/go-cty/cty/msgpack"
10
10
)
11
11
@@ -14,7 +14,7 @@ type Variable struct {
14
14
Name string
15
15
Description string
16
16
Default []byte
17
- Type cty. Type
17
+ Type [] byte
18
18
ParsingMode configs.VariableParsingMode
19
19
Validations []* VariableValidation
20
20
Sensitive bool
@@ -35,14 +35,25 @@ func decodeVariable(variable *Variable) (*configs.Variable, hcl.Diagnostics) {
35
35
ret [i ] = validation
36
36
}
37
37
38
- defaultVal , err := msgpack . Unmarshal ( variable . Default , variable .Type )
38
+ typeVal , err := json . UnmarshalType ( variable .Type )
39
39
if err != nil {
40
40
return nil , hcl.Diagnostics {
41
41
& hcl.Diagnostic {
42
42
Severity : hcl .DiagError ,
43
- Summary : "cannot unmarshal variable default value" ,
44
- Detail : fmt .Sprint (err ),
45
- Subject : & variable .DeclRange ,
43
+ Summary : "cannot unmarshal type for variable" ,
44
+ Detail : fmt .Sprint (err ),
45
+ Subject : & variable .DeclRange ,
46
+ },
47
+ }
48
+ }
49
+ defaultVal , err := msgpack .Unmarshal (variable .Default , typeVal )
50
+ if err != nil {
51
+ return nil , hcl.Diagnostics {
52
+ & hcl.Diagnostic {
53
+ Severity : hcl .DiagError ,
54
+ Summary : "cannot unmarshal variable default value" ,
55
+ Detail : fmt .Sprint (err ),
56
+ Subject : & variable .DeclRange ,
46
57
},
47
58
}
48
59
}
@@ -51,7 +62,7 @@ func decodeVariable(variable *Variable) (*configs.Variable, hcl.Diagnostics) {
51
62
Name : variable .Name ,
52
63
Description : variable .Description ,
53
64
Default : defaultVal ,
54
- Type : variable . Type ,
65
+ Type : typeVal ,
55
66
ParsingMode : variable .ParsingMode ,
56
67
Validations : ret ,
57
68
Sensitive : variable .Sensitive ,
0 commit comments