Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated validation funcs #333

Merged
merged 1 commit into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions helper/validation/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ package validation

import "fmt"

// ValidateListUniqueStrings is a ValidateFunc that ensures a list has no
// duplicate items in it. It's useful for when a list is needed over a set
// because order matters, yet the items still need to be unique.
//
// Deprecated: use ListOfUniqueStrings
func ValidateListUniqueStrings(i interface{}, k string) (warnings []string, errors []error) {
return ListOfUniqueStrings(i, k)
}

// ListOfUniqueStrings is a ValidateFunc that ensures a list has no
// duplicate items in it. It's useful for when a list is needed over a set
// because order matters, yet the items still need to be unique.
Expand Down
23 changes: 0 additions & 23 deletions helper/validation/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

// SingleIP returns a SchemaValidateFunc which tests if the provided value
// is of type string, and in valid single Value notation
//
// Deprecated: use IsIPAddress instead
func SingleIP() schema.SchemaValidateFunc {
return IsIPAddress
}

// IsIPAddress is a SchemaValidateFunc which tests if the provided value is of type string and is a single IP (v4 or v6)
func IsIPAddress(i interface{}, k string) (warnings []string, errors []error) {
v, ok := i.(string)
Expand Down Expand Up @@ -65,13 +57,6 @@ func IsIPv4Address(i interface{}, k string) (warnings []string, errors []error)
return warnings, errors
}

// IPRange returns a SchemaValidateFunc which tests if the provided value is of type string, and in valid IP range
//
// Deprecated: use IsIPv4Range instead
func IPRange() schema.SchemaValidateFunc {
return IsIPv4Range
}

// IsIPv4Range is a SchemaValidateFunc which tests if the provided value is of type string, and in valid IP range
func IsIPv4Range(i interface{}, k string) (warnings []string, errors []error) {
v, ok := i.(string)
Expand Down Expand Up @@ -110,14 +95,6 @@ func IsCIDR(i interface{}, k string) (warnings []string, errors []error) {
return warnings, errors
}

// CIDRNetwork returns a SchemaValidateFunc which tests if the provided value
// is of type string, is in valid Value network notation, and has significant bits between min and max (inclusive)
//
// Deprecated: use IsCIDRNetwork instead
func CIDRNetwork(min, max int) schema.SchemaValidateFunc {
return IsCIDRNetwork(min, max)
}

// IsCIDRNetwork returns a SchemaValidateFunc which tests if the provided value
// is of type string, is in valid Value network notation, and has significant bits between min and max (inclusive)
func IsCIDRNetwork(min, max int) schema.SchemaValidateFunc {
Expand Down
16 changes: 0 additions & 16 deletions helper/validation/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,6 @@ func StringIsBase64(i interface{}, k string) (warnings []string, errors []error)
return warnings, errors
}

// ValidateJsonString is a SchemaValidateFunc which tests to make sure the
// supplied string is valid JSON.
//
// Deprecated: use StringIsJSON instead
func ValidateJsonString(i interface{}, k string) (warnings []string, errors []error) {
return StringIsJSON(i, k)
}

// StringIsJSON is a SchemaValidateFunc which tests to make sure the supplied string is valid JSON.
func StringIsJSON(i interface{}, k string) (warnings []string, errors []error) {
v, ok := i.(string)
Expand All @@ -207,14 +199,6 @@ func StringIsJSON(i interface{}, k string) (warnings []string, errors []error) {
return warnings, errors
}

// ValidateRegexp returns a SchemaValidateFunc which tests to make sure the
// supplied string is a valid regular expression.
//
// Deprecated: use StringIsValidRegExp instead
func ValidateRegexp(i interface{}, k string) (warnings []string, errors []error) {
return StringIsValidRegExp(i, k)
}

// StringIsValidRegExp returns a SchemaValidateFunc which tests to make sure the supplied string is a valid regular expression.
func StringIsValidRegExp(i interface{}, k string) (warnings []string, errors []error) {
v, ok := i.(string)
Expand Down
12 changes: 6 additions & 6 deletions helper/validation/strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func TestValidationStringDoesNotMatch(t *testing.T) {
})
}

func TestValidateJsonString(t *testing.T) {
func TestStringIsJSON(t *testing.T) {
type testCases struct {
Value string
ErrCount int
Expand All @@ -369,7 +369,7 @@ func TestValidateJsonString(t *testing.T) {
}

for _, tc := range invalidCases {
_, errors := ValidateJsonString(tc.Value, "json")
_, errors := StringIsJSON(tc.Value, "json")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected %q to trigger a validation error.", tc.Value)
}
Expand All @@ -391,7 +391,7 @@ func TestValidateJsonString(t *testing.T) {
}

for _, tc := range validCases {
_, errors := ValidateJsonString(tc.Value, "json")
_, errors := StringIsJSON(tc.Value, "json")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected %q not to trigger a validation error.", tc.Value)
}
Expand Down Expand Up @@ -426,15 +426,15 @@ func TestStringDoesNotContainAny(t *testing.T) {
}
}

func TestValidationRegexp(t *testing.T) {
func TestStringIsValidRegExp(t *testing.T) {
runTestCases(t, []testCase{
{
val: ".*foo.*",
f: ValidateRegexp,
f: StringIsValidRegExp,
},
{
val: "foo(bar",
f: ValidateRegexp,
f: StringIsValidRegExp,
expectedErr: regexp.MustCompile(regexp.QuoteMeta("error parsing regexp: missing closing ): `foo(bar`")),
},
})
Expand Down
7 changes: 0 additions & 7 deletions helper/validation/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,3 @@ func IsRFC3339Time(i interface{}, k string) (warnings []string, errors []error)

return warnings, errors
}

// ValidateRFC3339TimeString is a ValidateFunc that ensures a string parses as time.RFC3339 format
//
// Deprecated: use IsRFC3339Time() instead
func ValidateRFC3339TimeString(i interface{}, k string) (warnings []string, errors []error) {
return IsRFC3339Time(i, k)
}
14 changes: 0 additions & 14 deletions internal/addrs/self.go

This file was deleted.