Skip to content

Commit

Permalink
fix(region): trim metadata key (#18775)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioito authored Nov 24, 2023
1 parent 4d7cbb9 commit c5e8856
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/cloudcommon/db/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ func (manager *SMetadataManager) rawSetValues(ctx context.Context, objType strin
keys := make([]string, 0, len(store))
changes := make([]sMetadataChange, 0)
for key, value := range store {
key = strings.TrimSpace(key)
keys = append(keys, key)

record := SMetadata{}
Expand Down Expand Up @@ -708,7 +709,7 @@ func (manager *SMetadataManager) rawGetAll(objType, objId string, keys []string,
ret := make(map[string]string)
for _, rec := range records {
if len(rec.Value) > 0 || strings.HasPrefix(rec.Key, USER_TAG_PREFIX) || strings.HasPrefix(rec.Key, CLOUD_TAG_PREFIX) {
ret[rec.Key] = rec.Value
ret[strings.TrimSpace(rec.Key)] = rec.Value
}
}
return ret, nil
Expand Down Expand Up @@ -771,7 +772,7 @@ func metaList2Map(manager IMetadataBaseModelManager, userCred mcclient.TokenCred
hiddenKeys := manager.GetMetadataHiddenKeys()
for _, meta := range metaList {
if IsMetadataKeyVisible(meta.Key) && !utils.IsInStringArray(meta.Key, hiddenKeys) {
metaMap[meta.Key] = meta.Value
metaMap[strings.TrimSpace(meta.Key)] = meta.Value
}
}

Expand Down

0 comments on commit c5e8856

Please sign in to comment.