Skip to content

Commit

Permalink
Updated util with new diag.Diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
AdminTurnedDevOps committed Sep 28, 2020
1 parent 931a51b commit 083d1d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion go.mod
Expand Up @@ -13,6 +13,7 @@ require (
github.com/google/uuid v1.1.2
github.com/gostaticanalysis/analysisutil v0.2.1 // indirect
github.com/gruntwork-io/terratest v0.29.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-getter v1.4.2-0.20200106182914-9813cbd4eb02 // indirect
github.com/hashicorp/go-plugin v1.3.0 // indirect
github.com/hashicorp/hcl/v2 v2.6.0 // indirect
Expand All @@ -33,7 +34,7 @@ require (
github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b // indirect
github.com/tetafro/godot v0.4.9 // indirect
github.com/timakin/bodyclose v0.0.0-20200424151742-cb6215831a94 // indirect
github.com/zclconf/go-cty v1.5.1 // indirect
github.com/zclconf/go-cty v1.5.1
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff // indirect
Expand Down
8 changes: 6 additions & 2 deletions octopusdeploy/util.go
Expand Up @@ -6,13 +6,17 @@ import (
"strings"

"github.com/OctopusDeploy/go-octopusdeploy/client"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

// Validate a value against a set of possible values
func validateValueFunc(values []string) schema.SchemaValidateDiagFunc {
return func(v interface{}, k string) (we []string, errors []error) {

return func(v interface{}, c cty.Path) diag.Diagnostics {
var diags diag.Diagnostics
value := v.(string)
valid := false
for _, val := range values {
Expand All @@ -23,7 +27,7 @@ func validateValueFunc(values []string) schema.SchemaValidateDiagFunc {
}

if !valid {
errors = append(errors, fmt.Errorf("%#v is an invalid value for argument %s. Must be one of %#v", value, k, values))
diags = append(errors, fmt.Errorf("%#v is an invalid value for argument %s. Must be one of %#v", value, k, values))
}
return
}
Expand Down

0 comments on commit 083d1d2

Please sign in to comment.