Skip to content

Commit 99fddd6

Browse files
committed
feat(ppnlb): Update code with latest spec changes
1 parent 444845e commit 99fddd6

14 files changed

+8074
-2481
lines changed

common/github.com/IBM/vpc-go-sdk/vpcv1/vpc_v1.go

Lines changed: 7984 additions & 2329 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ replace github.com/softlayer/softlayer-go v1.0.3 => github.com/IBM-Cloud/softlay
231231
// add sdk changes.
232232
replace github.com/portworx/sched-ops v0.0.0-20200831185134-3e8010dc7056 => github.com/portworx/sched-ops v0.20.4-openstorage-rc3 // required by rook v1.7
233233

234-
replace github.com/IBM/vpc-go-sdk v0.64.0 => ./common/github.com/IBM/vpc-go-sdk
234+
replace github.com/IBM/vpc-go-sdk v0.70.1 => ./common/github.com/IBM/vpc-go-sdk
235235
replace github.com/hashicorp/consul/api v1.1.0 => github.com/hashicorp/consul/api v1.30.0
236236

237237
replace github.com/hashicorp/vault => github.com/hashicorp/vault v1.18.2

ibm/service/vpc/data_source_ibm_is_lb.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ func DataSourceIBMISLB() *schema.Resource {
9797
Computed: true,
9898
Description: "Indicates whether this load balancer supports source IP session persistence.",
9999
},
100-
isLBReservedIPtargetSupported: {
101-
Type: schema.TypeBool,
102-
Computed: true,
103-
Description: "Indicates whether this load balancer supports members with reserved IP as target.",
104-
},
105100
isLBUdpSupported: {
106101
Type: schema.TypeBool,
107102
Computed: true,
@@ -489,9 +484,6 @@ func lbGetByName(context context.Context, d *schema.ResourceData, meta interface
489484
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting route_mode: %s", err), "(Data) ibm_is_lb", "read", "set-route_mode").GetDiag()
490485
}
491486
}
492-
if lb.ReservedIPTargetSupported != nil {
493-
d.Set(isLBReservedIPtargetSupported, *lb.ReservedIPTargetSupported)
494-
}
495487
if err = d.Set("udp_supported", loadBalancer.UDPSupported); err != nil {
496488
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting udp_supported: %s", err), "(Data) ibm_is_lb", "read", "set-udp_supported").GetDiag()
497489
}

ibm/service/vpc/data_source_ibm_is_lb_profile.go

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,26 @@ func DataSourceIBMISLbProfile() *schema.Resource {
8686
Computed: true,
8787
Description: "The product family this load balancer profile belongs to",
8888
},
89-
"reserved_ip_target_supported": {
90-
Type: schema.TypeBool,
91-
Computed: true,
92-
Description: "The Reserved IP Target support for a load balancer with this profile",
89+
"targetable_resource_types": &schema.Schema{
90+
Type: schema.TypeList,
91+
Computed: true,
92+
Elem: &schema.Resource{
93+
Schema: map[string]*schema.Schema{
94+
"type": &schema.Schema{
95+
Type: schema.TypeString,
96+
Computed: true,
97+
Description: "The type for this profile field.",
98+
},
99+
"values": &schema.Schema{
100+
Type: schema.TypeList,
101+
Computed: true,
102+
Description: "The resource types that pool members of load balancers with this profile can target",
103+
Elem: &schema.Schema{
104+
Type: schema.TypeString,
105+
},
106+
},
107+
},
108+
},
93109
},
94110
"reserved_ip_type": {
95111
Type: schema.TypeString,
@@ -285,38 +301,38 @@ func dataSourceIBMISLbProfileRead(context context.Context, d *schema.ResourceDat
285301
}
286302
}
287303
}
288-
if lbProfile.ReservedIPTargetSupported != nil {
289-
reservedIPTargetSupported := lbProfile.ReservedIPTargetSupported
290-
switch reflect.TypeOf(reservedIPTargetSupported).String() {
291-
case "*vpcv1.LoadBalancerProfileReservedIPTargetSupportedFixed":
292-
{
293-
reservedIP := reservedIPTargetSupported.(*vpcv1.LoadBalancerProfileReservedIPTargetSupportedFixed)
294-
d.Set("reserved_ip_target_supported", reservedIP.Value)
295-
d.Set("reserved_ip_type", reservedIP.Type)
296-
}
297-
case "*vpcv1.LoadBalancerProfileReservedIPTargetSupportedDependent":
298-
{
299-
reservedIP := reservedIPTargetSupported.(*vpcv1.LoadBalancerProfileReservedIPTargetSupportedDependent)
300-
if reservedIP.Type != nil {
301-
d.Set("reserved_ip_type", *reservedIP.Type)
302-
}
303-
}
304-
case "*vpcv1.LoadBalancerProfileReservedIPTargetSupported":
305-
{
306-
reservedIP := reservedIPTargetSupported.(*vpcv1.LoadBalancerProfileReservedIPTargetSupported)
307-
if reservedIP.Type != nil {
308-
d.Set("reserved_ip_type", *reservedIP.Type)
309-
}
310-
if reservedIP.Value != nil {
311-
d.Set("reserved_ip_target_supported", *reservedIP.Value)
312-
}
313-
}
304+
305+
if loadBalancerProfile.TargetableResourceTypes != nil {
306+
err = d.Set("targetable_resource_types", dataSourceTargetableResourceTypes(*loadBalancerProfile.TargetableResourceTypes))
307+
if err != nil {
308+
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting targetable_resource_types: %s", err), "(Data) ibm_is_lb_profile", "read", "set-targetable_resource_types").GetDiag()
314309
}
315310
}
316311
d.SetId(*loadBalancerProfile.Name)
317312
return nil
318313
}
319314

315+
func dataSourceTargetableResourceTypes(result vpcv1.LoadBalancerProfileTargetableResourceTypes) (finalList []map[string]interface{}) {
316+
finalList = []map[string]interface{}{}
317+
finalMap := dataSourceTargetableResourceTypesToMap(result)
318+
finalList = append(finalList, finalMap)
319+
320+
return finalList
321+
}
322+
323+
func dataSourceTargetableResourceTypesToMap(resTermItem vpcv1.LoadBalancerProfileTargetableResourceTypes) map[string]interface{} {
324+
resTermMap := map[string]interface{}{}
325+
326+
if resTermItem.Type != nil {
327+
resTermMap["type"] = resTermItem.Type
328+
}
329+
if resTermItem.Values != nil {
330+
resTermMap["values"] = resTermItem.Values
331+
}
332+
333+
return resTermMap
334+
}
335+
320336
func dataSourceIBMIsLbProfileLoadBalancerProfileFailsafePolicyActionsToMap(model vpcv1.LoadBalancerProfileFailsafePolicyActionsIntf) (map[string]interface{}, error) {
321337
if _, ok := model.(*vpcv1.LoadBalancerProfileFailsafePolicyActionsEnum); ok {
322338
return dataSourceIBMIsLbProfileLoadBalancerProfileFailsafePolicyActionsEnumToMap(model.(*vpcv1.LoadBalancerProfileFailsafePolicyActionsEnum))

ibm/service/vpc/data_source_ibm_is_lb_profile_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestAccIBMISLBProfileDatasource_basic(t *testing.T) {
2525
resource.TestCheckResourceAttr("data.ibm_is_lb_profile.test_profile", "family", "network"),
2626
resource.TestCheckResourceAttr("data.ibm_is_lb_profile.test_profile", "route_mode_supported", "true"),
2727
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "href"),
28-
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "reserved_ip_target_supported"),
28+
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "targetable_resource_types"),
2929
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "udp_supported"),
3030
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "access_modes.0.values.#"),
3131
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "targetable_load_balancer_profiles.#"),

ibm/service/vpc/data_source_ibm_is_lb_profiles.go

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,26 @@ func DataSourceIBMISLbProfiles() *schema.Resource {
160160
},
161161
},
162162
},
163-
"reserved_ip_target_supported": {
164-
Type: schema.TypeBool,
165-
Computed: true,
166-
Description: "The Reserved IP Target support for a load balancer with this profile",
167-
},
168-
"reserved_ip_type": {
169-
Type: schema.TypeString,
170-
Computed: true,
171-
Description: "The Reserved IP Target support for a load balancer profile, one of [fixed, dependent]",
163+
"targetable_resource_types": &schema.Schema{
164+
Type: schema.TypeList,
165+
Computed: true,
166+
Elem: &schema.Resource{
167+
Schema: map[string]*schema.Schema{
168+
"type": &schema.Schema{
169+
Type: schema.TypeString,
170+
Computed: true,
171+
Description: "The type for this profile field.",
172+
},
173+
"values": &schema.Schema{
174+
Type: schema.TypeList,
175+
Computed: true,
176+
Description: "The resource types that pool members of load balancers with this profile can target",
177+
Elem: &schema.Schema{
178+
Type: schema.TypeString,
179+
},
180+
},
181+
},
182+
},
172183
},
173184
"route_mode_supported": {
174185
Type: schema.TypeBool,
@@ -305,34 +316,6 @@ func dataSourceIBMISLbProfilesRead(context context.Context, d *schema.ResourceDa
305316
}
306317
}
307318
}
308-
if profileCollector.ReservedIPTargetSupported != nil {
309-
reservedIPTargetSupported := profileCollector.ReservedIPTargetSupported
310-
switch reflect.TypeOf(reservedIPTargetSupported).String() {
311-
case "*vpcv1.LoadBalancerProfileReservedIPTargetSupportedFixed":
312-
{
313-
reservedIP := reservedIPTargetSupported.(*vpcv1.LoadBalancerProfileReservedIPTargetSupportedFixed)
314-
l["reserved_ip_target_supported"] = reservedIP.Value
315-
l["reserved_ip_type"] = reservedIP.Type
316-
}
317-
case "*vpcv1.LoadBalancerProfileReservedIPTargetSupportedDependent":
318-
{
319-
reservedIP := reservedIPTargetSupported.(*vpcv1.LoadBalancerProfileReservedIPTargetSupportedDependent)
320-
if reservedIP.Type != nil {
321-
l["reserved_ip_type"] = *reservedIP.Type
322-
}
323-
}
324-
case "*vpcv1.LoadBalancerProfileReservedIPTargetSupported":
325-
{
326-
reservedIP := reservedIPTargetSupported.(*vpcv1.LoadBalancerProfileReservedIPTargetSupported)
327-
if reservedIP.Type != nil {
328-
l["reserved_ip_type"] = *reservedIP.Type
329-
}
330-
if reservedIP.Value != nil {
331-
l["reserved_ip_target_supported"] = *reservedIP.Value
332-
}
333-
}
334-
}
335-
}
336319
if profileCollector.RouteModeSupported != nil {
337320
routeMode := profileCollector.RouteModeSupported
338321
switch reflect.TypeOf(routeMode).String() {
@@ -380,6 +363,10 @@ func dataSourceIBMISLbProfilesRead(context context.Context, d *schema.ResourceDa
380363
l["targetable_load_balancer_profiles"] = dataSourceLbProfileFlattenTargetableLoadBalancerProfiles(profileCollector.TargetableLoadBalancerProfiles)
381364
}
382365

366+
if profileCollector.TargetableResourceTypes != nil {
367+
l["targetable_resource_types"] = dataSourceTargetableResourceTypes(*profileCollector.TargetableResourceTypes)
368+
}
369+
383370
if profileCollector.Availability != nil {
384371
availabilitySupport := profileCollector.Availability.(*vpcv1.LoadBalancerProfileAvailability)
385372
availabilitySupportMap := map[string]interface{}{}

ibm/service/vpc/data_source_ibm_is_lb_profiles_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestAccIBMISLBProfilesDatasource_basic(t *testing.T) {
2525
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.access_modes.#"),
2626
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.access_modes.0.values.#"),
2727
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.targetable_load_balancer_profiles.#"),
28-
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.reserved_ip_target_supported"),
28+
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.targetable_resource_types"),
2929
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.route_mode_supported"),
3030
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.href"),
3131
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.udp_supported"),
@@ -73,7 +73,7 @@ func TestAccIBMISLBProfilesDatasource_filter(t *testing.T) {
7373
resource.TestCheckResourceAttr("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.family", "Network"),
7474
resource.TestCheckResourceAttr("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.route_mode_supported", "true"),
7575
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.href"),
76-
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.reserved_ip_target_supported"),
76+
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.targetable_resource_types"),
7777
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.udp_supported"),
7878
),
7979
},

ibm/service/vpc/data_source_ibm_is_lbs.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ func DataSourceIBMISLBS() *schema.Resource {
136136
Computed: true,
137137
Description: "Indicates whether this load balancer supports source IP session persistence.",
138138
},
139-
isLBReservedIPtargetSupported: {
140-
Type: schema.TypeBool,
141-
Computed: true,
142-
Description: "Indicates whether this load balancer supports members with reserved IP as target.",
143-
},
144139
isLBUdpSupported: {
145140
Type: schema.TypeBool,
146141
Computed: true,
@@ -418,9 +413,6 @@ func getLbs(context context.Context, d *schema.ResourceData, meta interface{}) d
418413
if lb.RouteMode != nil {
419414
lbInfo[isLBRouteMode] = *lb.RouteMode
420415
}
421-
if lb.ReservedIPTargetSupported != nil {
422-
lbInfo[isLBReservedIPtargetSupported] = *lb.ReservedIPTargetSupported
423-
}
424416
if lb.UDPSupported != nil {
425417
lbInfo[isLBUdpSupported] = *lb.UDPSupported
426418
}

ibm/service/vpc/resource_ibm_is_lb.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const (
4242
isLBDeleted = "done"
4343
isLBProvisioning = "provisioning"
4444
isLBProvisioningDone = "done"
45-
isLBReservedIPtargetSupported = "reserved_ip_target_supported"
4645
isLBResourceGroup = "resource_group"
4746
isLBProfile = "profile"
4847
isLBRouteMode = "route_mode"
@@ -296,13 +295,6 @@ func ResourceIBMISLB() *schema.Resource {
296295
Set: flex.ResourceIBMVPCHash,
297296
Description: "List of access management tags",
298297
},
299-
300-
isLBReservedIPtargetSupported: {
301-
Type: schema.TypeBool,
302-
Computed: true,
303-
Description: "Indicates whether this load balancer supports members with reserved IP as target.",
304-
},
305-
306298
isLBResourceGroup: {
307299
Type: schema.TypeString,
308300
ForceNew: true,
@@ -798,9 +790,6 @@ func lbGet(context context.Context, d *schema.ResourceData, meta interface{}, id
798790
err = fmt.Errorf("Error setting hostname: %s", err)
799791
return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_lb", "read", "set-hostname").GetDiag()
800792
}
801-
if lb.ReservedIPTargetSupported != nil {
802-
d.Set(isLBReservedIPtargetSupported, *lb.ReservedIPTargetSupported)
803-
}
804793
if loadBalancer.UDPSupported != nil {
805794
if err = d.Set(isLBUdpSupported, *loadBalancer.UDPSupported); err != nil {
806795
err = fmt.Errorf("Error setting udp_supported: %s", err)

ibm/service/vpc/resource_ibm_is_lb_pool_member_test.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -589,47 +589,6 @@ func testAccCheckIBMISLBPoolMemberIDConfigWithLBTarget(vpcname, subnetname, zone
589589
`, vpcname, subnetname, zone, cidr, albName, nlbName, nlbPoolName)
590590
}
591591

592-
func testAccCheckIBMISLBPoolMemberIDConfigWithLBTarget(vpcname, subnetname, zone, cidr, albName, nlbName, nlbPoolName string) string {
593-
return fmt.Sprintf(`
594-
resource "ibm_is_vpc" "testacc_vpc" {
595-
name = "%s"
596-
}
597-
resource "ibm_is_subnet" "testacc_subnet" {
598-
name = "%s"
599-
vpc = "${ibm_is_vpc.testacc_vpc.id}"
600-
zone = "%s"
601-
ipv4_cidr_block = "%s"
602-
}
603-
resource "ibm_is_lb" "testacc_LB" {
604-
name = "%s"
605-
subnets = ["${ibm_is_subnet.testacc_subnet.id}"]
606-
}
607-
resource "ibm_is_lb" "testacc_NLB" {
608-
name = "%s"
609-
subnets = ["${ibm_is_subnet.testacc_subnet.id}"]
610-
profile = "network-private-path"
611-
type = "private_path"
612-
}
613-
resource "ibm_is_lb_pool" "testacc_nlb_pool" {
614-
name = "%s"
615-
lb = "${ibm_is_lb.testacc_NLB.id}"
616-
algorithm = "weighted_round_robin"
617-
protocol = "tcp"
618-
health_delay = 60
619-
health_retries = 5
620-
health_timeout = 30
621-
health_type = "tcp"
622-
}
623-
resource "ibm_is_lb_pool_member" "testacc_nlb_mem" {
624-
lb = "${ibm_is_lb.testacc_NLB.id}"
625-
pool = "${element(split("/",ibm_is_lb_pool.testacc_nlb_pool.id),1)}"
626-
port = 8080
627-
weight = 20
628-
target_id = "${ibm_is_lb.testacc_LB.id}"
629-
}
630-
`, vpcname, subnetname, zone, cidr, albName, nlbName, nlbPoolName)
631-
}
632-
633592
func testAccCheckIBMISLBPoolMemberIDConfigWithReservedIPTarget(vpcname, subnetname, resIpSubnetName, zone, cidr, sshname, publickey,
634593
isImageName, vsiName, nlbName, nlbPoolName string) string {
635594
return fmt.Sprintf(`

0 commit comments

Comments
 (0)