From c2af4c41f0ceecd17ef53705a318d89432c28d94 Mon Sep 17 00:00:00 2001 From: nikolay-spectro Date: Thu, 28 Sep 2023 08:22:21 -0700 Subject: [PATCH] PLT-658: fixing unit test. --- spectrocloud/cluster_common_hash.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/spectrocloud/cluster_common_hash.go b/spectrocloud/cluster_common_hash.go index af7968b1..5e716328 100644 --- a/spectrocloud/cluster_common_hash.go +++ b/spectrocloud/cluster_common_hash.go @@ -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 { @@ -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()))