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

schema: add 1.2 lifecycle replace_triggered_by attribute #123

Merged
merged 2 commits into from
Jul 8, 2022
Merged
Changes from 1 commit
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
28 changes: 20 additions & 8 deletions internal/schema/1.2/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ import (
"github.com/zclconf/go-cty/cty"

v1_1_mod "github.com/hashicorp/terraform-schema/internal/schema/1.1"
"github.com/hashicorp/terraform-schema/internal/schema/refscope"
)

var v1_2 = version.Must(version.NewVersion("1.2.0"))

func ModuleSchema(v *version.Version) *schema.BodySchema {
bs := v1_1_mod.ModuleSchema(v)
if v.GreaterThanOrEqual(v1_2) {
bs.Blocks["data"].Body.Blocks = map[string]*schema.BlockSchema{
"lifecycle": datasourceLifecycleBlock,
}
bs.Blocks["resource"].Body.Blocks["lifecycle"] = resourceLifecycleBlock
bs.Blocks["output"].Body.Blocks = map[string]*schema.BlockSchema{
"lifecycle": outputLifecycleBlock,
}
bs.Blocks["data"].Body.Blocks = map[string]*schema.BlockSchema{
"lifecycle": datasourceLifecycleBlock,
}
bs.Blocks["resource"].Body.Blocks["lifecycle"] = resourceLifecycleBlock
bs.Blocks["output"].Body.Blocks = map[string]*schema.BlockSchema{
"lifecycle": outputLifecycleBlock,
}

return bs
Expand Down Expand Up @@ -79,6 +78,19 @@ var resourceLifecycleBlock = &schema.BlockSchema{
IsOptional: true,
Description: lang.Markdown("A set of fields (references) of which to ignore changes to, e.g. `tags`"),
},
"replace_triggered_by": {
Expr: schema.ExprConstraints{
schema.TupleConsExpr{
Name: "set of references",
AnyElem: schema.ExprConstraints{
schema.TraversalExpr{OfScopeId: refscope.ResourceScope},
},
},
},
IsOptional: true,
Description: lang.Markdown("Set of references to any other resources which when changed cause " +
"this resource to be proposed for replacement"),
},
},
Blocks: map[string]*schema.BlockSchema{
"precondition": {
Expand Down