mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
core: EvalValidateProvider must always call provider.Validate
Previously we were skipping all of the validation steps if a provider was being configured implicitly, and thus had no block in configuration. This is incorrect, since a provider must still get an opportunity to configure itself with an empty configuration and possibly reject that empty configuration with errors.
This commit is contained in:
parent
b031e18332
commit
e4e3876332
@ -71,11 +71,15 @@ type EvalValidateProvider struct {
|
|||||||
func (n *EvalValidateProvider) Eval(ctx EvalContext) (interface{}, error) {
|
func (n *EvalValidateProvider) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
var diags tfdiags.Diagnostics
|
var diags tfdiags.Diagnostics
|
||||||
provider := *n.Provider
|
provider := *n.Provider
|
||||||
config := n.Config
|
|
||||||
|
|
||||||
if n.Config == nil {
|
var sourceBody hcl.Body
|
||||||
// Nothing to validate, then.
|
if n.Config != nil && n.Config.Config != nil {
|
||||||
return nil, nil
|
sourceBody = n.Config.Config
|
||||||
|
} else {
|
||||||
|
// If the provider configuration is implicit (no block in configuration
|
||||||
|
// but referred to by resources) then we'll assume an empty body
|
||||||
|
// as a placeholder.
|
||||||
|
sourceBody = hcl.EmptyBody()
|
||||||
}
|
}
|
||||||
|
|
||||||
schema, err := provider.GetSchema(&ProviderSchemaRequest{})
|
schema, err := provider.GetSchema(&ProviderSchemaRequest{})
|
||||||
@ -88,7 +92,7 @@ func (n *EvalValidateProvider) Eval(ctx EvalContext) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configSchema := schema.Provider
|
configSchema := schema.Provider
|
||||||
configBody := buildProviderConfig(ctx, n.Addr, config.Config)
|
configBody := buildProviderConfig(ctx, n.Addr, sourceBody)
|
||||||
configVal, configBody, evalDiags := ctx.EvaluateBlock(configBody, configSchema, nil, addrs.NoKey)
|
configVal, configBody, evalDiags := ctx.EvaluateBlock(configBody, configSchema, nil, addrs.NoKey)
|
||||||
diags = diags.Append(evalDiags)
|
diags = diags.Append(evalDiags)
|
||||||
if evalDiags.HasErrors() {
|
if evalDiags.HasErrors() {
|
||||||
|
Loading…
Reference in New Issue
Block a user