From 30313ab2f20f458e1b4c7ecebd4190573ade5685 Mon Sep 17 00:00:00 2001 From: Tao <104055472+teowa@users.noreply.github.com> Date: Fri, 15 Sep 2023 15:40:40 +0800 Subject: [PATCH] optmize location compare --- .../appconfiguration/app_configuration_resource.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/services/appconfiguration/app_configuration_resource.go b/internal/services/appconfiguration/app_configuration_resource.go index de2af0a036ce5..a14759c4c18ca 100644 --- a/internal/services/appconfiguration/app_configuration_resource.go +++ b/internal/services/appconfiguration/app_configuration_resource.go @@ -778,22 +778,19 @@ func expandAppConfigurationReplicas(input []interface{}, configurationStoreName, // check if there are duplicated replica names or locations // location cannot be same as original configuration store and other replicas - const placeholder = "" - locationSet := map[string]string{ - configurationStoreLocation: placeholder, - } + locationSet := map[string]string{} replicaNameSet := map[string]struct{}{} for _, v := range input { replica := v.(map[string]interface{}) replicaName := replica["name"].(string) replicaLocation := location.Normalize(replica["location"].(string)) + if strings.EqualFold(replicaLocation, configurationStoreLocation) { + return nil, fmt.Errorf("location (%q) of replica %q is duplicated with original configuration store %q", replicaName, replicaLocation, configurationStoreName) + } if name, ok := locationSet[replicaLocation]; ok { - if name == placeholder { - return nil, fmt.Errorf("replica %q location %q is duplicated with original configuration store %q", replicaName, replicaLocation, configurationStoreName) - } - return nil, fmt.Errorf("replica %q location %q is duplicated with replica %q", replicaName, replicaLocation, name) + return nil, fmt.Errorf("location (%q) of replica %q is duplicated with replica %q", replicaName, replicaLocation, name) } locationSet[replicaLocation] = replicaName