Merge pull request #26999 from hashicorp/pselle/diags

Fix diags non-assignment bugs
This commit is contained in:
Pam Selle 2020-11-20 15:55:05 -05:00 committed by GitHub
commit a44a50a8b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) { switch k := subj.Key.(type) {
case addrs.IntKey: case addrs.IntKey:
self, hclDiags = hcl.Index(val, cty.NumberIntVal(int64(k)), ref.SourceRange.ToHCL().Ptr()) self, hclDiags = hcl.Index(val, cty.NumberIntVal(int64(k)), ref.SourceRange.ToHCL().Ptr())
diags.Append(hclDiags) diags = diags.Append(hclDiags)
case addrs.StringKey: case addrs.StringKey:
self, hclDiags = hcl.Index(val, cty.StringVal(string(k)), ref.SourceRange.ToHCL().Ptr()) self, hclDiags = hcl.Index(val, cty.StringVal(string(k)), ref.SourceRange.ToHCL().Ptr())
diags.Append(hclDiags) diags = diags.Append(hclDiags)
default: default:
self = val self = val
} }

View File

@ -546,7 +546,7 @@ func TestContext2Validate_orphans(t *testing.T) {
p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse { p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse {
var diags tfdiags.Diagnostics var diags tfdiags.Diagnostics
if req.Config.GetAttr("foo").IsNull() { 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{ return providers.ValidateResourceTypeConfigResponse{
Diagnostics: diags, Diagnostics: diags,
@ -810,7 +810,7 @@ func TestContext2Validate_provisionerConfig_good(t *testing.T) {
pr.ValidateProvisionerConfigFn = func(req provisioners.ValidateProvisionerConfigRequest) provisioners.ValidateProvisionerConfigResponse { pr.ValidateProvisionerConfigFn = func(req provisioners.ValidateProvisionerConfigRequest) provisioners.ValidateProvisionerConfigResponse {
var diags tfdiags.Diagnostics var diags tfdiags.Diagnostics
if req.Config.GetAttr("test_string").IsNull() { 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{ return provisioners.ValidateProvisionerConfigResponse{
Diagnostics: diags, Diagnostics: diags,
@ -943,7 +943,7 @@ func TestContext2Validate_tainted(t *testing.T) {
p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse { p.ValidateResourceTypeConfigFn = func(req providers.ValidateResourceTypeConfigRequest) providers.ValidateResourceTypeConfigResponse {
var diags tfdiags.Diagnostics var diags tfdiags.Diagnostics
if req.Config.GetAttr("foo").IsNull() { 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{ return providers.ValidateResourceTypeConfigResponse{
Diagnostics: diags, Diagnostics: diags,