Skip to content

Commit 9a3f2bf

Browse files
committed
update imports to hashicorp/go-cty
change RequiredWith to use diagnostics
1 parent 74146e6 commit 9a3f2bf

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

diag/diagnostic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"errors"
55
"fmt"
66

7-
"github.com/zclconf/go-cty/cty"
7+
"github.com/hashicorp/go-cty/cty"
88
)
99

1010
// Diagnostics is a collection of Diagnostic.

helper/schema/schema.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import (
2222
"strconv"
2323
"strings"
2424

25+
"github.com/hashicorp/go-cty/cty"
2526
"github.com/mitchellh/copystructure"
2627
"github.com/mitchellh/mapstructure"
27-
"github.com/zclconf/go-cty/cty"
2828

2929
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
3030
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/hcl2shim"
@@ -1459,7 +1459,12 @@ func (m schemaMap) validate(
14591459

14601460
err = validateRequiredWithAttribute(k, schema, c)
14611461
if err != nil {
1462-
return nil, []error{err}
1462+
return append(diags, diag.Diagnostic{
1463+
Severity: diag.Error,
1464+
Summary: "RequiredWith",
1465+
Detail: err.Error(),
1466+
AttributePath: path,
1467+
})
14631468
}
14641469

14651470
// If the value is unknown then we can't validate it yet.

helper/schema/schema_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import (
1212
"strings"
1313
"testing"
1414

15+
"github.com/hashicorp/go-cty/cty"
1516
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1617
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/hashcode"
1718
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/hcl2shim"
1819
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
19-
"github.com/zclconf/go-cty/cty"
2020
)
2121

2222
func TestEnvDefaultFunc(t *testing.T) {
@@ -6791,7 +6791,8 @@ func TestValidateRequiredWithAttributes(t *testing.T) {
67916791
for tn, tc := range cases {
67926792
t.Run(tn, func(t *testing.T) {
67936793
c := terraform.NewResourceConfigRaw(tc.Config)
6794-
_, es := schemaMap(tc.Schema).Validate(c)
6794+
diags := schemaMap(tc.Schema).Validate(c)
6795+
es := errorDiags(diags).Errors()
67956796
if len(es) > 0 != tc.Err {
67966797
if len(es) == 0 {
67976798
t.Fatalf("expected error")

0 commit comments

Comments
 (0)