Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for expressions #19

Merged
merged 1 commit into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/google/go-cmp v0.5.4
github.com/hashicorp/go-multierror v1.1.0
github.com/hashicorp/go-version v1.2.1
github.com/hashicorp/hcl-lang v0.0.0-20210213170001-bd00c3f68680
github.com/hashicorp/hcl-lang v0.0.0-20210225075938-01f0b453dd63
github.com/hashicorp/hcl/v2 v2.9.0
github.com/hashicorp/terraform-config-inspect v0.0.0-20201102131242-0c45ba392e51
github.com/hashicorp/terraform-json v0.8.0
Expand Down
21 changes: 4 additions & 17 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3 h1:ZSTrOEhiM5J5RFxEaFvMZVEAM1KvT1YzbEOwB2EAGjA=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/apparentlymart/go-textseg/v12 v12.0.0 h1:bNEQyAGak9tojivJNkoqWErVCQbjdL7GzRt3F8NvfJ0=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -22,7 +18,6 @@ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand All @@ -31,17 +26,14 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI=
github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA=
github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI=
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f h1:UdxlrJz4JOnY8W+DbLISwf2B8WXEolNRA8BGCwI9jws=
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
github.com/hashicorp/hcl-lang v0.0.0-20210213170001-bd00c3f68680 h1:QjPFluG2uGJCBKIp5sEFx+UZ98QnuxmVsnLIuHz8a2Y=
github.com/hashicorp/hcl-lang v0.0.0-20210213170001-bd00c3f68680/go.mod h1:TZ5tpvmgJSHfmIndN4WP9SpZvyWK8tHPBY8LDRyU+pI=
github.com/hashicorp/hcl-lang v0.0.0-20210225075938-01f0b453dd63 h1:ixUQf+oecfFaMpg6gUNc8LymYKQf+OfmRpxtGL34XtU=
github.com/hashicorp/hcl-lang v0.0.0-20210225075938-01f0b453dd63/go.mod h1:jVqv6gpR2SOPIC6j5HFG/KavqCdfLZED5QitQuV7JTU=
github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
github.com/hashicorp/hcl/v2 v2.6.0 h1:3krZOfGY6SziUXa6H9PJU6TyohHn7I+ARYnhbeNBz+o=
github.com/hashicorp/hcl/v2 v2.6.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY=
github.com/hashicorp/hcl/v2 v2.9.0 h1:7kJiMiKBqGHASbDJuFAMlpRMJLyhuLg/IsU/3EzwniA=
github.com/hashicorp/hcl/v2 v2.9.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
github.com/hashicorp/terraform-config-inspect v0.0.0-20201102131242-0c45ba392e51 h1:SEGO1vz/pFLfKy4QpABIMCe7wffmtsOiWO4yc1E87cU=
Expand All @@ -55,24 +47,21 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5 h1:shw+DWUaHIyW64Tv30ASCbC6QO6fLy+M5SJb5pJVEI4=
github.com/mh-cbon/go-fmt-fail v0.0.0-20160815164508-67765b3fbcb5/go.mod h1:nHPoxaBUc5CDAMIv0MNmn5PBjWbTs9BI/eh30/n0U6g=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
github.com/mitchellh/copystructure v1.1.1/go.mod h1:EBArHfARyrSWO/+Wyr9zwEkc6XMFB9XyNgFNmRkZZU4=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
Expand All @@ -84,7 +73,6 @@ github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgq
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
github.com/zclconf/go-cty v1.6.1/go.mod h1:VDR4+I79ubFBGm1uJac1226K5yANQFHeauxPBoP54+o=
github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA=
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI=
Expand All @@ -106,7 +94,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
18 changes: 12 additions & 6 deletions internal/schema/0.12/data_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@ func datasourceBlockSchema(v *version.Version) *schema.BlockSchema {
Body: &schema.BodySchema{
Attributes: map[string]*schema.AttributeSchema{
"provider": {
ValueType: cty.DynamicPseudoType,
Expr: schema.ExprConstraints{},
IsOptional: true,
Description: lang.Markdown("Reference to a `provider` configuration block, e.g. `mycloud.west` or `mycloud`"),
IsDepKey: true,
},
"count": {
ValueType: cty.Number,
Expr: schema.ExprConstraints{
schema.LiteralTypeExpr{Type: cty.Number},
},
IsOptional: true,
Description: lang.Markdown("Number of instances of this data source, e.g. `3`"),
},
"depends_on": {
ValueType: cty.Set(cty.DynamicPseudoType),
Expr: schema.ExprConstraints{
schema.TupleConsExpr{
Name: "set of references",
},
},
IsOptional: true,
Description: lang.Markdown("Set of references to hidden dependencies, e.g. other resources or data sources"),
},
Expand All @@ -47,9 +53,9 @@ func datasourceBlockSchema(v *version.Version) *schema.BlockSchema {

if v.GreaterThanOrEqual(v0_12_6) {
bs.Body.Attributes["for_each"] = &schema.AttributeSchema{
ValueTypes: schema.ValueTypes{
cty.Set(cty.DynamicPseudoType),
cty.Map(cty.DynamicPseudoType),
Expr: schema.ExprConstraints{
schema.LiteralTypeExpr{Type: cty.Set(cty.DynamicPseudoType)},
schema.LiteralTypeExpr{Type: cty.Map(cty.DynamicPseudoType)},
},
IsOptional: true,
Description: lang.Markdown("A set or a map where each item represents an instance of this data source"),
Expand Down
10 changes: 7 additions & 3 deletions internal/schema/0.12/module_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var moduleBlockSchema = &schema.BlockSchema{
Body: &schema.BodySchema{
Attributes: map[string]*schema.AttributeSchema{
"source": {
ValueType: cty.String,
Expr: schema.LiteralTypeOnly(cty.String),
Description: lang.Markdown("Source where to load the module from, " +
"a local directory (e.g. `./module`) or a remote address - e.g. " +
"`hashicorp/consul/aws` (Terraform Registry address) or " +
Expand All @@ -26,13 +26,17 @@ var moduleBlockSchema = &schema.BlockSchema{
IsDepKey: true,
},
"version": {
ValueType: cty.String,
Expr: schema.LiteralTypeOnly(cty.String),
IsOptional: true,
Description: lang.Markdown("Constraint to set the version of the module, e.g. `~> 1.0`." +
" Only applicable to modules in a module registry."),
},
"providers": {
ValueType: cty.Map(cty.DynamicPseudoType),
Expr: schema.ExprConstraints{
schema.MapExpr{
Name: "map of provider references",
},
},
IsOptional: true,
Description: lang.Markdown("Explicit mapping of providers which the module uses"),
},
Expand Down
12 changes: 8 additions & 4 deletions internal/schema/0.12/output_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,26 @@ var outputBlockSchema = &schema.BlockSchema{
Body: &schema.BodySchema{
Attributes: map[string]*schema.AttributeSchema{
"description": {
ValueType: cty.String,
Expr: schema.LiteralTypeOnly(cty.String),
IsOptional: true,
Description: lang.PlainText("Human-readable description of the output (for documentation and UI)"),
},
"value": {
ValueType: cty.DynamicPseudoType,
Expr: schema.ExprConstraints{},
IsRequired: true,
Description: lang.PlainText("Value, typically a reference to an attribute of a resource or a data source"),
},
"sensitive": {
ValueType: cty.Bool,
Expr: schema.LiteralTypeOnly(cty.Bool),
IsOptional: true,
Description: lang.PlainText("Whether the output contains sensitive material and should be hidden in the UI"),
},
"depends_on": {
ValueType: cty.Set(cty.DynamicPseudoType),
Expr: schema.ExprConstraints{
schema.TupleConsExpr{
Name: "set of references",
},
},
IsOptional: true,
Description: lang.PlainText("Set of references to hidden dependencies (e.g. resources or data sources)"),
},
Expand Down
4 changes: 2 additions & 2 deletions internal/schema/0.12/provider_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ func providerBlockSchema(v *version.Version) *schema.BlockSchema {
Body: &schema.BodySchema{
Attributes: map[string]*schema.AttributeSchema{
"alias": {
ValueType: cty.String,
Expr: schema.LiteralTypeOnly(cty.String),
IsOptional: true,
Description: lang.Markdown("Alias for using the same provider with different configurations for different resources, e.g. `eu-west`"),
},
"version": {
ValueType: cty.String,
Expr: schema.LiteralTypeOnly(cty.String),
IsOptional: true,
Description: lang.Markdown("Specifies a version constraint for the provider, e.g. `~> 1.0`"),
},
Expand Down
57 changes: 45 additions & 12 deletions internal/schema/0.12/resource_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ func resourceBlockSchema(v *version.Version) *schema.BlockSchema {
Body: &schema.BodySchema{
Attributes: map[string]*schema.AttributeSchema{
"provider": {
ValueType: cty.DynamicPseudoType,
Expr: schema.ExprConstraints{},
IsOptional: true,
Description: lang.Markdown("Reference to a `provider` configuration block, e.g. `mycloud.west` or `mycloud`"),
IsDepKey: true,
},
"count": {
ValueType: cty.Number,
Expr: schema.LiteralTypeOnly(cty.Number),
IsOptional: true,
Description: lang.Markdown("Number of instances of this resource, e.g. `3`"),
},
"depends_on": {
ValueType: cty.Set(cty.DynamicPseudoType),
Expr: schema.ExprConstraints{
schema.TupleConsExpr{
Name: "set of references",
},
},
IsOptional: true,
Description: lang.Markdown("Set of references to hidden dependencies, e.g. other resources or data sources"),
},
Expand All @@ -51,9 +55,9 @@ func resourceBlockSchema(v *version.Version) *schema.BlockSchema {

if v.GreaterThanOrEqual(v0_12_6) {
bs.Body.Attributes["for_each"] = &schema.AttributeSchema{
ValueTypes: schema.ValueTypes{
cty.Set(cty.DynamicPseudoType),
cty.Map(cty.DynamicPseudoType),
Expr: schema.ExprConstraints{
schema.LiteralTypeExpr{Type: cty.Set(cty.DynamicPseudoType)},
schema.LiteralTypeExpr{Type: cty.Map(cty.DynamicPseudoType)},
},
IsOptional: true,
Description: lang.Markdown("A set or a map where each item represents an instance of this resource"),
Expand All @@ -68,19 +72,21 @@ var lifecycleBlock = &schema.BlockSchema{
Body: &schema.BodySchema{
Attributes: map[string]*schema.AttributeSchema{
"create_before_destroy": {
ValueType: cty.Bool,
Expr: schema.LiteralTypeOnly(cty.Bool),
IsOptional: true,
Description: lang.Markdown("Whether to reverse the default order of operations (destroy -> create) during apply " +
"when the resource requires replacement (cannot be updated in-place)"),
},
"prevent_destroy": {
ValueType: cty.Bool,
Expr: schema.LiteralTypeOnly(cty.Bool),
IsOptional: true,
Description: lang.Markdown("Whether to prevent accidental destruction of the resource and cause Terraform " +
"to reject with an error any plan that would destroy the resource"),
},
"ignore_changes": {
ValueType: cty.Set(cty.DynamicPseudoType),
Expr: schema.ExprConstraints{
schema.TupleConsExpr{},
},
IsOptional: true,
Description: lang.Markdown("A set of fields (references) of which to ignore changes to, e.g. `tags`"),
},
Expand All @@ -101,14 +107,32 @@ var provisionerBlock = &schema.BlockSchema{
Body: &schema.BodySchema{
Attributes: map[string]*schema.AttributeSchema{
"when": {
ValueType: cty.DynamicPseudoType,
Expr: schema.ExprConstraints{
schema.KeywordExpr{
Keyword: "create",
Description: lang.Markdown("Run the provisioner when the resource is created"),
},
schema.KeywordExpr{
Keyword: "destroy",
Description: lang.Markdown("Run the provisioner when the resource is destroyed"),
},
},
IsOptional: true,
Description: lang.Markdown("When to run the provisioner - `create` or `destroy`, defaults to `create` " +
"(i.e. after creation of the resource)"),
},
"on_failure": {
IsOptional: true,
ValueType: cty.DynamicPseudoType,
Expr: schema.ExprConstraints{
schema.KeywordExpr{
Keyword: "fail",
Description: lang.Markdown("Raise an error and stop applying (the default behavior). If this is a creation provisioner, taint the resource."),
},
schema.KeywordExpr{
Keyword: "continue",
Description: lang.Markdown("Ignore the error and continue with creation or destruction"),
},
},
Description: lang.Markdown("What to do when the provisioner run fails to finish - `fail` (default), " +
"or `continue` (ignore the error)"),
},
Expand All @@ -125,7 +149,16 @@ var connectionBlock = &schema.BlockSchema{
Body: &schema.BodySchema{
Attributes: map[string]*schema.AttributeSchema{
"type": {
ValueType: cty.String,
Expr: schema.ExprConstraints{
schema.LiteralValue{
Val: cty.StringVal("ssh"),
Description: lang.Markdown("Use SSH to connect and provision the instance"),
},
schema.LiteralValue{
Val: cty.StringVal("winrm"),
Description: lang.Markdown("Use WinRM to connect and provision the instance"),
},
},
IsOptional: true,
Description: lang.Markdown("Connection type to use - `ssh` (default) or `winrm`"),
},
Expand Down
26 changes: 19 additions & 7 deletions internal/schema/0.12/terraform_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func terraformBlockSchema(v *version.Version) *schema.BlockSchema {
Body: &schema.BodySchema{
Attributes: map[string]*schema.AttributeSchema{
"required_version": {
ValueType: cty.String,
Expr: schema.LiteralTypeOnly(cty.String),
IsOptional: true,
Description: lang.Markdown("Constraint to specify which versions of Terraform can be used " +
"with this configuration, e.g. `~> 0.12`"),
Expand All @@ -36,7 +36,7 @@ func terraformBlockSchema(v *version.Version) *schema.BlockSchema {
Description: lang.Markdown("What provider version to use within this configuration"),
Body: &schema.BodySchema{
AnyAttribute: &schema.AttributeSchema{
ValueType: cty.String,
Expr: schema.LiteralTypeOnly(cty.String),
Description: lang.Markdown("Version constraint"),
},
},
Expand All @@ -47,8 +47,20 @@ func terraformBlockSchema(v *version.Version) *schema.BlockSchema {
}

if v.GreaterThanOrEqual(v0_12_18) {
experiments := schema.TupleConsExpr{
AnyElem: schema.ExprConstraints{},
Name: "set of features",
}
if v.GreaterThanOrEqual(v0_12_20) {
experiments.AnyElem = append(experiments.AnyElem, schema.KeywordExpr{
Keyword: "variable_validation",
Name: "feature",
})
}
bs.Body.Attributes["experiments"] = &schema.AttributeSchema{
ValueType: cty.Set(cty.DynamicPseudoType),
Expr: schema.ExprConstraints{
experiments,
},
IsOptional: true,
Description: lang.Markdown("A set of experimental language features to enable"),
}
Expand All @@ -57,11 +69,11 @@ func terraformBlockSchema(v *version.Version) *schema.BlockSchema {
if v.GreaterThanOrEqual(v0_12_20) {
bs.Body.Blocks["required_providers"].Body = &schema.BodySchema{
AnyAttribute: &schema.AttributeSchema{
ValueTypes: schema.ValueTypes{
cty.Object(map[string]cty.Type{
Expr: schema.ExprConstraints{
schema.LiteralTypeExpr{Type: cty.Object(map[string]cty.Type{
"version": cty.String,
}),
cty.String,
})},
schema.LiteralTypeExpr{Type: cty.String},
},
Description: lang.Markdown("Version constraint"),
},
Expand Down
Loading