da95646a33
This extension allows an application to support dynamic generation of child blocks based on expressions in certain contexts. This is done using a new block type called "dynamic", which contains an iteration value (which must be a collection) and a specification of how to construct a child block for each element of that collection.
51 lines
812 B
Go
51 lines
812 B
Go
package dynblock
|
|
|
|
import "github.com/hashicorp/hcl2/hcl"
|
|
|
|
var dynamicBlockHeaderSchema = hcl.BlockHeaderSchema{
|
|
Type: "dynamic",
|
|
LabelNames: []string{"type"},
|
|
}
|
|
|
|
var dynamicBlockBodySchemaLabels = &hcl.BodySchema{
|
|
Attributes: []hcl.AttributeSchema{
|
|
{
|
|
Name: "for_each",
|
|
Required: true,
|
|
},
|
|
{
|
|
Name: "iterator",
|
|
Required: false,
|
|
},
|
|
{
|
|
Name: "labels",
|
|
Required: true,
|
|
},
|
|
},
|
|
Blocks: []hcl.BlockHeaderSchema{
|
|
{
|
|
Type: "content",
|
|
LabelNames: nil,
|
|
},
|
|
},
|
|
}
|
|
|
|
var dynamicBlockBodySchemaNoLabels = &hcl.BodySchema{
|
|
Attributes: []hcl.AttributeSchema{
|
|
{
|
|
Name: "for_each",
|
|
Required: true,
|
|
},
|
|
{
|
|
Name: "iterator",
|
|
Required: false,
|
|
},
|
|
},
|
|
Blocks: []hcl.BlockHeaderSchema{
|
|
{
|
|
Type: "content",
|
|
LabelNames: nil,
|
|
},
|
|
},
|
|
}
|