Skip to content

Commit dc77ebc

Browse files
committed
Uses terraform core's stack schema for config parsing
1 parent 25db91e commit dc77ebc

File tree

2 files changed

+11
-41
lines changed

2 files changed

+11
-41
lines changed

tfconfig/load_hcl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func loadStackFromFile(file *hcl.File, stack *Stack) hcl.Diagnostics {
254254
continue
255255
}
256256

257-
_, _, contentDiags := block.Body.PartialContent(stackProviderSchema)
257+
_, _, contentDiags := block.Body.PartialContent(providerConfigSchema)
258258
diags = append(diags, contentDiags...)
259259

260260
providerName := block.Labels[0]

tfconfig/schema.go

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -133,49 +133,19 @@ var componentSchema = &hcl.BodySchema{
133133
},
134134
}
135135

136-
// stackSchema defines the schema for Terraform Stacks files
136+
// stackSchema defines the schema for Terraform Stacks files based on Terraform core's rootConfigSchema
137137
var stackSchema = &hcl.BodySchema{
138-
Blocks: []hcl.BlockHeaderSchema{
139-
{
140-
Type: "terraform",
141-
LabelNames: nil,
142-
},
143-
{
144-
Type: "variable",
145-
LabelNames: []string{"name"},
146-
},
147-
{
148-
Type: "output",
149-
LabelNames: []string{"name"},
150-
},
151-
{
152-
Type: "provider",
153-
LabelNames: []string{"name", "config_name"},
154-
},
155-
{
156-
Type: "component",
157-
LabelNames: []string{"name"},
158-
},
159-
{
160-
Type: "required_providers",
161-
LabelNames: nil,
162-
},
163-
},
164-
}
165-
166-
// stackProviderSchema defines the schema for provider blocks in stacks
167-
var stackProviderSchema = &hcl.BodySchema{
168138
Attributes: []hcl.AttributeSchema{
169-
{
170-
Name: "for_each",
171-
},
172-
{
173-
Name: "config",
174-
},
139+
{Name: "language"},
175140
},
176141
Blocks: []hcl.BlockHeaderSchema{
177-
{
178-
Type: "config",
179-
},
142+
{Type: "stack", LabelNames: []string{"name"}},
143+
{Type: "component", LabelNames: []string{"name"}},
144+
{Type: "variable", LabelNames: []string{"name"}},
145+
{Type: "locals"},
146+
{Type: "output", LabelNames: []string{"name"}},
147+
{Type: "provider", LabelNames: []string{"type", "name"}},
148+
{Type: "required_providers"},
149+
{Type: "removed"},
180150
},
181151
}

0 commit comments

Comments
 (0)