Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

LB profile datasource access mode value support #5773

Merged
merged 5 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ibm/service/vpc/data_source_ibm_is_lb_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
},
},
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion ibm/service/vpc/data_source_ibm_is_lb_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.#"),
),
},
},
Expand Down
10 changes: 9 additions & 1 deletion ibm/service/vpc/data_source_ibm_is_lb_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
},
},
Expand Down Expand Up @@ -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
Expand Down
32 changes: 9 additions & 23 deletions ibm/service/vpc/data_source_ibm_is_lb_profiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand All @@ -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(`
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/is_lb_profile.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/is_lb_profiles.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand Down
Loading