Skip to content

Commit

Permalink
update imports to hashicorp/go-cty
Browse files Browse the repository at this point in the history
change RequiredWith to use diagnostics
  • Loading branch information
appilon committed Apr 17, 2020
1 parent 74146e6 commit 9a3f2bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion diag/diagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/zclconf/go-cty/cty"
"github.com/hashicorp/go-cty/cty"
)

// Diagnostics is a collection of Diagnostic.
Expand Down
9 changes: 7 additions & 2 deletions helper/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"strconv"
"strings"

"github.com/hashicorp/go-cty/cty"
"github.com/mitchellh/copystructure"
"github.com/mitchellh/mapstructure"
"github.com/zclconf/go-cty/cty"

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

err = validateRequiredWithAttribute(k, schema, c)
if err != nil {
return nil, []error{err}
return append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: "RequiredWith",
Detail: err.Error(),
AttributePath: path,
})
}

// If the value is unknown then we can't validate it yet.
Expand Down
5 changes: 3 additions & 2 deletions helper/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"strings"
"testing"

"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/hashcode"
"github.com/hashicorp/terraform-plugin-sdk/v2/internal/configs/hcl2shim"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/zclconf/go-cty/cty"
)

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

0 comments on commit 9a3f2bf

Please sign in to comment.