Skip to content

Commit

Permalink
refactor(Cloud Databases) autoscaling uses cloud-databases-go-sdk (IB…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhemard authored and ADYA NAND JHA committed Feb 2, 2023
1 parent 79ce830 commit 3528f08
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 189 deletions.
16 changes: 11 additions & 5 deletions ibm/service/database/data_source_ibm_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"path/filepath"

"github.com/IBM/cloud-databases-go-sdk/clouddatabasesv5"
"github.com/IBM/go-sdk-core/v5/core"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM-Cloud/bluemix-go/api/icd/icdv4"
Expand Down Expand Up @@ -747,12 +748,12 @@ func dataSourceIBMDatabaseInstanceRead(d *schema.ResourceData, meta interface{})
}
d.Set(flex.ResourceControllerURL, rcontroller+"/services/"+url.QueryEscape(instance.Crn.String()))

icdClient, err := meta.(conns.ClientSession).ICDAPI()
cloudDatabasesClient, err := meta.(conns.ClientSession).CloudDatabasesV5()
if err != nil {
return fmt.Errorf("[ERROR] Error getting database client settings: %s", err)
}

cloudDatabasesClient, err := meta.(conns.ClientSession).CloudDatabasesV5()
icdClient, err := meta.(conns.ClientSession).ICDAPI()
if err != nil {
return fmt.Errorf("[ERROR] Error getting database client settings: %s", err)
}
Expand All @@ -779,11 +780,16 @@ func dataSourceIBMDatabaseInstanceRead(d *schema.ResourceData, meta interface{})
d.Set("members_memory_allocation_mb", groupList.Groups[0].Memory.AllocationMb)
d.Set("members_disk_allocation_mb", groupList.Groups[0].Disk.AllocationMb)

autoSclaingGroup, err := icdClient.AutoScaling().GetAutoScaling(icdId, "member")
getAutoscalingConditionsOptions := &clouddatabasesv5.GetAutoscalingConditionsOptions{
ID: &instance.ID,
GroupID: core.StringPtr("member"),
}

autoscalingGroup, _, err := cloudDatabasesClient.GetAutoscalingConditions(getAutoscalingConditionsOptions)
if err != nil {
return fmt.Errorf("[ERROR] Error getting database groups: %s", err)
return fmt.Errorf("[ERROR] Error getting database autoscaling groups: %s", err)
}
d.Set("auto_scaling", flattenICDAutoScalingGroup(autoSclaingGroup))
d.Set("auto_scaling", flattenAutoScalingGroup(*autoscalingGroup))

alEntry := &clouddatabasesv5.GetAllowlistOptions{
ID: &instance.ID,
Expand Down
Loading

0 comments on commit 3528f08

Please sign in to comment.