command: Fix backend config schema validation

When applying a backend config override file, we must not check for the
presence of all required fields, as the override can be a partial
configuration. It is only valid to check for required fields after all
overrides have been merged, which init already does.
This commit is contained in:
Alisdair McDiarmid 2020-08-26 10:50:47 -04:00
parent 75e676f2f2
commit f028b0a2bf
1 changed files with 6 additions and 3 deletions

View File

@ -866,10 +866,13 @@ func (c *InitCommand) backendConfigOverrideBody(flags rawFlags, schema *configsc
}
// Generate an HCL body schema for the backend block.
var bodySchema hcl.BodySchema
for name, attr := range schema.Attributes {
for name := range schema.Attributes {
// We intentionally ignore the `Required` attribute here
// because backend config override files can be partial. The
// goal is to make sure we're not loading a file with
// extraneous attributes or blocks.
bodySchema.Attributes = append(bodySchema.Attributes, hcl.AttributeSchema{
Name: name,
Required: attr.Required,
Name: name,
})
}
for name, block := range schema.BlockTypes {