From 3213bbf6201e010fb068508ea239a5680613ad73 Mon Sep 17 00:00:00 2001 From: Deepak Selvakumar <77007253+deepaksibm@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:54:12 +0530 Subject: [PATCH] LB profile datasource access mode value support (#5773) * LB profile datasource access mode value support * Revert "LB profile datasource access mode value support" This reverts commit 376764e5f003892ea12b7141f88004f6f5249939. * updated access mode values and test cases * doc update * doc update --- .../vpc/data_source_ibm_is_lb_profile.go | 10 +++++- .../vpc/data_source_ibm_is_lb_profile_test.go | 3 +- .../vpc/data_source_ibm_is_lb_profiles.go | 10 +++++- .../data_source_ibm_is_lb_profiles_test.go | 32 ++++++------------- website/docs/d/is_lb_profile.html.markdown | 2 +- website/docs/d/is_lb_profiles.html.markdown | 2 +- 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/ibm/service/vpc/data_source_ibm_is_lb_profile.go b/ibm/service/vpc/data_source_ibm_is_lb_profile.go index 2bc81ac8cf..887116cbdb 100644 --- a/ibm/service/vpc/data_source_ibm_is_lb_profile.go +++ b/ibm/service/vpc/data_source_ibm_is_lb_profile.go @@ -40,6 +40,14 @@ func DataSourceIBMISLbProfile() *schema.Resource { Computed: true, Description: "Access modes for this profile", }, + "values": { + Type: schema.TypeList, + Computed: true, + Description: "Access modes for this profile", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, }, }, }, @@ -103,7 +111,7 @@ func dataSourceIBMISLbProfileRead(context context.Context, d *schema.ResourceDat AccessModesMap["type"] = *accessModes.Type } if len(accessModes.Values) > 0 { - AccessModesMap["value"] = accessModes.Values + AccessModesMap["values"] = accessModes.Values } AccessModesList = append(AccessModesList, AccessModesMap) d.Set(isLBAccessModes, AccessModesList) diff --git a/ibm/service/vpc/data_source_ibm_is_lb_profile_test.go b/ibm/service/vpc/data_source_ibm_is_lb_profile_test.go index 30626cd305..4fb57d8623 100644 --- a/ibm/service/vpc/data_source_ibm_is_lb_profile_test.go +++ b/ibm/service/vpc/data_source_ibm_is_lb_profile_test.go @@ -22,10 +22,11 @@ func TestAccIBMISLBProfileDatasource_basic(t *testing.T) { Config: testDSCheckIBMISLBProfileBasicConfig(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.ibm_is_lb_profile.test_profile", "name", "network-fixed"), - resource.TestCheckResourceAttr("data.ibm_is_lb_profile.test_profile", "family", "Network"), + resource.TestCheckResourceAttr("data.ibm_is_lb_profile.test_profile", "family", "network"), resource.TestCheckResourceAttr("data.ibm_is_lb_profile.test_profile", "route_mode_supported", "true"), resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "href"), resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "udp_supported"), + resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "access_modes.0.values.#"), ), }, }, diff --git a/ibm/service/vpc/data_source_ibm_is_lb_profiles.go b/ibm/service/vpc/data_source_ibm_is_lb_profiles.go index 143402b6a3..c9f53c2dcf 100644 --- a/ibm/service/vpc/data_source_ibm_is_lb_profiles.go +++ b/ibm/service/vpc/data_source_ibm_is_lb_profiles.go @@ -50,6 +50,14 @@ func DataSourceIBMISLbProfiles() *schema.Resource { Computed: true, Description: "Access modes for this profile", }, + "values": { + Type: schema.TypeList, + Computed: true, + Description: "Access modes for this profile", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, }, }, }, @@ -260,7 +268,7 @@ func dataSourceIBMISLbProfilesRead(d *schema.ResourceData, meta interface{}) err AccessModesMap["type"] = *accessModes.Type } if len(accessModes.Values) > 0 { - AccessModesMap["value"] = accessModes.Values + AccessModesMap["values"] = accessModes.Values } AccessModesList = append(AccessModesList, AccessModesMap) l[isLBAccessModes] = AccessModesList diff --git a/ibm/service/vpc/data_source_ibm_is_lb_profiles_test.go b/ibm/service/vpc/data_source_ibm_is_lb_profiles_test.go index 9e9823926f..ef046e5a79 100644 --- a/ibm/service/vpc/data_source_ibm_is_lb_profiles_test.go +++ b/ibm/service/vpc/data_source_ibm_is_lb_profiles_test.go @@ -9,25 +9,24 @@ import ( acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccIBMISLBProfilesDatasource_basic(t *testing.T) { - name := fmt.Sprintf("tflb-name-%d", acctest.RandIntRange(10, 100)) - vpcname := fmt.Sprintf("tflb-vpc-%d", acctest.RandIntRange(10, 100)) - subnetname := fmt.Sprintf("tflb-subnet-name-%d", acctest.RandIntRange(10, 100)) - var lb string resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testDSCheckIBMISLBProfilesConfig(vpcname, subnetname, acc.ISZoneName, acc.ISCIDR, name), + Config: testDSCheckIBMISLBProfilesConfig(), Check: resource.ComposeTestCheckFunc( - testAccCheckIBMISLBExists("ibm_is_lb.testacc_lb", lb), resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.#"), + resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.access_modes.#"), + resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.access_modes.0.values.#"), + resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.route_mode_supported"), + resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.href"), + resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.udp_supported"), ), }, }, @@ -52,23 +51,10 @@ func TestAccIBMISLBProfilesDatasource_filter(t *testing.T) { }, }) } -func testDSCheckIBMISLBProfilesConfig(vpcname, subnetname, zone, cidr, name string) string { +func testDSCheckIBMISLBProfilesConfig() string { return fmt.Sprintf(` -resource "ibm_is_vpc" "testacc_vpc" { - name = "%s" -} -resource "ibm_is_subnet" "testacc_subnet" { - name = "%s" - vpc = ibm_is_vpc.testacc_vpc.id - zone = "%s" - ipv4_cidr_block = "%s" -} -resource "ibm_is_lb" "testacc_lb" { - name = "%s" - subnets = [ibm_is_subnet.testacc_subnet.id] -} -data "ibm_is_lb_profiles" "test_profiles" { -} `, vpcname, subnetname, zone, cidr, name) + data "ibm_is_lb_profiles" "test_profiles" { + } `) } func testDSCheckIBMISLBProfilesFilterConfig() string { return fmt.Sprintf(` diff --git a/website/docs/d/is_lb_profile.html.markdown b/website/docs/d/is_lb_profile.html.markdown index aa9d024e0c..495e185312 100644 --- a/website/docs/d/is_lb_profile.html.markdown +++ b/website/docs/d/is_lb_profile.html.markdown @@ -40,7 +40,7 @@ You can access the following attribute references after your data source is crea - `access_modes` - (List) The instance groups support for a load balancer with this profile Nested scheme for `access_modes`: - `type` - (String) The type of access mode. - - `value` - (String) Access modes for this profile. + - `values` - (List of strings) Access modes for this profile. - `family` - (String) The product family this load balancer profile belongs to. - `href` - (String) The URL for this load balancer profile. - `id` - (String) The id(`name`) for this load balancer profile. diff --git a/website/docs/d/is_lb_profiles.html.markdown b/website/docs/d/is_lb_profiles.html.markdown index ea1acd75fe..eb71baa7af 100644 --- a/website/docs/d/is_lb_profiles.html.markdown +++ b/website/docs/d/is_lb_profiles.html.markdown @@ -44,7 +44,7 @@ You can access the following attribute references after your data source is crea Nested scheme for `access_modes`: - `type` - (String) The type of access mode. - - `value` - (String) Access modes for this profile. + - `values` - (List of strings) Access modes for this profile. - `availability` - (List) The availability mode for a load balancer with this profile Nested scheme for `availability`: