From ad8fd7b26a719e5944b83fef1baf0458c16eb58e Mon Sep 17 00:00:00 2001 From: Stoyan Zhelyazkov Date: Fri, 7 Mar 2025 10:52:42 +0200 Subject: [PATCH 1/4] [feat] Make tier0_name input optional for edge cluster creation Signed-off-by: Stoyan Zhelyazkov --- internal/provider/resource_edge_cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/provider/resource_edge_cluster.go b/internal/provider/resource_edge_cluster.go index 9fedff4..f76b587 100644 --- a/internal/provider/resource_edge_cluster.go +++ b/internal/provider/resource_edge_cluster.go @@ -65,7 +65,7 @@ func ResourceEdgeCluster() *schema.Resource { }, "tier0_name": { Type: schema.TypeString, - Required: true, + Optional: true, Description: "Name for the Tier-0 gateway", ValidateFunc: validation.NoZeroValues, }, From 223e72bc659e2cd4e7420760b24bd2cfe6e54a14 Mon Sep 17 00:00:00 2001 From: Stoyan Zhelyazkov Date: Fri, 7 Mar 2025 11:03:39 +0200 Subject: [PATCH 2/4] [feat] allow public ASNs for edge cluster creation Signed-off-by: Stoyan Zhelyazkov --- internal/validation/validation_utils.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/internal/validation/validation_utils.go b/internal/validation/validation_utils.go index f8eef4c..b9d48a9 100644 --- a/internal/validation/validation_utils.go +++ b/internal/validation/validation_utils.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "net/netip" + "slices" "strconv" "strings" "unicode" @@ -315,20 +316,18 @@ func IsEmpty(object interface{}) bool { } func ValidASN(v interface{}, k string) (ws []string, errors []error) { - value := v.(string) - - asn, err := strconv.ParseInt(value, 10, 64) + asn, err := strconv.ParseInt(v.(string), 10, 64) if err != nil { errors = append(errors, fmt.Errorf("%q (%q) must be a 64-bit integer", k, v)) return } - isLegacyAsn := func(a int64) bool { - return a == 7224 || a == 9059 || a == 10124 || a == 17493 - } + isLegacyAsn := slices.Contains([]int64{7224, 9059, 10124, 17493}, asn) + isPublicAsn := (asn >= 1 && asn <= 64495) || (asn >= 131072 && asn <= 4199999999) - if !isLegacyAsn(asn) && ((asn < 64512) || (asn > 65534 && asn < 4200000000) || (asn > 4294967294)) { - errors = append(errors, fmt.Errorf("%q (%q) must be 7224, 9059, 10124 or 17493 or in the range 64512 to 65534 or 4200000000 to 4294967294", k, v)) + if !isLegacyAsn && !isPublicAsn && ((asn < 64512) || (asn > 65534 && asn < 4200000000) || (asn > 4294967294)) { + errors = append(errors, fmt.Errorf("%q (%q) must be a legacy ASN, a non-private ASN, or in the range 64512 to 65534 or 4200000000 to 4294967294", k, v)) } + return } From af342ba84e1bfbef24b140635df7b5f8aab11586 Mon Sep 17 00:00:00 2001 From: Stoyan Zhelyazkov Date: Fri, 7 Mar 2025 11:18:37 +0200 Subject: [PATCH 3/4] [feat] Simplify ASN validation --- internal/provider/resource_edge_cluster_test.go | 2 -- internal/validation/validation_utils.go | 8 ++------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/internal/provider/resource_edge_cluster_test.go b/internal/provider/resource_edge_cluster_test.go index 363e433..a5896a6 100644 --- a/internal/provider/resource_edge_cluster_test.go +++ b/internal/provider/resource_edge_cluster_test.go @@ -75,8 +75,6 @@ func getEdgeClusterConfigFullInitial() string { root_password = %q admin_password = %q audit_password = %q - tier0_name = "T0_testCluster1" - tier1_name = "T1_testCluster1" form_factor = "MEDIUM" profile_type = "DEFAULT" routing_type = "EBGP" diff --git a/internal/validation/validation_utils.go b/internal/validation/validation_utils.go index b9d48a9..4b7d7f1 100644 --- a/internal/validation/validation_utils.go +++ b/internal/validation/validation_utils.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "net/netip" - "slices" "strconv" "strings" "unicode" @@ -322,11 +321,8 @@ func ValidASN(v interface{}, k string) (ws []string, errors []error) { return } - isLegacyAsn := slices.Contains([]int64{7224, 9059, 10124, 17493}, asn) - isPublicAsn := (asn >= 1 && asn <= 64495) || (asn >= 131072 && asn <= 4199999999) - - if !isLegacyAsn && !isPublicAsn && ((asn < 64512) || (asn > 65534 && asn < 4200000000) || (asn > 4294967294)) { - errors = append(errors, fmt.Errorf("%q (%q) must be a legacy ASN, a non-private ASN, or in the range 64512 to 65534 or 4200000000 to 4294967294", k, v)) + if asn < 1 || asn > 4294967294 { + errors = append(errors, fmt.Errorf("%q (%q) must be in the range 1 to 4294967294", k, v)) } return From e17af53df71664baac42daf96ad59135b3c7ec76 Mon Sep 17 00:00:00 2001 From: Stoyan Zhelyazkov Date: Fri, 7 Mar 2025 11:24:57 +0200 Subject: [PATCH 4/4] [feat] Update docs Signed-off-by: Stoyan Zhelyazkov --- docs/resources/edge_cluster.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/docs/resources/edge_cluster.md b/docs/resources/edge_cluster.md index 2968bca..2e94818 100644 --- a/docs/resources/edge_cluster.md +++ b/docs/resources/edge_cluster.md @@ -42,12 +42,10 @@ Review the documentation for VMware Cloud Foundation for more information about - `profile_type` (String) One among: DEFAULT, CUSTOM. If set to CUSTOM a 'profile' must be provided - `root_password` (String) Root user password for the NSX manager - `routing_type` (String) One among: EBGP, STATIC -- `tier0_name` (String) Name for the Tier-0 gateway ### Optional - `internal_transit_subnets` (List of String) Subnet addresses in CIDR notation that are used to assign addresses to logical links connecting service routers and distributed routers - - `profile` (Block List, Max: 1) The specification for the edge cluster profile (see [below for nested schema](#nestedblock--profile)) - `skip_tep_routability_check` (Boolean) Set to true to bypass normal ICMP-based check of Edge TEP / host TEP routability (default is false, meaning do check) - `tier1_name` (String) Name for the Tier-1 gateway @@ -60,7 +58,6 @@ Review the documentation for VMware Cloud Foundation for more information about - `id` (String) The ID of this resource. - ### Nested Schema for `edge_node` Required: @@ -79,16 +76,14 @@ Required: Optional: -- `compute_cluster_id` (String) The id of the compute cluster. You cannot specify a value for `compute_cluster_name` if you set this attribute. -- `compute_cluster_name` (String) The name of the compute cluster. You cannot specify a value for `compute_cluster_id` if you set this attribute. - +- `compute_cluster_id` (String) The id of the compute cluster +- `compute_cluster_name` (String) The name of the compute cluster - `first_nsx_vds_uplink` (String) The name of the first NSX-enabled VDS uplink - `management_network` (Block List, Max: 1) The management network which will be created for this node (see [below for nested schema](#nestedblock--edge_node--management_network)) - `second_nsx_vds_uplink` (String) The name of the second NSX-enabled VDS uplink - `uplink` (Block List) Specifications of Tier-0 uplinks for the edge node (see [below for nested schema](#nestedblock--edge_node--uplink)) - ### Nested Schema for `edge_node.management_network` Required: @@ -96,8 +91,8 @@ Required: - `portgroup_name` (String) The name of the portgroup - `vlan_id` (Number) The VLAN ID for the portgroup - + ### Nested Schema for `edge_node.uplink` Required: @@ -107,7 +102,6 @@ Required: - `vlan` (Number) The VLAN ID for the distributed switch uplink - ### Nested Schema for `edge_node.uplink.bgp_peer` Required: @@ -116,8 +110,10 @@ Required: - `ip` (String) IP address - `password` (String) Password - + + + ### Nested Schema for `profile` Required: @@ -128,8 +124,8 @@ Required: - `name` (String) The name of the profile - `standby_relocation_threshold` (Number) Standby relocation threshold - + ### Nested Schema for `timeouts` Optional: