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

fix(lb): fix for lb data source collection #5763

Merged
merged 3 commits into from
Nov 6, 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
2 changes: 1 addition & 1 deletion ibm/service/vpc/data_source_ibm_is_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func lbGetByName(d *schema.ResourceData, meta interface{}, name string) error {
if lb.Logging != nil && lb.Logging.Datapath != nil {
d.Set(isLBLogging, *lb.Logging.Datapath.Active)
}
if *lb.IsPublic {
if lb.IsPublic != nil && *lb.IsPublic {
d.Set(isLBType, "public")
} else if lb.IsPrivatePath != nil && *lb.IsPrivatePath {
d.Set(isLBType, "private_path")
Expand Down
4 changes: 2 additions & 2 deletions ibm/service/vpc/data_source_ibm_is_lbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ func getLbs(d *schema.ResourceData, meta interface{}) error {
lbInfo[ProvisioningStatus] = *lb.ProvisioningStatus

lbInfo[CreatedAt] = lb.CreatedAt.String()
if *lb.IsPublic {
if lb.IsPublic != nil && *lb.IsPublic {
lbInfo[isLBType] = "public"
} else if *lb.IsPrivatePath {
} else if lb.IsPrivatePath != nil && *lb.IsPrivatePath {
lbInfo[isLBType] = "private_path"
} else {
lbInfo[isLBType] = "private"
Expand Down
12 changes: 8 additions & 4 deletions ibm/service/vpc/data_source_ibm_is_lbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func TestAccIBMISLBSDatasource_basic(t *testing.T) {
testAccCheckIBMISLBExists("ibm_is_lb.testacc_lb", lb),
resource.TestCheckResourceAttr(
"data.ibm_is_lb.ds_lb", "name", name),
resource.TestCheckResourceAttrSet("data.ibm_is_lbs.ds_lb", "load_balancers.0.availability"),
resource.TestCheckResourceAttrSet("data.ibm_is_lbs.ds_lb", "load_balancers.0.instance_groups_supported"),
resource.TestCheckResourceAttrSet("data.ibm_is_lbs.ds_lb", "load_balancers.0.source_ip_persistence_supported"),
resource.TestCheckResourceAttrSet("data.ibm_is_lbs.test_lbs", "load_balancers.0.availability"),
resource.TestCheckResourceAttrSet("data.ibm_is_lbs.test_lbs", "load_balancers.0.instance_groups_supported"),
resource.TestCheckResourceAttrSet("data.ibm_is_lbs.test_lbs", "load_balancers.0.source_ip_session_persistence_supported"),
),
},
{
Expand Down Expand Up @@ -101,7 +101,11 @@ func testDSCheckIBMISLBSConfig(vpcname, subnetname, zone, cidr, name string) str
}
data "ibm_is_lb" "ds_lb" {
name = ibm_is_lb.testacc_lb.name
}`, vpcname, subnetname, zone, cidr, name)
}
data "ibm_is_lbs" "test_lbs" {
depends_on = [ibm_is_lb.testacc_lb]
}
`, vpcname, subnetname, zone, cidr, name)
}
func testDSCheckIBMISLBSDatasourceConfig() string {
// status filter defaults to empty
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/vpc/resource_ibm_is_lb.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func lbGet(d *schema.ResourceData, meta interface{}, id string) error {
d.Set("dns", nil)
}
d.Set(isLBName, *lb.Name)
if *lb.IsPublic {
if lb.IsPublic != nil && *lb.IsPublic {
d.Set(isLBType, "public")
} else {
if lb.IsPrivatePath != nil && *lb.IsPrivatePath {
Expand Down
Loading