Skip to content

Commit

Permalink
Update(CDSSCluster): Improved duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
youngmn authored and wonchulee committed Dec 7, 2023
1 parent 72ac7ef commit efe430c
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions internal/service/cdss/cdss_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,17 @@ func resourceNcloudCDSSClusterRead(ctx context.Context, d *schema.ResourceData,
var bList []map[string]interface{}
var eList []map[string]interface{}

c := d.Get("cmak").([]interface{})
if len(c) == 0 { // API response not support user_password. Not currently available during import
cList = append(cList, map[string]interface{}{
"user_name": cluster.KafkaManagerUserName,
"user_password": cluster.KafkaManagerUserPassword,
})
} else { // Create exist in config
cMap := c[0].(map[string]interface{})
cList = append(cList, map[string]interface{}{
"user_name": cluster.KafkaManagerUserName,
"user_password": cMap["user_password"],
})
var userPassword string // API response not support user_password. Not currently available during import
if c, ok := d.GetOk("cmak"); ok { // Create exist in config
cMap := c.([]interface{})[0].(map[string]interface{})
userPassword = cMap["user_password"].(string)
}

cList = append(cList, map[string]interface{}{
"user_name": cluster.KafkaManagerUserName,
"user_password": userPassword,
})

mList = append(mList, map[string]interface{}{
"node_product_code": cluster.ManagerNodeProductCode,
"subnet_no": strconv.Itoa(int(cluster.ManagerNodeSubnetNo)),
Expand Down

0 comments on commit efe430c

Please sign in to comment.