Skip to content

Commit

Permalink
PLT-658: fixing unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikchern committed Sep 28, 2023
1 parent ca542b9 commit c2af4c4
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions spectrocloud/cluster_common_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@ func resourceMachinePoolEksHash(v interface{}) int {
buf.WriteString(fmt.Sprintf("%s-", m["capacity_type"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["max_price"].(string)))

for i, j := range m["az_subnets"].(map[string]interface{}) {
buf.WriteString(fmt.Sprintf("%s-%s", i, j.(string)))
keys := make([]string, 0, len(m["az_subnets"].(map[string]interface{})))
for k := range m["az_subnets"].(map[string]interface{}) {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
buf.WriteString(fmt.Sprintf("%s-%s", k, m["az_subnets"].(map[string]interface{})[k].(string)))
}

if m["eks_launch_template"] != nil {
Expand Down Expand Up @@ -194,8 +199,13 @@ func resourceMachinePoolTkeHash(v interface{}) int {
m := v.(map[string]interface{})
buf := CommonHash(m)

for i, j := range m["az_subnets"].(map[string]interface{}) {
buf.WriteString(fmt.Sprintf("%s-%s", i, j.(string)))
keys := make([]string, 0, len(m["az_subnets"].(map[string]interface{})))
for k := range m["az_subnets"].(map[string]interface{}) {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
buf.WriteString(fmt.Sprintf("%s-%s", k, m["az_subnets"].(map[string]interface{})[k].(string)))
}

return int(hash(buf.String()))
Expand Down

0 comments on commit c2af4c4

Please sign in to comment.