call the InConfigBody with addresses

This commit is contained in:
James Bardin 2021-04-02 17:11:20 -04:00
parent 406ac97965
commit 265b5106ca
6 changed files with 18 additions and 17 deletions

View File

@ -39,7 +39,7 @@ func TestBackendConfig(t *testing.T, b Backend, c hcl.Body) Backend {
diags = diags.Append(decDiags)
newObj, valDiags := b.PrepareConfig(obj)
diags = diags.Append(valDiags.InConfigBody(c))
diags = diags.Append(valDiags.InConfigBody(c, ""))
if len(diags) != 0 {
t.Fatal(diags.ErrWithWarnings())
@ -49,7 +49,7 @@ func TestBackendConfig(t *testing.T, b Backend, c hcl.Body) Backend {
confDiags := b.Configure(obj)
if len(confDiags) != 0 {
confDiags = confDiags.InConfigBody(c)
confDiags = confDiags.InConfigBody(c, "")
t.Fatal(confDiags.ErrWithWarnings())
}

View File

@ -1086,13 +1086,13 @@ func (m *Meta) backendInitFromConfig(c *configs.Backend) (backend.Backend, cty.V
}
newVal, validateDiags := b.PrepareConfig(configVal)
diags = diags.Append(validateDiags.InConfigBody(c.Config))
diags = diags.Append(validateDiags.InConfigBody(c.Config, ""))
if validateDiags.HasErrors() {
return nil, cty.NilVal, diags
}
configureDiags := b.Configure(newVal)
diags = diags.Append(configureDiags.InConfigBody(c.Config))
diags = diags.Append(configureDiags.InConfigBody(c.Config, ""))
return b, configVal, diags
}

View File

@ -393,7 +393,7 @@ func TestProtoDiagnostics_emptyAttributePath(t *testing.T) {
if parseDiags.HasErrors() {
t.Fatal(parseDiags)
}
diags := tfDiags.InConfigBody(f.Body)
diags := tfDiags.InConfigBody(f.Body, "")
if len(tfDiags) != 1 {
t.Fatalf("expected 1 diag, got %d", len(tfDiags))

View File

@ -167,14 +167,14 @@ func (n *NodeApplyableProvider) ConfigureProvider(ctx EvalContext, provider prov
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Invalid provider configuration",
fmt.Sprintf(providerConfigErr, configDiags.InConfigBody(configBody).Err(), n.Addr.Provider),
fmt.Sprintf(providerConfigErr, configDiags.InConfigBody(configBody, n.Addr.String()).Err(), n.Addr.Provider),
))
return diags
} else {
return diags.Append(configDiags.InConfigBody(configBody))
return diags.Append(configDiags.InConfigBody(configBody, n.Addr.String()))
}
}
diags = diags.Append(configDiags.InConfigBody(configBody))
diags = diags.Append(configDiags.InConfigBody(configBody, n.Addr.String()))
return diags
}

View File

@ -625,8 +625,9 @@ func (n *NodeAbstractResourceInstance) plan(
Config: unmarkedConfigVal,
},
)
if validateResp.Diagnostics.HasErrors() {
diags = diags.Append(validateResp.Diagnostics.InConfigBody(config.Config))
diags = diags.Append(validateResp.Diagnostics.InConfigBody(config.Config, n.Addr.String()))
return plan, state, diags
}
@ -659,7 +660,7 @@ func (n *NodeAbstractResourceInstance) plan(
PriorPrivate: priorPrivate,
ProviderMeta: metaConfigVal,
})
diags = diags.Append(resp.Diagnostics.InConfigBody(config.Config))
diags = diags.Append(resp.Diagnostics.InConfigBody(config.Config, n.Addr.String()))
if diags.HasErrors() {
return plan, state, diags
}
@ -869,7 +870,7 @@ func (n *NodeAbstractResourceInstance) plan(
// Consequently, we break from the usual pattern here and only
// append these new diagnostics if there's at least one error inside.
if resp.Diagnostics.HasErrors() {
diags = diags.Append(resp.Diagnostics.InConfigBody(config.Config))
diags = diags.Append(resp.Diagnostics.InConfigBody(config.Config, n.Addr.String()))
return plan, state, diags
}
plannedNewVal = resp.PlannedState
@ -1195,7 +1196,7 @@ func (n *NodeAbstractResourceInstance) readDataSource(ctx EvalContext, configVal
},
)
if validateResp.Diagnostics.HasErrors() {
return newVal, validateResp.Diagnostics.InConfigBody(config.Config)
return newVal, validateResp.Diagnostics.InConfigBody(config.Config, n.Addr.String())
}
// If we get down here then our configuration is complete and we're read
@ -1207,7 +1208,7 @@ func (n *NodeAbstractResourceInstance) readDataSource(ctx EvalContext, configVal
Config: configVal,
ProviderMeta: metaConfigVal,
})
diags = diags.Append(resp.Diagnostics.InConfigBody(config.Config))
diags = diags.Append(resp.Diagnostics.InConfigBody(config.Config, n.Addr.String()))
if diags.HasErrors() {
return newVal, diags
}
@ -1741,7 +1742,7 @@ func (n *NodeAbstractResourceInstance) applyProvisioners(ctx EvalContext, state
Connection: unmarkedConnInfo,
UIOutput: &output,
})
applyDiags := resp.Diagnostics.InConfigBody(prov.Config)
applyDiags := resp.Diagnostics.InConfigBody(prov.Config, n.Addr.String())
// Call post hook
hookErr := ctx.Hook(func(h Hook) (HookAction, error) {
@ -1907,7 +1908,7 @@ func (n *NodeAbstractResourceInstance) apply(
})
applyDiags := resp.Diagnostics
if applyConfig != nil {
applyDiags = applyDiags.InConfigBody(applyConfig.Config)
applyDiags = applyDiags.InConfigBody(applyConfig.Config, n.Addr.String())
}
diags = diags.Append(applyDiags)

View File

@ -381,7 +381,7 @@ func (n *NodeValidatableResource) validateResource(ctx EvalContext) tfdiags.Diag
}
resp := provider.ValidateResourceConfig(req)
diags = diags.Append(resp.Diagnostics.InConfigBody(n.Config.Config))
diags = diags.Append(resp.Diagnostics.InConfigBody(n.Config.Config, n.Addr.String()))
case addrs.DataResourceMode:
schema, _ := providerSchema.SchemaForResourceType(n.Config.Mode, n.Config.Type)
@ -409,7 +409,7 @@ func (n *NodeValidatableResource) validateResource(ctx EvalContext) tfdiags.Diag
}
resp := provider.ValidateDataResourceConfig(req)
diags = diags.Append(resp.Diagnostics.InConfigBody(n.Config.Config))
diags = diags.Append(resp.Diagnostics.InConfigBody(n.Config.Config, n.Addr.String()))
}
return diags