Skip to content

Commit

Permalink
schema: add 1.1 moved block (#121)
Browse files Browse the repository at this point in the history
* schema: add 1.1 moved block

* remove data source ref constraints
  • Loading branch information
radeksimko authored Jul 8, 2022
1 parent 1a218af commit 408b2ae
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/schema/1.1/moved.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package schema

import (
"github.com/hashicorp/hcl-lang/lang"
"github.com/hashicorp/hcl-lang/schema"
"github.com/hashicorp/terraform-schema/internal/schema/refscope"
)

var movedBlockSchema = &schema.BlockSchema{
Description: lang.Markdown("Refactoring declaration to specify what address to move where"),
Body: &schema.BodySchema{
HoverURL: "https://www.terraform.io/language/modules/develop/refactoring#moved-block-syntax",
Attributes: map[string]*schema.AttributeSchema{
"from": {
Expr: schema.ExprConstraints{
schema.TraversalExpr{OfScopeId: refscope.ModuleScope},
schema.TraversalExpr{OfScopeId: refscope.ResourceScope},
},
IsRequired: true,
Description: lang.Markdown("Source address to move away from"),
},
"to": {
Expr: schema.ExprConstraints{
schema.TraversalExpr{OfScopeId: refscope.ModuleScope},
schema.TraversalExpr{OfScopeId: refscope.ResourceScope},
},
IsRequired: true,
Description: lang.Markdown("Destination address to move to"),
},
},
},
}
1 change: 1 addition & 0 deletions internal/schema/1.1/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

func ModuleSchema(v *version.Version) *schema.BodySchema {
bs := v015_mod.ModuleSchema(v)
bs.Blocks["moved"] = movedBlockSchema
bs.Blocks["terraform"] = patchTerraformBlockSchema(bs.Blocks["terraform"], v)
return bs
}

0 comments on commit 408b2ae

Please sign in to comment.