Skip to content

Commit

Permalink
Added validateDiagFunc wrapper function
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed Sep 28, 2020
1 parent d386621 commit 7471000
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions octopusdeploy/util.go
Expand Up @@ -12,6 +12,27 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

// wrapper function to be removed
func validateDiagFunc(validateFunc func(interface{}, string) ([]string, []error)) schema.SchemaValidateDiagFunc {
return func(i interface{}, path cty.Path) diag.Diagnostics {
warnings, errors := validateFunc(i, fmt.Sprintf("%+v", path))
var diags diag.Diagnostics
for _, warning := range warnings {
diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
Summary: warning,
})
}
for _, err := range errors {
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Summary: err.Error(),
})
}
return diags
}
}

// Validate a value against a set of possible values
func validateValueFunc(values []string) schema.SchemaValidateDiagFunc {

Expand Down

0 comments on commit 7471000

Please sign in to comment.