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

refactor: clean up config package #480

Merged
merged 2 commits into from
Dec 11, 2023
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
2 changes: 1 addition & 1 deletion equinix/helpers_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func ipAddressSchema() *schema.Resource {
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringMatch(uuidRE, "must be a valid UUID"),
ValidateFunc: validation.IsUUID,
},
},
},
Expand Down
7 changes: 2 additions & 5 deletions equinix/resource_metal_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package equinix
import (
"fmt"
"path"
"regexp"
"strings"

equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors"
Expand All @@ -15,8 +14,6 @@ import (
"github.com/packethost/packngo"
)

var uuidRE = regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$")

func resourceMetalProject() *schema.Resource {
return &schema.Resource{
Create: resourceMetalProjectCreate,
Expand Down Expand Up @@ -57,7 +54,7 @@ func resourceMetalProject() *schema.Resource {
return strings.EqualFold(strings.Trim(old, `"`), strings.Trim(new, `"`))
},
ValidateFunc: validation.Any(
validation.StringMatch(uuidRE, "must be a valid UUID"),
validation.IsUUID,
validation.StringIsEmpty,
),
},
Expand All @@ -70,7 +67,7 @@ func resourceMetalProject() *schema.Resource {
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
return strings.EqualFold(strings.Trim(old, `"`), strings.Trim(new, `"`))
},
ValidateFunc: validation.StringMatch(uuidRE, "must be a valid UUID"),
ValidateFunc: validation.IsUUID,
},
"bgp_config": {
Type: schema.TypeList,
Expand Down
5 changes: 0 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ import (
xoauth2 "golang.org/x/oauth2"
)

var (
UuidRE = regexp.MustCompile("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$")
IpAddressTypes = []string{"public_ipv4", "private_ipv4", "public_ipv6"}
Copy link
Contributor Author

@ctreatma ctreatma Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see here that the ipAddressTypes private variable is declared in the Metal device resource and only used in device_helpers.go: https://github.com/search?q=repo%3Aequinix%2Fterraform-provider-equinix%20ipAddressTypes&type=code

You can see here that the ipAddressSchema function in device_helpers.go (which is the only place ipAddressTypes is used) is only called by the Metal device resource: https://github.com/search?q=repo%3Aequinix%2Fterraform-provider-equinix%20ipAddressSchema&type=code

When we get to moving the device resource into its own package we should move the ipAddressSchema function with it; I left it as-is for now to avoid making unnecessary changes in this PR.

)

type ProviderMeta struct {
ModuleName string `cty:"module_name"`
}
Expand Down
Loading