From 909eeeb782ef31ce62f6d919f3c515b711f5da63 Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Tue, 27 Apr 2021 11:54:10 +0800 Subject: [PATCH] fix(region): tag list key case insensitive --- pkg/cloudcommon/db/metadata.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/cloudcommon/db/metadata.go b/pkg/cloudcommon/db/metadata.go index 2fca8775d9..46142c4391 100644 --- a/pkg/cloudcommon/db/metadata.go +++ b/pkg/cloudcommon/db/metadata.go @@ -247,9 +247,15 @@ func (manager *SMetadataManager) metaDataQuery2List(ctx context.Context, q *sqlc if err != nil { return nil, errors.Wrap(err, "Query.All") } + ciMap := map[string]string{} ret := make([]jsonutils.JSONObject, len(metadatas)) for i := range metadatas { + if k, ok := ciMap[strings.ToLower(metadatas[i].Key)]; !ok { + ciMap[strings.ToLower(metadatas[i].Key)] = metadatas[i].Key + } else { + metadatas[i].Key = k + } if input.Details != nil && *input.Details { ret[i], err = manager.getKeyValueObjectCount(ctx, userCred, input, metadatas[i].Key, metadatas[i].Value, metadatas[i].Count) if err != nil {