Fix diags non-assignment bugs

Fix places where diags was not reassigned when diags were added.
This commit is contained in:
Pam Selle 2020-11-20 13:21:56 -05:00
parent 9ac9564207
commit c55b69e30a
2 changed files with 5 additions and 5 deletions

View File

@ -323,10 +323,10 @@ func (s *Scope) evalContext(refs []*addrs.Reference, selfAddr addrs.Referenceabl
switch k := subj.Key.(type) {
case addrs.IntKey:
self, hclDiags = hcl.Index(val, cty.NumberIntVal(int64(k)), ref.SourceRange.ToHCL().Ptr())
diags.Append(hclDiags)
diags = diags.Append(hclDiags)
case addrs.StringKey:
self, hclDiags = hcl.Index(val, cty.StringVal(string(k)), ref.SourceRange.ToHCL().Ptr())
diags.Append(hclDiags)
diags = diags.Append(hclDiags)
default:
self = val
}

View File

@ -546,7 +546,7 @@ func TestContext2Validate_orphans(t *testing.T) {
p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse {
var diags tfdiags.Diagnostics
if req.Config.GetAttr("foo").IsNull() {
diags.Append(errors.New("foo is not set"))
diags = diags.Append(errors.New("foo is not set"))
}
return providers.ValidateResourceTypeConfigResponse{
Diagnostics: diags,
@ -810,7 +810,7 @@ func TestContext2Validate_provisionerConfig_good(t *testing.T) {
pr.ValidateProvisionerConfigFn = func(req provisioners.ValidateProvisionerConfigRequest) provisioners.ValidateProvisionerConfigResponse {
var diags tfdiags.Diagnostics
if req.Config.GetAttr("test_string").IsNull() {
diags.Append(errors.New("test_string is not set"))
diags = diags.Append(errors.New("test_string is not set"))
}
return provisioners.ValidateProvisionerConfigResponse{
Diagnostics: diags,
@ -943,7 +943,7 @@ func TestContext2Validate_tainted(t *testing.T) {
p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse {
var diags tfdiags.Diagnostics
if req.Config.GetAttr("foo").IsNull() {
diags.Append(errors.New("foo is not set"))
diags = diags.Append(errors.New("foo is not set"))
}
return providers.ValidateResourceTypeConfigResponse{
Diagnostics: diags,