From 62d43b157811243423dae993a38ee5c8361a05d2 Mon Sep 17 00:00:00 2001 From: Mickael Stanislas Date: Thu, 6 Feb 2025 09:23:44 +0100 Subject: [PATCH] chore: rename alb to elb --- docs/data-sources/alb_pool.md | 64 --- docs/data-sources/alb_service_engine_group.md | 39 -- docs/data-sources/elb_service_engine_group.md | 39 ++ ...groups.md => elb_service_engine_groups.md} | 30 +- docs/resources/alb_pool.md | 121 ----- .../cloudavenue_alb_pool/data-source.tf | 4 - .../data-source.tf | 7 - .../data-source.tf | 6 +- .../data-source.tf | 7 + .../resources/cloudavenue_alb_pool/import.sh | 2 - .../cloudavenue_alb_pool/resource.tf | 48 -- internal/provider/alb/pool_common.go | 60 --- internal/provider/alb/pool_datasource.go | 177 ------- internal/provider/alb/pool_resource.go | 466 ------------------ internal/provider/alb/pool_schema.go | 291 ----------- internal/provider/alb/pool_types.go | 59 --- internal/provider/{alb => elb}/base.go | 9 +- .../service_engine_group_datasource.go | 6 +- .../service_engine_group_schema.go | 18 +- .../service_engine_group_schema_test.go | 6 +- .../service_engine_group_types.go | 2 +- .../service_engine_groups_datasource.go | 6 +- .../service_engine_groups_schema.go | 6 +- .../service_engine_groups_schema_test.go | 6 +- .../service_engine_groups_types.go | 2 +- internal/provider/provider_datasources.go | 9 +- internal/provider/provider_resources.go | 4 - internal/testsacc/alb_pool_datasource_test.go | 74 --- internal/testsacc/alb_pool_resource_test.go | 84 ---- ...b_service_engine_group_datasource_test.go} | 18 +- ..._service_engine_groups_datasource_test.go} | 6 +- templates/data-sources/alb_pool.md.tmpl | 25 - ....tmpl => elb_service_engine_group.md.tmpl} | 2 +- ...tmpl => elb_service_engine_groups.md.tmpl} | 2 +- templates/resources/alb_pool.md.tmpl | 25 - 35 files changed, 110 insertions(+), 1620 deletions(-) delete mode 100644 docs/data-sources/alb_pool.md delete mode 100644 docs/data-sources/alb_service_engine_group.md create mode 100644 docs/data-sources/elb_service_engine_group.md rename docs/data-sources/{alb_service_engine_groups.md => elb_service_engine_groups.md} (66%) delete mode 100644 docs/resources/alb_pool.md delete mode 100644 examples/data-sources/cloudavenue_alb_pool/data-source.tf delete mode 100644 examples/data-sources/cloudavenue_alb_service_engine_groups/data-source.tf rename examples/data-sources/{cloudavenue_alb_service_engine_group => cloudavenue_elb_service_engine_group}/data-source.tf (52%) create mode 100644 examples/data-sources/cloudavenue_elb_service_engine_groups/data-source.tf delete mode 100644 examples/resources/cloudavenue_alb_pool/import.sh delete mode 100644 examples/resources/cloudavenue_alb_pool/resource.tf delete mode 100644 internal/provider/alb/pool_common.go delete mode 100644 internal/provider/alb/pool_datasource.go delete mode 100644 internal/provider/alb/pool_resource.go delete mode 100644 internal/provider/alb/pool_schema.go delete mode 100644 internal/provider/alb/pool_types.go rename internal/provider/{alb => elb}/base.go (79%) rename internal/provider/{alb => elb}/service_engine_group_datasource.go (97%) rename internal/provider/{alb => elb}/service_engine_group_schema.go (83%) rename internal/provider/{alb => elb}/service_engine_group_schema_test.go (95%) rename internal/provider/{alb => elb}/service_engine_group_types.go (98%) rename internal/provider/{alb => elb}/service_engine_groups_datasource.go (97%) rename internal/provider/{alb => elb}/service_engine_groups_schema.go (95%) rename internal/provider/{alb => elb}/service_engine_groups_schema_test.go (91%) rename internal/provider/{alb => elb}/service_engine_groups_types.go (98%) delete mode 100644 internal/testsacc/alb_pool_datasource_test.go delete mode 100644 internal/testsacc/alb_pool_resource_test.go rename internal/testsacc/{alb_service_engine_group_datasource_test.go => edgegateway_lb_service_engine_group_datasource_test.go} (91%) rename internal/testsacc/{alb_service_engine_groups_datasource_test.go => edgegateway_lb_service_engine_groups_datasource_test.go} (96%) delete mode 100644 templates/data-sources/alb_pool.md.tmpl rename templates/data-sources/{alb_service_engine_groups.md.tmpl => elb_service_engine_group.md.tmpl} (86%) rename templates/data-sources/{alb_service_engine_group.md.tmpl => elb_service_engine_groups.md.tmpl} (86%) delete mode 100644 templates/resources/alb_pool.md.tmpl diff --git a/docs/data-sources/alb_pool.md b/docs/data-sources/alb_pool.md deleted file mode 100644 index 471793d7..00000000 --- a/docs/data-sources/alb_pool.md +++ /dev/null @@ -1,64 +0,0 @@ ---- -page_title: "cloudavenue_alb_pool Data Source - cloudavenue" -subcategory: "ALB (Advanced Load Balancer)" -description: |- - Provides a data source to manage Advanced Load Balancer Pools. Pools maintain the list of assigned servers and perform health monitoring, load balancing, and persistence. ---- - -# cloudavenue_alb_pool (Data Source) - -Provides a data source to manage Advanced Load Balancer Pools. Pools maintain the list of assigned servers and perform health monitoring, load balancing, and persistence. - -## Example Usage - -```terraform -data "cloudavenue_alb_pool" "example" { - edge_gateway_name = "MyEdgeGatewayName" - name = "MyAlbPoolName" -} -``` - - -## Schema - -### Required - -- `name` (String) Name of ALB Pool. - -### Optional - -- `edge_gateway_id` (String) Edge gateway ID in which ALB Pool was created. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. -- `edge_gateway_name` (String) Edge gateway Name in which ALB Pool was created. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. - -### Read-Only - -- `algorithm` (String) Algorithm for selecting members within a pool. -- `default_port` (Number) Destination server port used for traffic sent to a member. -- `description` (String) Description of ALB Pool. -- `enabled` (Boolean) Define if ALB Pool is enabled or not. -- `graceful_timeout_period` (Number) Maximum time in minutes allowed for gracefully disabling a pool member. -- `health_monitors` (Set of String) List of health monitors type to activate. -- `id` (String) ID of ALB Pool. -- `members` (Attributes Set) ALB Pool Member(s). (see [below for nested schema](#nestedatt--members)) -- `passive_monitoring_enabled` (Boolean) Monitors if the traffic is accepted by node. -- `persistence_profile` (Attributes) Persistence profile ensures that a user remains connected to the same server for a specified duration. If the persistence profile is unmanaged by Cloud Avenue, updates with unchanged values will continue using the same unmanaged profile. However, any changes to the persistence profile will prompt Cloud Avenue to switch the pool to a profile it manages. (see [below for nested schema](#nestedatt--persistence_profile)) - - -### Nested Schema for `members` - -Read-Only: - -- `enabled` (Boolean) Indicates whether a pool member accepts traffic. -- `ip_address` (String) IP address of a pool member. -- `port` (Number) Member port. -- `ratio` (Number) Ratio of selecting eligible servers in the pool. - - - -### Nested Schema for `persistence_profile` - -Read-Only: - -- `type` (String) Type of persistence strategy. -- `value` (String) Value of attribute based on persistence type. - diff --git a/docs/data-sources/alb_service_engine_group.md b/docs/data-sources/alb_service_engine_group.md deleted file mode 100644 index b70f2797..00000000 --- a/docs/data-sources/alb_service_engine_group.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -page_title: "cloudavenue_alb_service_engine_group Data Source - cloudavenue" -subcategory: "ALB (Advanced Load Balancer)" -description: |- - The cloudavenue_alb_service_engine_group data source allows you to retrieve information about an ALB Service Engine Group. ---- - -# cloudavenue_alb_service_engine_group (Data Source) - -The `cloudavenue_alb_service_engine_group` data source allows you to retrieve information about an ALB Service Engine Group. - -## Example Usage - -```terraform -data "cloudavenue_alb_service_engine_group" "example" { - name = "my-service-engine" - edge_gateway_name = data.cloudavenue_edge_gateway.example.name -} - -output "example" { - value = data.cloudavenue_alb_service_engine_group.example -} -``` - - -## Schema - -### Optional - -- `edge_gateway_id` (String) Edge gateway ID in which ALB Service Engine Group should be located. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. -- `edge_gateway_name` (String) Edge gateway Name in which ALB Service Engine Group should be located. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. -- `id` (String) The ID of the ALB Service Engine Group. Ensure that one and only one attribute from this collection is set : `id`, `name`. -- `name` (String) The name of the ALB Service Engine Group. Ensure that one and only one attribute from this collection is set : `id`, `name`. - -### Read-Only - -- `deployed_virtual_services` (Number) The number of deployed virtual services on the ALB Service Engine Group. -- `max_virtual_services` (Number) The maximum number of virtual services that can be deployed on the ALB Service Engine Group. -- `reserved_virtual_services` (Number) The number of reserved virtual services for the ALB Service Engine Group. diff --git a/docs/data-sources/elb_service_engine_group.md b/docs/data-sources/elb_service_engine_group.md new file mode 100644 index 00000000..acd7183c --- /dev/null +++ b/docs/data-sources/elb_service_engine_group.md @@ -0,0 +1,39 @@ +--- +page_title: "cloudavenue_elb_service_engine_group Data Source - cloudavenue" +subcategory: "ELB (EdgeGateway Load Balancer)" +description: |- + The cloudavenue_elb_service_engine_group data source allows you to retrieve information about an Service Engine Group of an Edge Gateway. +--- + +# cloudavenue_elb_service_engine_group (Data Source) + +The `cloudavenue_elb_service_engine_group` data source allows you to retrieve information about an Service Engine Group of an Edge Gateway. + +## Example Usage + +```terraform +data "cloudavenue_elb_service_engine_group" "example" { + name = "my-service-engine" + edge_gateway_name = data.cloudavenue_edge_gateway.example.name +} + +output "example" { + value = data.cloudavenue_elb_service_engine_group.example +} +``` + + +## Schema + +### Optional + +- `edge_gateway_id` (String) Edge gateway ID in which ELB Service Engine Group should be located. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. +- `edge_gateway_name` (String) Edge gateway Name in which ELB Service Engine Group should be located. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. +- `id` (String) The ID of the ELB Service Engine Group. Ensure that one and only one attribute from this collection is set : `id`, `name`. +- `name` (String) The name of the ELB Service Engine Group. Ensure that one and only one attribute from this collection is set : `id`, `name`. + +### Read-Only + +- `deployed_virtual_services` (Number) The number of deployed virtual services on the ELB Service Engine Group. +- `max_virtual_services` (Number) The maximum number of virtual services that can be deployed on the ELB Service Engine Group. +- `reserved_virtual_services` (Number) The number of reserved virtual services for the ELB Service Engine Group. diff --git a/docs/data-sources/alb_service_engine_groups.md b/docs/data-sources/elb_service_engine_groups.md similarity index 66% rename from docs/data-sources/alb_service_engine_groups.md rename to docs/data-sources/elb_service_engine_groups.md index 88da010d..69baccfb 100644 --- a/docs/data-sources/alb_service_engine_groups.md +++ b/docs/data-sources/elb_service_engine_groups.md @@ -1,23 +1,23 @@ --- -page_title: "cloudavenue_alb_service_engine_groups Data Source - cloudavenue" -subcategory: "ALB (Advanced Load Balancer)" +page_title: "cloudavenue_elb_service_engine_groups Data Source - cloudavenue" +subcategory: "ELB (EdgeGateway Load Balancer)" description: |- - The cloudavenue_alb_service_engine_groups data source allows you to retrieve information about all the Service Engine Group of an Edge Gateway. + The cloudavenue_elb_service_engine_groups data source allows you to retrieve information about all the Service Engine Group of an Edge Gateway. --- -# cloudavenue_alb_service_engine_groups (Data Source) +# cloudavenue_elb_service_engine_groups (Data Source) -The `cloudavenue_alb_service_engine_groups` data source allows you to retrieve information about all the Service Engine Group of an Edge Gateway. +The `cloudavenue_elb_service_engine_groups` data source allows you to retrieve information about all the Service Engine Group of an Edge Gateway. ## Example Usage ```terraform -data "cloudavenue_alb_service_engine_groups" "example" { +data "cloudavenue_elb_service_engine_groups" "example" { edge_gateway_name = data.cloudavenue_edge_gateway.example.name } output "example" { - value = data.cloudavenue_alb_service_engine_groups.example + value = data.cloudavenue_elb_service_engine_groups.example } ``` @@ -31,7 +31,7 @@ output "example" { ### Read-Only -- `id` (String) The ID of the service engine groups. +- `id` (String) The ID of the ELB service engine groups. - `service_engine_groups` (Attributes List) The list of service engine groups. (see [below for nested schema](#nestedatt--service_engine_groups)) @@ -39,13 +39,13 @@ output "example" { Optional: -- `edge_gateway_id` (String) Edge gateway ID in which ALB Service Engine Group should be located. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. -- `edge_gateway_name` (String) Edge gateway Name in which ALB Service Engine Group should be located. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. -- `id` (String) The ID of the ALB Service Engine Group. Ensure that one and only one attribute from this collection is set : `id`, `name`. -- `name` (String) The name of the ALB Service Engine Group. Ensure that one and only one attribute from this collection is set : `id`, `name`. +- `edge_gateway_id` (String) Edge gateway ID in which ELB Service Engine Group should be located. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. +- `edge_gateway_name` (String) Edge gateway Name in which ELB Service Engine Group should be located. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. +- `id` (String) The ID of the ELB Service Engine Group. Ensure that one and only one attribute from this collection is set : `id`, `name`. +- `name` (String) The name of the ELB Service Engine Group. Ensure that one and only one attribute from this collection is set : `id`, `name`. Read-Only: -- `deployed_virtual_services` (Number) The number of deployed virtual services on the ALB Service Engine Group. -- `max_virtual_services` (Number) The maximum number of virtual services that can be deployed on the ALB Service Engine Group. -- `reserved_virtual_services` (Number) The number of reserved virtual services for the ALB Service Engine Group. +- `deployed_virtual_services` (Number) The number of deployed virtual services on the ELB Service Engine Group. +- `max_virtual_services` (Number) The maximum number of virtual services that can be deployed on the ELB Service Engine Group. +- `reserved_virtual_services` (Number) The number of reserved virtual services for the ELB Service Engine Group. diff --git a/docs/resources/alb_pool.md b/docs/resources/alb_pool.md deleted file mode 100644 index 6e399014..00000000 --- a/docs/resources/alb_pool.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -page_title: "cloudavenue_alb_pool Resource - cloudavenue" -subcategory: "ALB (Advanced Load Balancer)" -description: |- - Provides a resource to manage Advanced Load Balancer Pools. Pools maintain the list of assigned servers and perform health monitoring, load balancing, and persistence. A pool may be used or referenced by only one virtual service at a time. ---- - -# cloudavenue_alb_pool (Resource) - -Provides a resource to manage Advanced Load Balancer Pools. Pools maintain the list of assigned servers and perform health monitoring, load balancing, and persistence. A pool may be used or referenced by only one virtual service at a time. - -## Example Usage - -```terraform -data "cloudavenue_tier0_vrfs" "example" {} - -resource "cloudavenue_edgegateway" "example" { - owner_name = "MyVDC" - tier0_vrf_name = data.cloudavenue_tier0_vrfs.example.names.0 - owner_type = "vdc" - lb_enabled = true -} - -resource "cloudavenue_alb_pool" "example" { - edge_gateway_name = cloudavenue_edgegateway.example.name - name = "Example" - - persistence_profile = { - type = "CLIENT_IP" - } - - members = [ - { - ip_address = "192.168.1.1" - port = "80" - }, - { - ip_address = "192.168.1.2" - port = "80" - }, - { - ip_address = "192.168.1.3" - port = "80" - } - ] - - health_monitors = ["UDP", "TCP"] -} - -data "cloudavenue_tier0_vrfs" "example" {} - -resource "cloudavenue_edgegateway" "example" { - owner_name = "MyVDC" - tier0_vrf_name = data.cloudavenue_tier0_vrfs.example.names.0 - owner_type = "vdc" - lb_enabled = true -} - -resource "cloudavenue_alb_pool" "example" { - edge_gateway_name = cloudavenue_edgegateway.example.name - name = "Example" -} -``` - - -## Schema - -### Required - -- `name` (String) Name of ALB Pool. - -### Optional - -- `algorithm` (String) Algorithm for selecting members within a pool. Value must be one of : `ROUND_ROBIN`, `CONSISTENT_HASH`, `LEAST_CONNECTIONS`. Value defaults to `LEAST_CONNECTIONS`. -- `default_port` (Number) Destination server port used for traffic sent to a member. Value must be between 1 and 65535. Value defaults to `80`. -- `description` (String) Description of ALB Pool. -- `edge_gateway_id` (String) (ForceNew) Edge gateway ID in which ALB Pool should be created. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. -- `edge_gateway_name` (String) (ForceNew) Edge gateway Name in which ALB Pool should be created. Ensure that one and only one attribute from this collection is set : `edge_gateway_id`, `edge_gateway_name`. -- `enabled` (Boolean) Define if ALB Pool is enabled or not. Value defaults to `true`. -- `graceful_timeout_period` (Number) Maximum time in minutes allowed for gracefully disabling a pool member. Value defaults to `1`. -- `health_monitors` (Set of String) List of health monitors type to activate. Element value must satisfy all validations: value must be one of: ["HTTP" "HTTPS" "TCP" "UDP" "PING"]. -- `members` (Attributes Set) ALB Pool Member(s). (see [below for nested schema](#nestedatt--members)) -- `passive_monitoring_enabled` (Boolean) Monitors if the traffic is accepted by node. Value defaults to `true`. -- `persistence_profile` (Attributes) Persistence profile ensures that a user remains connected to the same server for a specified duration. If the persistence profile is unmanaged by Cloud Avenue, updates with unchanged values will continue using the same unmanaged profile. However, any changes to the persistence profile will prompt Cloud Avenue to switch the pool to a profile it manages. (see [below for nested schema](#nestedatt--persistence_profile)) - -### Read-Only - -- `id` (String) ID of ALB Pool. - - -### Nested Schema for `members` - -Required: - -- `ip_address` (String) IP address of a pool member. Must be a valid IP with net.ParseIP. -- `port` (Number) Member port. Value must be between 1 and 65535. - -Optional: - -- `enabled` (Boolean) Indicates whether a pool member accepts traffic. Value defaults to `true`. -- `ratio` (Number) Ratio of selecting eligible servers in the pool. Value must be at least 1. Value defaults to `1`. - - - -### Nested Schema for `persistence_profile` - -Required: - -- `type` (String) Type of persistence strategy. Value must be one of : `CLIENT_IP`, `HTTP_COOKIE`. - -Optional: - -- `value` (String) Value of attribute based on persistence type. If the value of [`persistence_profile.type`](#persistence_profile.type) attribute is `HTTP_COOKIE` this attribute is **REQUIRED**. - -## Import - -Import is supported using the following syntax: -```shell -# use the edge_gateway_name.alb_pool_name to import the ALB Pool -terraform import cloudavenue_alb_pool.test edge_gateway_name.alb_pool_name -``` \ No newline at end of file diff --git a/examples/data-sources/cloudavenue_alb_pool/data-source.tf b/examples/data-sources/cloudavenue_alb_pool/data-source.tf deleted file mode 100644 index b8ea64bf..00000000 --- a/examples/data-sources/cloudavenue_alb_pool/data-source.tf +++ /dev/null @@ -1,4 +0,0 @@ -data "cloudavenue_alb_pool" "example" { - edge_gateway_name = "MyEdgeGatewayName" - name = "MyAlbPoolName" -} diff --git a/examples/data-sources/cloudavenue_alb_service_engine_groups/data-source.tf b/examples/data-sources/cloudavenue_alb_service_engine_groups/data-source.tf deleted file mode 100644 index f0ed2baa..00000000 --- a/examples/data-sources/cloudavenue_alb_service_engine_groups/data-source.tf +++ /dev/null @@ -1,7 +0,0 @@ -data "cloudavenue_alb_service_engine_groups" "example" { - edge_gateway_name = data.cloudavenue_edge_gateway.example.name -} - -output "example" { - value = data.cloudavenue_alb_service_engine_groups.example -} \ No newline at end of file diff --git a/examples/data-sources/cloudavenue_alb_service_engine_group/data-source.tf b/examples/data-sources/cloudavenue_elb_service_engine_group/data-source.tf similarity index 52% rename from examples/data-sources/cloudavenue_alb_service_engine_group/data-source.tf rename to examples/data-sources/cloudavenue_elb_service_engine_group/data-source.tf index f63b9228..741f1001 100644 --- a/examples/data-sources/cloudavenue_alb_service_engine_group/data-source.tf +++ b/examples/data-sources/cloudavenue_elb_service_engine_group/data-source.tf @@ -1,8 +1,8 @@ -data "cloudavenue_alb_service_engine_group" "example" { +data "cloudavenue_elb_service_engine_group" "example" { name = "my-service-engine" edge_gateway_name = data.cloudavenue_edge_gateway.example.name } output "example" { - value = data.cloudavenue_alb_service_engine_group.example -} \ No newline at end of file + value = data.cloudavenue_elb_service_engine_group.example +} diff --git a/examples/data-sources/cloudavenue_elb_service_engine_groups/data-source.tf b/examples/data-sources/cloudavenue_elb_service_engine_groups/data-source.tf new file mode 100644 index 00000000..7e9bdea4 --- /dev/null +++ b/examples/data-sources/cloudavenue_elb_service_engine_groups/data-source.tf @@ -0,0 +1,7 @@ +data "cloudavenue_elb_service_engine_groups" "example" { + edge_gateway_name = data.cloudavenue_edge_gateway.example.name +} + +output "example" { + value = data.cloudavenue_elb_service_engine_groups.example +} diff --git a/examples/resources/cloudavenue_alb_pool/import.sh b/examples/resources/cloudavenue_alb_pool/import.sh deleted file mode 100644 index 35fd627f..00000000 --- a/examples/resources/cloudavenue_alb_pool/import.sh +++ /dev/null @@ -1,2 +0,0 @@ -# use the edge_gateway_name.alb_pool_name to import the ALB Pool -terraform import cloudavenue_alb_pool.test edge_gateway_name.alb_pool_name \ No newline at end of file diff --git a/examples/resources/cloudavenue_alb_pool/resource.tf b/examples/resources/cloudavenue_alb_pool/resource.tf deleted file mode 100644 index 3b38630a..00000000 --- a/examples/resources/cloudavenue_alb_pool/resource.tf +++ /dev/null @@ -1,48 +0,0 @@ -data "cloudavenue_tier0_vrfs" "example" {} - -resource "cloudavenue_edgegateway" "example" { - owner_name = "MyVDC" - tier0_vrf_name = data.cloudavenue_tier0_vrfs.example.names.0 - owner_type = "vdc" - lb_enabled = true -} - -resource "cloudavenue_alb_pool" "example" { - edge_gateway_name = cloudavenue_edgegateway.example.name - name = "Example" - - persistence_profile = { - type = "CLIENT_IP" - } - - members = [ - { - ip_address = "192.168.1.1" - port = "80" - }, - { - ip_address = "192.168.1.2" - port = "80" - }, - { - ip_address = "192.168.1.3" - port = "80" - } - ] - - health_monitors = ["UDP", "TCP"] -} - -data "cloudavenue_tier0_vrfs" "example" {} - -resource "cloudavenue_edgegateway" "example" { - owner_name = "MyVDC" - tier0_vrf_name = data.cloudavenue_tier0_vrfs.example.names.0 - owner_type = "vdc" - lb_enabled = true -} - -resource "cloudavenue_alb_pool" "example" { - edge_gateway_name = cloudavenue_edgegateway.example.name - name = "Example" -} \ No newline at end of file diff --git a/internal/provider/alb/pool_common.go b/internal/provider/alb/pool_common.go deleted file mode 100644 index 5db69016..00000000 --- a/internal/provider/alb/pool_common.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2025 Orange - * SPDX-License-Identifier: Mozilla Public License 2.0 - * - * This software is distributed under the MPL-2.0 license. - * the text of which is available at https://www.mozilla.org/en-US/MPL/2.0/ - * or see the "LICENSE" file for more details. - */ - -package alb - -import ( - "errors" - - "github.com/vmware/go-vcloud-director/v2/govcd" - govcdtypes "github.com/vmware/go-vcloud-director/v2/types/v56" - - "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" -) - -var ErrPersistenceProfileIsEmpty = errors.New("persistence profile is empty") - -type albPool interface { - GetID() string - GetName() string - GetAlbPool() (*govcd.NsxtAlbPool, error) -} - -func processMembers(poolMembers []govcdtypes.NsxtAlbPoolMember) (members []member) { - for _, poolMember := range poolMembers { - members = append(members, member{ - Enabled: types.BoolValue(poolMember.Enabled), - IPAddress: types.StringValue(poolMember.IpAddress), - Port: types.Int64Value(int64(poolMember.Port)), - Ratio: types.Int64Value(int64(*poolMember.Ratio)), - }) - } - return -} - -func processHealthMonitors(poolHealthMonitors []govcdtypes.NsxtAlbPoolHealthMonitor) (healthMonitors []string) { - for _, poolHealthMonitor := range poolHealthMonitors { - healthMonitors = append(healthMonitors, poolHealthMonitor.Type) - } - - return -} - -func processPersistenceProfile(poolPersistenceProfile *govcdtypes.NsxtAlbPoolPersistenceProfile) persistenceProfile { - if poolPersistenceProfile == nil { - return persistenceProfile{} - } - - return persistenceProfile{ - Type: types.StringValue(poolPersistenceProfile.Type), - Value: utils.StringValueOrNull(poolPersistenceProfile.Value), - } -} diff --git a/internal/provider/alb/pool_datasource.go b/internal/provider/alb/pool_datasource.go deleted file mode 100644 index 8b327be8..00000000 --- a/internal/provider/alb/pool_datasource.go +++ /dev/null @@ -1,177 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2025 Orange - * SPDX-License-Identifier: Mozilla Public License 2.0 - * - * This software is distributed under the MPL-2.0 license. - * the text of which is available at https://www.mozilla.org/en-US/MPL/2.0/ - * or see the "LICENSE" file for more details. - */ - -// Package alb provides a Terraform datasource. -package alb - -import ( - "context" - "fmt" - - "github.com/vmware/go-vcloud-director/v2/govcd" - - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/hashicorp/terraform-plugin-framework/datasource" - - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" -) - -var ( - _ datasource.DataSource = &albPoolDataSource{} - _ datasource.DataSourceWithConfigure = &albPoolDataSource{} - _ albPool = &albPoolDataSource{} -) - -func NewAlbPoolDataSource() datasource.DataSource { - return &albPoolDataSource{} -} - -type albPoolDataSource struct { - client *client.CloudAvenue - org org.Org - edgegw edgegw.BaseEdgeGW - albPool base -} - -func (d *albPoolDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_" + categoryName + "_pool" -} - -func (d *albPoolDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = albPoolSchema().GetDataSource(ctx) -} - -func (d *albPoolDataSource) Init(ctx context.Context, dm *albPoolModel) (diags diag.Diagnostics) { - d.albPool = base{ - name: dm.Name.ValueString(), - id: dm.ID.ValueString(), - } - - d.edgegw = edgegw.BaseEdgeGW{ - ID: dm.EdgeGatewayID, - Name: dm.EdgeGatewayName, - } - - d.org, diags = org.Init(d.client) - return -} - -func (d *albPoolDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*client.CloudAvenue) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected Data Source Configure Type", - fmt.Sprintf("Expected *client.CloudAvenue, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - d.client = client -} - -func (d *albPoolDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - defer metrics.New("data.cloudavenue_alb_pool", d.client.GetOrgName(), metrics.Read)() - - var ( - data *albPoolModel - diags diag.Diagnostics - ) - // Read Terraform configuration data into the model - resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(d.Init(ctx, data)...) - if resp.Diagnostics.HasError() { - return - } - - // Get albPool. - albPool, err := d.GetAlbPool() - if err != nil { - resp.Diagnostics.AddError("Unable to find ALB Pool", err.Error()) - return - } - - // Set data - data.ID = types.StringValue(albPool.NsxtAlbPool.ID) - data.Description = types.StringValue(albPool.NsxtAlbPool.Description) - data.Enabled = types.BoolValue(*albPool.NsxtAlbPool.Enabled) - data.Algorithm = types.StringValue(albPool.NsxtAlbPool.Algorithm) - data.DefaultPort = types.Int64Value(int64(*albPool.NsxtAlbPool.DefaultPort)) - data.GracefulTimeoutPeriod = types.Int64Value(int64(*albPool.NsxtAlbPool.GracefulTimeoutPeriod)) - data.PassiveMonitoringEnabled = types.BoolValue(*albPool.NsxtAlbPool.PassiveMonitoringEnabled) - - // Set members - members := processMembers(albPool.NsxtAlbPool.Members) - - data.Members, diags = types.SetValueFrom(ctx, types.ObjectType{AttrTypes: memberAttrTypes}, members) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - // Set health monitors. - healthMonitors := processHealthMonitors(albPool.NsxtAlbPool.HealthMonitors) - - data.HealthMonitors, diags = types.SetValueFrom(ctx, types.StringType, healthMonitors) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - // Set persistence profile - p := processPersistenceProfile(albPool.NsxtAlbPool.PersistenceProfile) - - data.PersistenceProfile, diags = types.ObjectValueFrom(ctx, persistenceProfileAttrTypes, p) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - // Save data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -// GetID returns the ID of the albPool. -func (d *albPoolDataSource) GetID() string { - return d.albPool.id -} - -// GetName returns the name of the albPool. -func (d *albPoolDataSource) GetName() string { - return d.albPool.name -} - -// GetAlbPool returns the govcd.NsxtAlbPool. -func (d *albPoolDataSource) GetAlbPool() (*govcd.NsxtAlbPool, error) { - if d.GetID() != "" { - return d.client.Vmware.GetAlbPoolById(d.GetID()) - } - - nsxtEdge, err := d.org.GetEdgeGateway(d.edgegw) - if err != nil { - return nil, fmt.Errorf("could not retrieve Edge gateway '%s'", d.edgegw.GetIDOrName()) - } - return d.client.Vmware.GetAlbPoolByName(nsxtEdge.GetID(), d.GetName()) -} diff --git a/internal/provider/alb/pool_resource.go b/internal/provider/alb/pool_resource.go deleted file mode 100644 index 6ed7c4e6..00000000 --- a/internal/provider/alb/pool_resource.go +++ /dev/null @@ -1,466 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2025 Orange - * SPDX-License-Identifier: Mozilla Public License 2.0 - * - * This software is distributed under the MPL-2.0 license. - * the text of which is available at https://www.mozilla.org/en-US/MPL/2.0/ - * or see the "LICENSE" file for more details. - */ - -// Package alb provides a Terraform resource. -package alb - -import ( - "context" - "errors" - "fmt" - "strings" - - "github.com/vmware/go-vcloud-director/v2/govcd" - govcdtypes "github.com/vmware/go-vcloud-director/v2/types/v56" - - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - - "github.com/hashicorp/terraform-plugin-framework/resource" - - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/edgegw" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/org" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/pkg/utils" -) - -// Ensure the implementation satisfies the expected interfaces. -var ( - _ resource.Resource = &albPoolResource{} - _ resource.ResourceWithConfigure = &albPoolResource{} - _ resource.ResourceWithImportState = &albPoolResource{} - _ albPool = &albPoolResource{} -) - -// NewAlbPoolResource is a helper function to simplify the provider implementation. -func NewAlbPoolResource() resource.Resource { - return &albPoolResource{} -} - -// albPoolResource is the resource implementation. -type albPoolResource struct { - client *client.CloudAvenue - org org.Org - edgegw edgegw.BaseEdgeGW - albPool base -} - -// Metadata returns the resource type name. -func (r *albPoolResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_" + categoryName + "_pool" -} - -// Schema defines the schema for the resource. -func (r *albPoolResource) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = albPoolSchema().GetResource(ctx) -} - -func (r *albPoolResource) Init(ctx context.Context, rm *albPoolModel) (diags diag.Diagnostics) { - r.albPool = base{ - name: rm.Name.ValueString(), - id: rm.ID.ValueString(), - } - - r.edgegw = edgegw.BaseEdgeGW{ - ID: rm.EdgeGatewayID, - Name: rm.EdgeGatewayName, - } - - r.org, diags = org.Init(r.client) - return -} - -func (r *albPoolResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - // Prevent panic if the provider has not been configured. - if req.ProviderData == nil { - return - } - - client, ok := req.ProviderData.(*client.CloudAvenue) - - if !ok { - resp.Diagnostics.AddError( - "Unexpected Resource Configure Type", - fmt.Sprintf("Expected *client.CloudAvenue, got: %T. Please report this issue to the provider developers.", req.ProviderData), - ) - - return - } - - r.client = client -} - -// Create creates the resource and sets the initial Terraform state. -func (r *albPoolResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - defer metrics.New("cloudavenue_alb_pool", r.client.GetOrgName(), metrics.Create)() - - // Retrieve values from plan - var ( - plan *albPoolModel - ) - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - // Init - resp.Diagnostics.Append(r.Init(ctx, plan)...) - if resp.Diagnostics.HasError() { - return - } - - // Prepare config. - albPoolConfig, err := r.getAlbPoolConfig(ctx, plan) - if err != nil { - resp.Diagnostics.AddError("Unable to prepare ALB Pool Config", err.Error()) - return - } - - // Lock EdgeGW - edgeGW, err := r.org.GetEdgeGateway(r.edgegw) - if err != nil { - resp.Diagnostics.AddError("Unable to get Edge Gateway", err.Error()) - return - } - edgeGW.Lock(ctx) - defer edgeGW.Unlock(ctx) - - // Create ALB Pool - createdAlbPool, err := r.client.Vmware.CreateNsxtAlbPool(albPoolConfig) - if err != nil { - resp.Diagnostics.AddError("Unable to create ALB Pool", err.Error()) - return - } - - // Store ID - plan.ID = utils.StringValueOrNull(createdAlbPool.NsxtAlbPool.ID) - - // Set state to fully populated data - resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) -} - -// Read refreshes the Terraform state with the latest data. -func (r *albPoolResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - defer metrics.New("cloudavenue_alb_pool", r.client.GetOrgName(), metrics.Read)() - - var ( - state *albPoolModel - diags diag.Diagnostics - ) - - // Get current state - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(r.Init(ctx, state)...) - if resp.Diagnostics.HasError() { - return - } - - // Get albPool. - albPool, err := r.GetAlbPool() - if err != nil { - if govcd.ContainsNotFound(err) { - resp.State.RemoveResource(ctx) - return - } - - resp.Diagnostics.AddError("Unable to find ALB Pool", err.Error()) - return - } - - // Set data - plan := &albPoolModel{ - ID: utils.StringValueOrNull(albPool.NsxtAlbPool.ID), - Name: state.Name, - Description: utils.StringValueOrNull(albPool.NsxtAlbPool.Description), - EdgeGatewayID: state.EdgeGatewayID, - EdgeGatewayName: state.EdgeGatewayName, - Enabled: types.BoolValue(*albPool.NsxtAlbPool.Enabled), - Algorithm: utils.StringValueOrNull(albPool.NsxtAlbPool.Algorithm), - DefaultPort: types.Int64Value(int64(*albPool.NsxtAlbPool.DefaultPort)), - GracefulTimeoutPeriod: types.Int64Value(int64(*albPool.NsxtAlbPool.GracefulTimeoutPeriod)), - PassiveMonitoringEnabled: types.BoolValue(*albPool.NsxtAlbPool.PassiveMonitoringEnabled), - Members: types.SetNull(types.ObjectType{AttrTypes: memberAttrTypes}), - HealthMonitors: types.SetNull(types.StringType), - PersistenceProfile: types.ObjectNull(persistenceProfileAttrTypes), - } - - // Set members - if members := processMembers(albPool.NsxtAlbPool.Members); len(members) > 0 { - plan.Members, diags = types.SetValueFrom(ctx, types.ObjectType{AttrTypes: memberAttrTypes}, members) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - } - - // Set health monitors. - healthMonitors := processHealthMonitors(albPool.NsxtAlbPool.HealthMonitors) - - if len(healthMonitors) > 0 { - plan.HealthMonitors, diags = types.SetValueFrom(ctx, types.StringType, healthMonitors) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - } - - // Set persistence profile - p := processPersistenceProfile(albPool.NsxtAlbPool.PersistenceProfile) - - if p != (persistenceProfile{}) { - plan.PersistenceProfile, diags = types.ObjectValueFrom(ctx, persistenceProfileAttrTypes, p) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - } - - // Set refreshed state - resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) -} - -// Update updates the resource and sets the updated Terraform state on success. -func (r *albPoolResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - defer metrics.New("cloudavenue_alb_pool", r.client.GetOrgName(), metrics.Update)() - - var plan *albPoolModel - - // Get current state - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - // Init - resp.Diagnostics.Append(r.Init(ctx, plan)...) - if resp.Diagnostics.HasError() { - return - } - - // Get albPool - albPool, err := r.GetAlbPool() - if err != nil { - resp.Diagnostics.AddError("Unable to find ALB Pool", err.Error()) - return - } - - // Prepare config. - albPoolConfig, err := r.getAlbPoolConfig(ctx, plan) - if err != nil { - resp.Diagnostics.AddError("Unable to prepare ALB Pool Config", err.Error()) - return - } - - // Lock EdgeGW - edgeGW, err := r.org.GetEdgeGateway(r.edgegw) - if err != nil { - resp.Diagnostics.AddError("Unable to get Edge Gateway", err.Error()) - return - } - edgeGW.Lock(ctx) - defer edgeGW.Unlock(ctx) - - // Update ALB Pool. - _, err = albPool.Update(albPoolConfig) - if err != nil { - resp.Diagnostics.AddError("Unable to update ALB Pool", err.Error()) - return - } - - // Set state to fully populated data - resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) -} - -// Delete deletes the resource and removes the Terraform state on success. -func (r *albPoolResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - defer metrics.New("cloudavenue_alb_pool", r.client.GetOrgName(), metrics.Delete)() - - var state *albPoolModel - - // Get current state - resp.Diagnostics.Append(req.State.Get(ctx, &state)...) - if resp.Diagnostics.HasError() { - return - } - - // Init - resp.Diagnostics.Append(r.Init(ctx, state)...) - if resp.Diagnostics.HasError() { - return - } - - // Lock EdgeGW - edgeGW, err := r.org.GetEdgeGateway(r.edgegw) - if err != nil { - resp.Diagnostics.AddError("Unable to get Edge Gateway", err.Error()) - return - } - edgeGW.Lock(ctx) - defer edgeGW.Unlock(ctx) - - // Get albPool - albPool, err := r.GetAlbPool() - if err != nil { - resp.Diagnostics.AddError("Unable to find ALB Pool", err.Error()) - return - } - - err = albPool.Delete() - if err != nil { - resp.Diagnostics.AddError("Unable to delete ALB Pool", err.Error()) - return - } -} - -func (r *albPoolResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - defer metrics.New("cloudavenue_alb_pool", r.client.GetOrgName(), metrics.Import)() - - idParts := strings.Split(req.ID, ".") - - if len(idParts) != 2 { - resp.Diagnostics.AddError( - "Unexpected Import Identifier", - fmt.Sprintf("Expected import identifier with format: edge_gateway_name.alb_pool_name. Got: %q", req.ID), - ) - return - } - - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("edge_gateway_name"), idParts[0])...) - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), idParts[1])...) -} - -// GetID returns the ID of the albPool. -func (r *albPoolResource) GetID() string { - return r.albPool.id -} - -// GetName returns the name of the albPool. -func (r *albPoolResource) GetName() string { - return r.albPool.name -} - -// GetAlbPool returns the govcd.NsxtAlbPool. -func (r *albPoolResource) GetAlbPool() (*govcd.NsxtAlbPool, error) { - if r.GetID() != "" { - return r.client.Vmware.GetAlbPoolById(r.GetID()) - } - - nsxtEdge, err := r.org.GetEdgeGateway(r.edgegw) - if err != nil { - return nil, fmt.Errorf("could not retrieve Edge gateway '%s'", r.edgegw.GetIDOrName()) - } - return r.client.Vmware.GetAlbPoolByName(nsxtEdge.EdgeGateway.ID, r.GetName()) -} - -// getAlbPoolConfig is the main function for getting *govcdtypes.NsxtAlbPool for API request. It nests multiple smaller -// functions for smaller types. -func (r *albPoolResource) getAlbPoolConfig(ctx context.Context, d *albPoolModel) (*govcdtypes.NsxtAlbPool, error) { - edge, err := r.org.GetEdgeGateway(r.edgegw) - if err != nil { - return nil, err - } - - albPoolConfig := &govcdtypes.NsxtAlbPool{ - ID: r.GetID(), - Name: d.Name.ValueString(), - Description: d.Description.ValueString(), - Enabled: d.Enabled.ValueBoolPointer(), - GatewayRef: govcdtypes.OpenApiReference{ - ID: edge.GetID(), - }, - Algorithm: d.Algorithm.ValueString(), - DefaultPort: utils.TakeIntPointer(int(d.DefaultPort.ValueInt64())), - GracefulTimeoutPeriod: utils.TakeIntPointer(int(d.GracefulTimeoutPeriod.ValueInt64())), - PassiveMonitoringEnabled: d.PassiveMonitoringEnabled.ValueBoolPointer(), - } - - poolMembers, err := r.getAlbPoolMembersType(ctx, d) - if err != nil { - return nil, fmt.Errorf("error defining pool members: %w", err) - } - albPoolConfig.Members = poolMembers - - persistenceProfile, err := r.getAlbPoolPersistenceProfileType(ctx, d) - if err != nil && !errors.Is(err, ErrPersistenceProfileIsEmpty) { - return nil, fmt.Errorf("error defining persistence profile: %w", err) - } - albPoolConfig.PersistenceProfile = persistenceProfile - - healthMonitors, err := r.getAlbPoolHealthMonitorType(ctx, d) - if err != nil { - return nil, fmt.Errorf("error defining health monitors: %w", err) - } - albPoolConfig.HealthMonitors = healthMonitors - - return albPoolConfig, nil -} - -// getAlbPoolMembersType. -func (r *albPoolResource) getAlbPoolMembersType(ctx context.Context, d *albPoolModel) ([]govcdtypes.NsxtAlbPoolMember, error) { - var members []member - diags := d.Members.ElementsAs(ctx, &members, true) - if diags.HasError() { - return nil, errors.New(diags[0].Detail()) - } - memberSlice := make([]govcdtypes.NsxtAlbPoolMember, 0) - for _, memberDefinition := range members { - memberSlice = append(memberSlice, govcdtypes.NsxtAlbPoolMember{ - Enabled: memberDefinition.Enabled.ValueBool(), - IpAddress: memberDefinition.IPAddress.ValueString(), - Ratio: utils.TakeIntPointer(int(memberDefinition.Ratio.ValueInt64())), - Port: int(memberDefinition.Port.ValueInt64()), - }) - } - return memberSlice, nil -} - -// getAlbPoolPersistenceProfileType. -func (r *albPoolResource) getAlbPoolPersistenceProfileType(ctx context.Context, d *albPoolModel) (*govcdtypes.NsxtAlbPoolPersistenceProfile, error) { - if d.PersistenceProfile.IsNull() { - return nil, ErrPersistenceProfileIsEmpty - } - - p := &persistenceProfile{} - if diags := d.PersistenceProfile.As(ctx, p, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: false, - UnhandledUnknownAsEmpty: false, - }); diags.HasError() { - return nil, errors.New(diags[0].Detail()) - } - - return &govcdtypes.NsxtAlbPoolPersistenceProfile{ - Type: p.Type.ValueString(), - Value: p.Value.ValueString(), - }, nil -} - -// getAlbPoolHealthMonitorType. -func (r *albPoolResource) getAlbPoolHealthMonitorType(ctx context.Context, d *albPoolModel) (healthMonitors []govcdtypes.NsxtAlbPoolHealthMonitor, err error) { - var healthMonitorsSlice []string - - if diags := d.HealthMonitors.ElementsAs(ctx, &healthMonitorsSlice, true); diags.HasError() { - return nil, errors.New(diags[0].Detail()) - } - - for _, healthMonitor := range healthMonitorsSlice { - healthMonitors = append(healthMonitors, govcdtypes.NsxtAlbPoolHealthMonitor{ - Type: healthMonitor, - }) - } - - return -} diff --git a/internal/provider/alb/pool_schema.go b/internal/provider/alb/pool_schema.go deleted file mode 100644 index eb309c4c..00000000 --- a/internal/provider/alb/pool_schema.go +++ /dev/null @@ -1,291 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2025 Orange - * SPDX-License-Identifier: Mozilla Public License 2.0 - * - * This software is distributed under the MPL-2.0 license. - * the text of which is available at https://www.mozilla.org/en-US/MPL/2.0/ - * or see the "LICENSE" file for more details. - */ - -package alb - -import ( - superschema "github.com/orange-cloudavenue/terraform-plugin-framework-superschema" - fstringvalidator "github.com/orange-cloudavenue/terraform-plugin-framework-validators/stringvalidator" - - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" - - schemaD "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - schemaR "github.com/hashicorp/terraform-plugin-framework/resource/schema" - - "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64default" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - - "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" - "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" -) - -/* -albPoolSchema - -This function is used to create the schema for the ALB Pool resource and datasource. -*/ -func albPoolSchema() superschema.Schema { - return superschema.Schema{ - Resource: superschema.SchemaDetails{ - MarkdownDescription: "Provides a resource to manage Advanced Load Balancer Pools. Pools maintain the list of assigned servers and perform health monitoring, load balancing, and persistence. A pool may be used or referenced by only one virtual service at a time.", - }, - DataSource: superschema.SchemaDetails{ - MarkdownDescription: "Provides a data source to manage Advanced Load Balancer Pools. Pools maintain the list of assigned servers and perform health monitoring, load balancing, and persistence.", - }, - Attributes: map[string]superschema.Attribute{ - "id": superschema.StringAttribute{ - Common: &schemaR.StringAttribute{ - MarkdownDescription: "ID of ALB Pool.", - Computed: true, - }, - Resource: &schemaR.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - }, - "name": superschema.StringAttribute{ - Common: &schemaR.StringAttribute{ - MarkdownDescription: "Name of ALB Pool.", - Required: true, - }, - }, - "edge_gateway_id": superschema.StringAttribute{ - Common: &schemaR.StringAttribute{ - MarkdownDescription: "Edge gateway ID in which ALB Pool", - Optional: true, - Validators: []validator.String{ - stringvalidator.ExactlyOneOf(path.MatchRoot("edge_gateway_id"), path.MatchRoot("edge_gateway_name")), - }, - }, - Resource: &schemaR.StringAttribute{ - MarkdownDescription: "should be created.", - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - DataSource: &schemaD.StringAttribute{ - MarkdownDescription: "was created.", - }, - }, - "edge_gateway_name": superschema.StringAttribute{ - Common: &schemaR.StringAttribute{ - MarkdownDescription: "Edge gateway Name in which ALB Pool", - Optional: true, - Validators: []validator.String{ - stringvalidator.ExactlyOneOf(path.MatchRoot("edge_gateway_id"), path.MatchRoot("edge_gateway_name")), - }, - }, - Resource: &schemaR.StringAttribute{ - MarkdownDescription: "should be created.", - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - DataSource: &schemaD.StringAttribute{ - MarkdownDescription: "was created.", - }, - }, - "enabled": superschema.BoolAttribute{ - Common: &schemaR.BoolAttribute{ - MarkdownDescription: "Define if ALB Pool is enabled or not.", - Computed: true, - }, - Resource: &schemaR.BoolAttribute{ - Optional: true, - Default: booldefault.StaticBool(true), - }, - }, - "description": superschema.StringAttribute{ - Common: &schemaR.StringAttribute{ - MarkdownDescription: "Description of ALB Pool.", - }, - Resource: &schemaR.StringAttribute{ - Optional: true, - }, - DataSource: &schemaD.StringAttribute{ - Computed: true, - }, - }, - "algorithm": superschema.StringAttribute{ - Common: &schemaR.StringAttribute{ - MarkdownDescription: "Algorithm for selecting members within a pool.", - Computed: true, - }, - Resource: &schemaR.StringAttribute{ - Optional: true, - Default: stringdefault.StaticString("LEAST_CONNECTIONS"), - Validators: []validator.String{ - stringvalidator.OneOf("ROUND_ROBIN", "CONSISTENT_HASH", "LEAST_CONNECTIONS"), - }, - }, - }, - "default_port": superschema.Int64Attribute{ - Common: &schemaR.Int64Attribute{ - MarkdownDescription: "Destination server port used for traffic sent to a member.", - Computed: true, - }, - Resource: &schemaR.Int64Attribute{ - Optional: true, - Default: int64default.StaticInt64(80), - Validators: []validator.Int64{ - int64validator.Between(1, 65535), - }, - }, - }, - "graceful_timeout_period": superschema.Int64Attribute{ - Common: &schemaR.Int64Attribute{ - MarkdownDescription: "Maximum time in minutes allowed for gracefully disabling a pool member.", - Computed: true, - }, - Resource: &schemaR.Int64Attribute{ - Optional: true, - Default: int64default.StaticInt64(1), - }, - }, - "members": superschema.SetNestedAttribute{ - Common: &schemaR.SetNestedAttribute{ - MarkdownDescription: "ALB Pool Member(s).", - }, - Resource: &schemaR.SetNestedAttribute{ - Optional: true, - }, - DataSource: &schemaD.SetNestedAttribute{ - Computed: true, - }, - Attributes: map[string]superschema.Attribute{ - "enabled": superschema.BoolAttribute{ - Common: &schemaR.BoolAttribute{ - MarkdownDescription: "Indicates whether a pool member accepts traffic.", - Computed: true, - }, - Resource: &schemaR.BoolAttribute{ - Optional: true, - Default: booldefault.StaticBool(true), - }, - }, - "ip_address": superschema.StringAttribute{ - Common: &schemaR.StringAttribute{ - MarkdownDescription: "IP address of a pool member.", - }, - Resource: &schemaR.StringAttribute{ - Required: true, - Validators: []validator.String{ - fstringvalidator.IsIP(), - }, - }, - DataSource: &schemaD.StringAttribute{ - Computed: true, - }, - }, - "port": superschema.Int64Attribute{ - Common: &schemaR.Int64Attribute{ - MarkdownDescription: "Member port.", - }, - Resource: &schemaR.Int64Attribute{ - Required: true, - Validators: []validator.Int64{ - int64validator.Between(1, 65535), - }, - }, - DataSource: &schemaD.Int64Attribute{ - Computed: true, - }, - }, - "ratio": superschema.Int64Attribute{ - Common: &schemaR.Int64Attribute{ - MarkdownDescription: "Ratio of selecting eligible servers in the pool.", - Computed: true, - }, - Resource: &schemaR.Int64Attribute{ - Optional: true, - Default: int64default.StaticInt64(1), - Validators: []validator.Int64{ - int64validator.AtLeast(1), - }, - }, - }, - }, - }, - "health_monitors": superschema.SetAttribute{ - Common: &schemaR.SetAttribute{ - MarkdownDescription: "List of health monitors type to activate.", - ElementType: types.StringType, - }, - Resource: &schemaR.SetAttribute{ - Optional: true, - Validators: []validator.Set{ - setvalidator.ValueStringsAre(stringvalidator.OneOf("HTTP", "HTTPS", "TCP", "UDP", "PING")), - }, - }, - DataSource: &schemaD.SetAttribute{ - Computed: true, - }, - }, - "persistence_profile": superschema.SingleNestedAttribute{ - Common: &schemaR.SingleNestedAttribute{ - MarkdownDescription: "Persistence profile ensures that a user remains connected to the same server for a specified duration. If the persistence profile is unmanaged by Cloud Avenue, updates with unchanged values will continue using the same unmanaged profile. However, any changes to the persistence profile will prompt Cloud Avenue to switch the pool to a profile it manages.", - }, - Resource: &schemaR.SingleNestedAttribute{ - Optional: true, - }, - DataSource: &schemaD.SingleNestedAttribute{ - Computed: true, - }, - Attributes: map[string]superschema.Attribute{ - "type": superschema.StringAttribute{ - Common: &schemaR.StringAttribute{ - MarkdownDescription: "Type of persistence strategy.", - }, - Resource: &schemaR.StringAttribute{ - Required: true, - Validators: []validator.String{ - stringvalidator.OneOf("CLIENT_IP", "HTTP_COOKIE"), - }, - }, - DataSource: &schemaD.StringAttribute{ - Computed: true, - }, - }, - "value": superschema.StringAttribute{ - Common: &schemaR.StringAttribute{ - MarkdownDescription: "Value of attribute based on persistence type.", - }, - Resource: &schemaR.StringAttribute{ - Optional: true, - Validators: []validator.String{ - fstringvalidator.RequireIfAttributeIsOneOf(path.MatchRoot("persistence_profile").AtName("type"), []attr.Value{types.StringValue("HTTP_COOKIE")}), - }, - }, - DataSource: &schemaD.StringAttribute{ - Computed: true, - }, - }, - }, - }, - "passive_monitoring_enabled": superschema.BoolAttribute{ - Common: &schemaR.BoolAttribute{ - MarkdownDescription: "Monitors if the traffic is accepted by node.", - Computed: true, - }, - Resource: &schemaR.BoolAttribute{ - Optional: true, - Default: booldefault.StaticBool(true), - }, - }, - }, - } -} diff --git a/internal/provider/alb/pool_types.go b/internal/provider/alb/pool_types.go deleted file mode 100644 index 082f4332..00000000 --- a/internal/provider/alb/pool_types.go +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2025 Orange - * SPDX-License-Identifier: Mozilla Public License 2.0 - * - * This software is distributed under the MPL-2.0 license. - * the text of which is available at https://www.mozilla.org/en-US/MPL/2.0/ - * or see the "LICENSE" file for more details. - */ - -package alb - -import ( - "github.com/hashicorp/terraform-plugin-framework/attr" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type albPoolModel struct { - ID types.String `tfsdk:"id"` - EdgeGatewayID types.String `tfsdk:"edge_gateway_id"` - EdgeGatewayName types.String `tfsdk:"edge_gateway_name"` - Name types.String `tfsdk:"name"` - Enabled types.Bool `tfsdk:"enabled"` - Description types.String `tfsdk:"description"` - Algorithm types.String `tfsdk:"algorithm"` - DefaultPort types.Int64 `tfsdk:"default_port"` - GracefulTimeoutPeriod types.Int64 `tfsdk:"graceful_timeout_period"` - Members types.Set `tfsdk:"members"` - HealthMonitors types.Set `tfsdk:"health_monitors"` - PersistenceProfile types.Object `tfsdk:"persistence_profile"` - PassiveMonitoringEnabled types.Bool `tfsdk:"passive_monitoring_enabled"` - - // CACertificateIDs types.Set `tfsdk:"ca_certificate_ids"` - // CNCheckEnabled types.Bool `tfsdk:"cn_check_enabled"` - // DomainNames types.Set `tfsdk:"domain_names"` -} - -type member struct { - Enabled types.Bool `tfsdk:"enabled"` - IPAddress types.String `tfsdk:"ip_address"` - Port types.Int64 `tfsdk:"port"` - Ratio types.Int64 `tfsdk:"ratio"` -} - -var memberAttrTypes = map[string]attr.Type{ - "enabled": types.BoolType, - "ip_address": types.StringType, - "port": types.Int64Type, - "ratio": types.Int64Type, -} - -type persistenceProfile struct { - Type types.String `tfsdk:"type"` - Value types.String `tfsdk:"value"` -} - -var persistenceProfileAttrTypes = map[string]attr.Type{ - "type": types.StringType, - "value": types.StringType, -} diff --git a/internal/provider/alb/base.go b/internal/provider/elb/base.go similarity index 79% rename from internal/provider/alb/base.go rename to internal/provider/elb/base.go index f0f2cd52..bd60b4dd 100644 --- a/internal/provider/alb/base.go +++ b/internal/provider/elb/base.go @@ -7,13 +7,8 @@ * or see the "LICENSE" file for more details. */ -package alb +package elb const ( - categoryName = "alb" + categoryName = "elb" ) - -type base struct { - id string - name string -} diff --git a/internal/provider/alb/service_engine_group_datasource.go b/internal/provider/elb/service_engine_group_datasource.go similarity index 97% rename from internal/provider/alb/service_engine_group_datasource.go rename to internal/provider/elb/service_engine_group_datasource.go index cd1ec7a3..6e13259a 100644 --- a/internal/provider/alb/service_engine_group_datasource.go +++ b/internal/provider/elb/service_engine_group_datasource.go @@ -7,8 +7,8 @@ * or see the "LICENSE" file for more details. */ -// Package alb provides a Terraform datasource. -package alb +// package elb provides a Terraform datasource. +package elb import ( "context" @@ -79,7 +79,7 @@ func (d *serviceEngineGroupDataSource) Configure(ctx context.Context, req dataso } func (d *serviceEngineGroupDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - defer metrics.New("data.cloudavenue_alb_service_engine_group", d.client.GetOrgName(), metrics.Read)() + defer metrics.New("data.cloudavenue_elb_service_engine_group", d.client.GetOrgName(), metrics.Read)() config := &serviceEngineGroupModel{} diff --git a/internal/provider/alb/service_engine_group_schema.go b/internal/provider/elb/service_engine_group_schema.go similarity index 83% rename from internal/provider/alb/service_engine_group_schema.go rename to internal/provider/elb/service_engine_group_schema.go index fcf264be..e5dd7004 100644 --- a/internal/provider/alb/service_engine_group_schema.go +++ b/internal/provider/elb/service_engine_group_schema.go @@ -7,7 +7,7 @@ * or see the "LICENSE" file for more details. */ -package alb +package elb import ( "context" @@ -25,14 +25,14 @@ import ( func serviceEngineGroupSchema(_ context.Context) superschema.Schema { return superschema.Schema{ DataSource: superschema.SchemaDetails{ - MarkdownDescription: "The `cloudavenue_alb_service_engine_group` data source allows you to retrieve information about an ALB Service Engine Group.", + MarkdownDescription: "The `cloudavenue_elb_service_engine_group` data source allows you to retrieve information about an Service Engine Group of an Edge Gateway.", }, Attributes: map[string]superschema.Attribute{ "id": superschema.SuperStringAttribute{ DataSource: &schemaD.StringAttribute{ Computed: true, Optional: true, - MarkdownDescription: "The ID of the ALB Service Engine Group.", + MarkdownDescription: "The ID of the ELB Service Engine Group.", Validators: []validator.String{ stringvalidator.ExactlyOneOf(path.MatchRoot("id"), path.MatchRoot("name")), }, @@ -40,7 +40,7 @@ func serviceEngineGroupSchema(_ context.Context) superschema.Schema { }, "name": superschema.SuperStringAttribute{ DataSource: &schemaD.StringAttribute{ - MarkdownDescription: "The name of the ALB Service Engine Group.", + MarkdownDescription: "The name of the ELB Service Engine Group.", Computed: true, Optional: true, Validators: []validator.String{ @@ -50,7 +50,7 @@ func serviceEngineGroupSchema(_ context.Context) superschema.Schema { }, "edge_gateway_id": superschema.SuperStringAttribute{ DataSource: &schemaD.StringAttribute{ - MarkdownDescription: "Edge gateway ID in which ALB Service Engine Group should be located.", + MarkdownDescription: "Edge gateway ID in which ELB Service Engine Group should be located.", Optional: true, Validators: []validator.String{ stringvalidator.ExactlyOneOf(path.MatchRoot("edge_gateway_id"), path.MatchRoot("edge_gateway_name")), @@ -60,7 +60,7 @@ func serviceEngineGroupSchema(_ context.Context) superschema.Schema { }, "edge_gateway_name": superschema.SuperStringAttribute{ DataSource: &schemaD.StringAttribute{ - MarkdownDescription: "Edge gateway Name in which ALB Service Engine Group should be located.", + MarkdownDescription: "Edge gateway Name in which ELB Service Engine Group should be located.", Optional: true, Validators: []validator.String{ stringvalidator.ExactlyOneOf(path.MatchRoot("edge_gateway_id"), path.MatchRoot("edge_gateway_name")), @@ -71,19 +71,19 @@ func serviceEngineGroupSchema(_ context.Context) superschema.Schema { "max_virtual_services": superschema.SuperInt64Attribute{ DataSource: &schemaD.Int64Attribute{ Computed: true, - MarkdownDescription: "The maximum number of virtual services that can be deployed on the ALB Service Engine Group.", + MarkdownDescription: "The maximum number of virtual services that can be deployed on the ELB Service Engine Group.", }, }, "reserved_virtual_services": superschema.SuperInt64Attribute{ DataSource: &schemaD.Int64Attribute{ Computed: true, - MarkdownDescription: "The number of reserved virtual services for the ALB Service Engine Group.", + MarkdownDescription: "The number of reserved virtual services for the ELB Service Engine Group.", }, }, "deployed_virtual_services": superschema.SuperInt64Attribute{ DataSource: &schemaD.Int64Attribute{ Computed: true, - MarkdownDescription: "The number of deployed virtual services on the ALB Service Engine Group.", + MarkdownDescription: "The number of deployed virtual services on the ELB Service Engine Group.", }, }, }, diff --git a/internal/provider/alb/service_engine_group_schema_test.go b/internal/provider/elb/service_engine_group_schema_test.go similarity index 95% rename from internal/provider/alb/service_engine_group_schema_test.go rename to internal/provider/elb/service_engine_group_schema_test.go index 7e4dc409..5ebbe4dd 100644 --- a/internal/provider/alb/service_engine_group_schema_test.go +++ b/internal/provider/elb/service_engine_group_schema_test.go @@ -7,7 +7,7 @@ * or see the "LICENSE" file for more details. */ -package alb_test +package elb_test import ( "context" @@ -15,7 +15,7 @@ import ( fwdatasource "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/alb" + "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/elb" ) // TODO : Comment or uncomment the following imports if you are using resources or/and datasources @@ -51,7 +51,7 @@ func TestALBServiceEngineGroupDataSourceSchema(t *testing.T) { schemaResponse := &fwdatasource.SchemaResponse{} // Instantiate the datasource.Datasource and call its Schema method - alb.NewServiceEngineGroupDataSource().Schema(ctx, fwdatasource.SchemaRequest{}, schemaResponse) + elb.NewServiceEngineGroupDataSource().Schema(ctx, fwdatasource.SchemaRequest{}, schemaResponse) if schemaResponse.Diagnostics.HasError() { t.Fatalf("Schema method diagnostics: %+v", schemaResponse.Diagnostics) diff --git a/internal/provider/alb/service_engine_group_types.go b/internal/provider/elb/service_engine_group_types.go similarity index 98% rename from internal/provider/alb/service_engine_group_types.go rename to internal/provider/elb/service_engine_group_types.go index fbc2285d..886c98a9 100644 --- a/internal/provider/alb/service_engine_group_types.go +++ b/internal/provider/elb/service_engine_group_types.go @@ -7,7 +7,7 @@ * or see the "LICENSE" file for more details. */ -package alb +package elb import ( supertypes "github.com/orange-cloudavenue/terraform-plugin-framework-supertypes" diff --git a/internal/provider/alb/service_engine_groups_datasource.go b/internal/provider/elb/service_engine_groups_datasource.go similarity index 97% rename from internal/provider/alb/service_engine_groups_datasource.go rename to internal/provider/elb/service_engine_groups_datasource.go index 47aebba4..e51ae5c0 100644 --- a/internal/provider/alb/service_engine_groups_datasource.go +++ b/internal/provider/elb/service_engine_groups_datasource.go @@ -7,8 +7,8 @@ * or see the "LICENSE" file for more details. */ -// Package alb provides a Terraform datasource. -package alb +// package elb provides a Terraform datasource. +package elb import ( "context" @@ -76,7 +76,7 @@ func (d *serviceEngineGroupsDataSource) Configure(ctx context.Context, req datas } func (d *serviceEngineGroupsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - defer metrics.New("data.cloudavenue_alb_service_engine_groups", d.client.GetOrgName(), metrics.Read)() + defer metrics.New("data.cloudavenue_elb_service_engine_groups", d.client.GetOrgName(), metrics.Read)() config := &serviceEngineGroupsModel{} diff --git a/internal/provider/alb/service_engine_groups_schema.go b/internal/provider/elb/service_engine_groups_schema.go similarity index 95% rename from internal/provider/alb/service_engine_groups_schema.go rename to internal/provider/elb/service_engine_groups_schema.go index ab6ae8e2..c492e422 100644 --- a/internal/provider/alb/service_engine_groups_schema.go +++ b/internal/provider/elb/service_engine_groups_schema.go @@ -7,7 +7,7 @@ * or see the "LICENSE" file for more details. */ -package alb +package elb import ( "context" @@ -25,13 +25,13 @@ import ( func serviceEngineGroupsSchema(ctx context.Context) superschema.Schema { return superschema.Schema{ DataSource: superschema.SchemaDetails{ - MarkdownDescription: "The `cloudavenue_alb_service_engine_groups` data source allows you to retrieve information about all the Service Engine Group of an Edge Gateway.", + MarkdownDescription: "The `cloudavenue_elb_service_engine_groups` data source allows you to retrieve information about all the Service Engine Group of an Edge Gateway.", }, Attributes: map[string]superschema.Attribute{ "id": superschema.SuperStringAttribute{ DataSource: &schemaD.StringAttribute{ Computed: true, - MarkdownDescription: "The ID of the service engine groups.", + MarkdownDescription: "The ID of the ELB service engine groups.", }, }, "edge_gateway_id": superschema.SuperStringAttribute{ diff --git a/internal/provider/alb/service_engine_groups_schema_test.go b/internal/provider/elb/service_engine_groups_schema_test.go similarity index 91% rename from internal/provider/alb/service_engine_groups_schema_test.go rename to internal/provider/elb/service_engine_groups_schema_test.go index 53468392..9ccadfa7 100644 --- a/internal/provider/alb/service_engine_groups_schema_test.go +++ b/internal/provider/elb/service_engine_groups_schema_test.go @@ -7,7 +7,7 @@ * or see the "LICENSE" file for more details. */ -package alb_test +package elb_test import ( "context" @@ -15,7 +15,7 @@ import ( fwdatasource "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/alb" + "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/elb" ) // Unit test for the schema of the datasource cloudavenue_alb_ServiceEngineGroups. @@ -26,7 +26,7 @@ func TestServiceEngineGroupsDataSourceSchema(t *testing.T) { schemaResponse := &fwdatasource.SchemaResponse{} // Instantiate the datasource.Datasource and call its Schema method - alb.NewServiceEngineGroupsDataSource().Schema(ctx, fwdatasource.SchemaRequest{}, schemaResponse) + elb.NewServiceEngineGroupsDataSource().Schema(ctx, fwdatasource.SchemaRequest{}, schemaResponse) if schemaResponse.Diagnostics.HasError() { t.Fatalf("Schema method diagnostics: %+v", schemaResponse.Diagnostics) diff --git a/internal/provider/alb/service_engine_groups_types.go b/internal/provider/elb/service_engine_groups_types.go similarity index 98% rename from internal/provider/alb/service_engine_groups_types.go rename to internal/provider/elb/service_engine_groups_types.go index 22bce8da..bf8eb750 100644 --- a/internal/provider/alb/service_engine_groups_types.go +++ b/internal/provider/elb/service_engine_groups_types.go @@ -7,7 +7,7 @@ * or see the "LICENSE" file for more details. */ -package alb +package elb import supertypes "github.com/orange-cloudavenue/terraform-plugin-framework-supertypes" diff --git a/internal/provider/provider_datasources.go b/internal/provider/provider_datasources.go index 5095ecd7..00c11d8d 100644 --- a/internal/provider/provider_datasources.go +++ b/internal/provider/provider_datasources.go @@ -14,11 +14,11 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/alb" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/backup" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/bms" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/catalog" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/edgegw" + "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/elb" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/iam" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/network" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/org" @@ -35,10 +35,9 @@ import ( // DataSources defines the data sources implemented in the provider. func (p *cloudavenueProvider) DataSources(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ - // * ALB - alb.NewAlbPoolDataSource, - alb.NewServiceEngineGroupDataSource, - alb.NewServiceEngineGroupsDataSource, + // * EdgeGateway LoadBalancer + elb.NewServiceEngineGroupDataSource, + elb.NewServiceEngineGroupsDataSource, // * TIER0 vrf.NewTier0VrfsDataSource, diff --git a/internal/provider/provider_resources.go b/internal/provider/provider_resources.go index 6be3649d..775cfd48 100644 --- a/internal/provider/provider_resources.go +++ b/internal/provider/provider_resources.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/alb" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/backup" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/catalog" "github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/edgegw" @@ -33,9 +32,6 @@ import ( // Resources defines the resources implemented in the provider. func (p *cloudavenueProvider) Resources(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ - // * ALB - alb.NewAlbPoolResource, - // * EDGE GATEWAY edgegw.NewEdgeGatewayResource, edgegw.NewFirewallResource, diff --git a/internal/testsacc/alb_pool_datasource_test.go b/internal/testsacc/alb_pool_datasource_test.go deleted file mode 100644 index 51ba7c85..00000000 --- a/internal/testsacc/alb_pool_datasource_test.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2025 Orange - * SPDX-License-Identifier: Mozilla Public License 2.0 - * - * This software is distributed under the MPL-2.0 license. - * the text of which is available at https://www.mozilla.org/en-US/MPL/2.0/ - * or see the "LICENSE" file for more details. - */ - -package testsacc - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - - "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" -) - -const testAccAlbPoolDataSourceConfig = ` -resource "cloudavenue_alb_pool" "example" { - edge_gateway_name = "tn01e02ocb0006205spt102" - name = "Example" - - persistence_profile = { - type = "CLIENT_IP" - } - - members = [ - { - ip_address = "192.168.1.1" - port = "80" - }, - { - ip_address = "192.168.1.2" - port = "80" - }, - { - ip_address = "192.168.1.3" - port = "80" - } - ] - - health_monitors = ["UDP", "TCP"] - } - -data "cloudavenue_alb_pool" "example" { - edge_gateway_name = cloudavenue_alb_pool.example.edge_gateway_name - name = cloudavenue_alb_pool.example.name -} -` - -func TestAccAlbPoolDataSource(t *testing.T) { - dataSourceName := "data.cloudavenue_alb_pool.example" - resourceName := "cloudavenue_alb_pool.example" - resource.Test(t, resource.TestCase{ - PreCheck: func() { TestAccPreCheck(t) }, - ProtoV6ProviderFactories: TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Read testing - { - // Apply test - Config: testAccAlbPoolDataSourceConfig, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.LoadBalancerPool)), - resource.TestCheckResourceAttrPair(dataSourceName, "name", resourceName, "name"), - resource.TestCheckResourceAttrPair(dataSourceName, "persistence_profile.#", resourceName, "persistence_profile.#"), - resource.TestCheckResourceAttrPair(dataSourceName, "members.#", resourceName, "members.#"), - resource.TestCheckResourceAttrPair(dataSourceName, "health_monitors.#", resourceName, "health_monitors.#"), - ), - }, - }, - }) -} diff --git a/internal/testsacc/alb_pool_resource_test.go b/internal/testsacc/alb_pool_resource_test.go deleted file mode 100644 index 536cf27b..00000000 --- a/internal/testsacc/alb_pool_resource_test.go +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SPDX-FileCopyrightText: Copyright (c) 2025 Orange - * SPDX-License-Identifier: Mozilla Public License 2.0 - * - * This software is distributed under the MPL-2.0 license. - * the text of which is available at https://www.mozilla.org/en-US/MPL/2.0/ - * or see the "LICENSE" file for more details. - */ - -package testsacc - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - - "github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn" -) - -const testAccAlbPoolResourceConfig = ` -resource "cloudavenue_alb_pool" "example" { - edge_gateway_name = "tn01e02ocb0006205spt102" - name = "Example" - - persistence_profile = { - type = "CLIENT_IP" - } - - members = [ - { - ip_address = "192.168.1.1" - port = "80" - }, - { - ip_address = "192.168.1.2" - port = "80" - }, - { - ip_address = "192.168.1.3" - port = "80" - } - ] - - health_monitors = ["UDP", "TCP"] - } -` - -const testAccAlbPoolResourceConfigUpdate = ` -resource "cloudavenue_alb_pool" "example" { - edge_gateway_name = "tn01e02ocb0006205spt102" - name = "Example" - } -` - -func TestAccAlbPoolResource(t *testing.T) { - const resourceName = "cloudavenue_alb_pool.example" - resource.Test(t, resource.TestCase{ - PreCheck: func() { TestAccPreCheck(t) }, - ProtoV6ProviderFactories: TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Read testing - { - // Apply test - Config: testAccAlbPoolResourceConfig, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.LoadBalancerPool)), - resource.TestCheckResourceAttr(resourceName, "name", "Example"), - resource.TestCheckResourceAttr(resourceName, "persistence_profile.type", "CLIENT_IP"), - ), - }, - { - // Update test - Config: testAccAlbPoolResourceConfigUpdate, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.LoadBalancerPool)), - resource.TestCheckResourceAttr(resourceName, "name", "Example"), - resource.TestCheckNoResourceAttr(resourceName, "persistence_profile"), - resource.TestCheckNoResourceAttr(resourceName, "members"), - resource.TestCheckNoResourceAttr(resourceName, "health_monitors"), - ), - }, - }, - }) -} diff --git a/internal/testsacc/alb_service_engine_group_datasource_test.go b/internal/testsacc/edgegateway_lb_service_engine_group_datasource_test.go similarity index 91% rename from internal/testsacc/alb_service_engine_group_datasource_test.go rename to internal/testsacc/edgegateway_lb_service_engine_group_datasource_test.go index 4c7b07c4..b1477e33 100644 --- a/internal/testsacc/alb_service_engine_group_datasource_test.go +++ b/internal/testsacc/edgegateway_lb_service_engine_group_datasource_test.go @@ -22,7 +22,7 @@ import ( var _ testsacc.TestACC = &ALBServiceEngineGroupDataSource{} const ( - ALBServiceEngineGroupDataSourceName = testsacc.ResourceName("data.cloudavenue_alb_service_engine_group") + ALBServiceEngineGroupDataSourceName = testsacc.ResourceName("data.cloudavenue_elb_service_engine_group") ) type ALBServiceEngineGroupDataSource struct{} @@ -50,8 +50,8 @@ func (r *ALBServiceEngineGroupDataSource) Tests(ctx context.Context) map[testsac // ! Create testing Create: testsacc.TFConfig{ TFConfig: ` - data "cloudavenue_alb_service_engine_group" "example" { - name = data.cloudavenue_alb_service_engine_groups.example.service_engine_groups.0.name + data "cloudavenue_elb_service_engine_group" "example" { + name = data.cloudavenue_elb_service_engine_groups.example.service_engine_groups.0.name edge_gateway_name = data.cloudavenue_edgegateway.example_with_id.name }`, Checks: []resource.TestCheckFunc{ @@ -71,8 +71,8 @@ func (r *ALBServiceEngineGroupDataSource) Tests(ctx context.Context) map[testsac // ! Create testing Create: testsacc.TFConfig{ TFConfig: ` - data "cloudavenue_alb_service_engine_group" "example_with_id" { - id = data.cloudavenue_alb_service_engine_groups.example.service_engine_groups.0.id + data "cloudavenue_elb_service_engine_group" "example_with_id" { + id = data.cloudavenue_elb_service_engine_groups.example.service_engine_groups.0.id edge_gateway_name = data.cloudavenue_edgegateway.example_with_id.name }`, // Here use resource config test to test the data source @@ -94,8 +94,8 @@ func (r *ALBServiceEngineGroupDataSource) Tests(ctx context.Context) map[testsac // ! Create testing Create: testsacc.TFConfig{ TFConfig: ` - data "cloudavenue_alb_service_engine_group" "example_with_edge_id" { - id = data.cloudavenue_alb_service_engine_groups.example.service_engine_groups.0.id + data "cloudavenue_elb_service_engine_group" "example_with_edge_id" { + id = data.cloudavenue_elb_service_engine_groups.example.service_engine_groups.0.id edge_gateway_id = data.cloudavenue_edgegateway.example_with_id.id }`, // Here use resource config test to test the data source @@ -117,8 +117,8 @@ func (r *ALBServiceEngineGroupDataSource) Tests(ctx context.Context) map[testsac // ! Create testing Create: testsacc.TFConfig{ TFConfig: ` - data "cloudavenue_alb_service_engine_group" "example_with_name_and_edge_id" { - name = data.cloudavenue_alb_service_engine_groups.example.service_engine_groups.0.name + data "cloudavenue_elb_service_engine_group" "example_with_name_and_edge_id" { + name = data.cloudavenue_elb_service_engine_groups.example.service_engine_groups.0.name edge_gateway_id = data.cloudavenue_edgegateway.example_with_id.id }`, // Here use resource config test to test the data source diff --git a/internal/testsacc/alb_service_engine_groups_datasource_test.go b/internal/testsacc/edgegateway_lb_service_engine_groups_datasource_test.go similarity index 96% rename from internal/testsacc/alb_service_engine_groups_datasource_test.go rename to internal/testsacc/edgegateway_lb_service_engine_groups_datasource_test.go index 62029bed..6932cc6a 100644 --- a/internal/testsacc/alb_service_engine_groups_datasource_test.go +++ b/internal/testsacc/edgegateway_lb_service_engine_groups_datasource_test.go @@ -22,7 +22,7 @@ import ( var _ testsacc.TestACC = &ALBServiceEngineGroupsDataSource{} const ( - ALBServiceEngineGroupsDataSourceName = testsacc.ResourceName("data.cloudavenue_alb_service_engine_groups") + ALBServiceEngineGroupsDataSourceName = testsacc.ResourceName("data.cloudavenue_elb_service_engine_groups") ) type ALBServiceEngineGroupsDataSource struct{} @@ -49,7 +49,7 @@ func (r *ALBServiceEngineGroupsDataSource) Tests(ctx context.Context) map[testsa // ! Create testing Create: testsacc.TFConfig{ TFConfig: ` - data "cloudavenue_alb_service_engine_groups" "example" { + data "cloudavenue_elb_service_engine_groups" "example" { edge_gateway_name = data.cloudavenue_edgegateway.example_with_id.name }`, Checks: []resource.TestCheckFunc{ @@ -73,7 +73,7 @@ func (r *ALBServiceEngineGroupsDataSource) Tests(ctx context.Context) map[testsa // ! Create testing Create: testsacc.TFConfig{ TFConfig: ` - data "cloudavenue_alb_service_engine_groups" "example_with_id" { + data "cloudavenue_elb_service_engine_groups" "example_with_id" { edge_gateway_id = data.cloudavenue_edgegateway.example_with_id.id }`, Checks: []resource.TestCheckFunc{ diff --git a/templates/data-sources/alb_pool.md.tmpl b/templates/data-sources/alb_pool.md.tmpl deleted file mode 100644 index cb7a94b6..00000000 --- a/templates/data-sources/alb_pool.md.tmpl +++ /dev/null @@ -1,25 +0,0 @@ ---- -page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" -subcategory: "ALB (Advanced Load Balancer)" -description: |- -{{ .Description | plainmarkdown | trimspace | prefixlines " " }} ---- - -# {{.Name}} ({{.Type}}) - -{{ .Description | trimspace }} - -{{ if .HasExample -}} -## Example Usage - -{{ tffile .ExampleFile }} -{{- end }} - -{{ .SchemaMarkdown | trimspace }} - -{{ if .HasImport -}} -## Import - -Import is supported using the following syntax: -{{ codefile "shell" .ImportFile }} -{{- end }} \ No newline at end of file diff --git a/templates/data-sources/alb_service_engine_groups.md.tmpl b/templates/data-sources/elb_service_engine_group.md.tmpl similarity index 86% rename from templates/data-sources/alb_service_engine_groups.md.tmpl rename to templates/data-sources/elb_service_engine_group.md.tmpl index e60292cd..e09bf6b3 100644 --- a/templates/data-sources/alb_service_engine_groups.md.tmpl +++ b/templates/data-sources/elb_service_engine_group.md.tmpl @@ -1,6 +1,6 @@ --- page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" -subcategory: "ALB (Advanced Load Balancer)" +subcategory: "ELB (EdgeGateway Load Balancer)" description: |- {{ .Description | plainmarkdown | trimspace | prefixlines " " }} --- diff --git a/templates/data-sources/alb_service_engine_group.md.tmpl b/templates/data-sources/elb_service_engine_groups.md.tmpl similarity index 86% rename from templates/data-sources/alb_service_engine_group.md.tmpl rename to templates/data-sources/elb_service_engine_groups.md.tmpl index e60292cd..e09bf6b3 100644 --- a/templates/data-sources/alb_service_engine_group.md.tmpl +++ b/templates/data-sources/elb_service_engine_groups.md.tmpl @@ -1,6 +1,6 @@ --- page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" -subcategory: "ALB (Advanced Load Balancer)" +subcategory: "ELB (EdgeGateway Load Balancer)" description: |- {{ .Description | plainmarkdown | trimspace | prefixlines " " }} --- diff --git a/templates/resources/alb_pool.md.tmpl b/templates/resources/alb_pool.md.tmpl deleted file mode 100644 index cb7a94b6..00000000 --- a/templates/resources/alb_pool.md.tmpl +++ /dev/null @@ -1,25 +0,0 @@ ---- -page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" -subcategory: "ALB (Advanced Load Balancer)" -description: |- -{{ .Description | plainmarkdown | trimspace | prefixlines " " }} ---- - -# {{.Name}} ({{.Type}}) - -{{ .Description | trimspace }} - -{{ if .HasExample -}} -## Example Usage - -{{ tffile .ExampleFile }} -{{- end }} - -{{ .SchemaMarkdown | trimspace }} - -{{ if .HasImport -}} -## Import - -Import is supported using the following syntax: -{{ codefile "shell" .ImportFile }} -{{- end }} \ No newline at end of file