Skip to content

Commit

Permalink
internal/schema: KeywordExpr -> Keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Jan 23, 2023
1 parent 738006d commit 442c5c8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 33 deletions.
12 changes: 6 additions & 6 deletions internal/schema/0.12/provisioner_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func provisionerBlock(v *version.Version) *schema.BlockSchema {
HoverURL: "https://www.terraform.io/docs/language/resources/provisioners/syntax.html",
Attributes: map[string]*schema.AttributeSchema{
"when": {
Expr: schema.ExprConstraints{
schema.KeywordExpr{
Constraint: schema.OneOf{
schema.Keyword{
Keyword: "create",
Description: lang.Markdown("Run the provisioner when the resource is created"),
},
schema.KeywordExpr{
schema.Keyword{
Keyword: "destroy",
Description: lang.Markdown("Run the provisioner when the resource is destroyed"),
},
Expand All @@ -45,12 +45,12 @@ func provisionerBlock(v *version.Version) *schema.BlockSchema {
},
"on_failure": {
IsOptional: true,
Expr: schema.ExprConstraints{
schema.KeywordExpr{
Constraint: schema.OneOf{
schema.Keyword{
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{
schema.Keyword{
Keyword: "continue",
Description: lang.Markdown("Ignore the error and continue with creation or destruction"),
},
Expand Down
8 changes: 5 additions & 3 deletions internal/schema/0.12/resource_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ func lifecycleBlock() *schema.BlockSchema {
"to reject with an error any plan that would destroy the resource"),
},
"ignore_changes": {
Expr: schema.ExprConstraints{
schema.SetExpr{},
schema.KeywordExpr{
Constraint: schema.OneOf{
schema.Set{
// TODO: expose reference targets via attribute-only address
},
schema.Keyword{
Keyword: "all",
Description: lang.Markdown("Ignore all attributes, which means that Terraform can create" +
" and destroy the remote object but will never propose updates to it"),
Expand Down
10 changes: 4 additions & 6 deletions internal/schema/0.12/terraform_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,16 @@ func terraformBlockSchema(v *version.Version) *schema.BlockSchema {
}

if v.GreaterThanOrEqual(v0_12_18) {
experiments := schema.SetExpr{
Elem: schema.ExprConstraints{},
}
experiments := schema.OneOf{}
if v.GreaterThanOrEqual(v0_12_20) {
experiments.Elem = append(experiments.Elem, schema.KeywordExpr{
experiments = append(experiments, schema.Keyword{
Keyword: "variable_validation",
Name: "feature",
})
}
bs.Body.Attributes["experiments"] = &schema.AttributeSchema{
Expr: schema.ExprConstraints{
experiments,
Constraint: schema.Set{
Elem: experiments,
},
IsOptional: true,
Description: lang.Markdown("A set of experimental language features to enable"),
Expand Down
20 changes: 9 additions & 11 deletions internal/schema/0.14/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,15 @@ func terraformBlockSchema(v *version.Version) *schema.BlockSchema {
"with this configuration, e.g. `~> 0.12`"),
},
"experiments": {
Expr: schema.ExprConstraints{
schema.SetExpr{
Elem: schema.ExprConstraints{
schema.KeywordExpr{
Keyword: "module_variable_optional_attrs",
Name: "feature",
},
schema.KeywordExpr{
Keyword: "provider_sensitive_attrs",
Name: "feature",
},
Constraint: schema.Set{
Elem: schema.OneOf{
schema.Keyword{
Keyword: "module_variable_optional_attrs",
Name: "feature",
},
schema.Keyword{
Keyword: "provider_sensitive_attrs",
Name: "feature",
},
},
},
Expand Down
6 changes: 2 additions & 4 deletions internal/schema/0.15/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ func patchTerraformBlockSchema(bs *schema.BlockSchema) *schema.BlockSchema {
}
bs.Body.Attributes["language"] = &schema.AttributeSchema{
IsOptional: true,
Expr: schema.ExprConstraints{
schema.KeywordExpr{
Keyword: "TF2021",
},
Constraint: schema.Keyword{
Keyword: "TF2021",
},
}
return bs
Expand Down
8 changes: 5 additions & 3 deletions internal/schema/1.2/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ func resourceLifecycleBlock() *schema.BlockSchema {
"to reject with an error any plan that would destroy the resource"),
},
"ignore_changes": {
Expr: schema.ExprConstraints{
schema.SetExpr{},
schema.KeywordExpr{
Constraint: schema.OneOf{
schema.Set{
// TODO: expose reference targets via attribute-only address
},
schema.Keyword{
Keyword: "all",
Description: lang.Markdown("Ignore all attributes, which means that Terraform can create" +
" and destroy the remote object but will never propose updates to it"),
Expand Down

0 comments on commit 442c5c8

Please sign in to comment.