-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(CLOUD-1044): Fix update metadata for security group and snapshot
- Loading branch information
Aleksandr Semenov
committed
Feb 3, 2025
1 parent
3a3c23a
commit 19eb9ea
Showing
3 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package edgecenter | ||
|
||
type SnapshotMetadata = map[string]interface{} | ||
|
||
type SnapshotReadOnlyMetadata = []map[string]interface{} | ||
|
||
var snapshotReadOnlyTags = map[string]struct{}{ | ||
"bootable": {}, | ||
"task_id": {}, | ||
"volume_name": {}, | ||
"volume_type": {}, | ||
} | ||
|
||
// separateMetadata takes a map of string key-value pairs (md) and separates it into two distinct collections | ||
// Parameters: | ||
// - md: A map of string key-value pairs representing metadata to be separated. | ||
// | ||
// Returns: | ||
// - SnapshotMetadata: A map containing metadata that is mutable. | ||
// - SnapshotReadOnlyMetadata: A slice containing metadata that is read-only. | ||
func separateMetadata(md map[string]string) (SnapshotMetadata, SnapshotReadOnlyMetadata) { | ||
metadata := make(SnapshotMetadata) | ||
metadataReadOnly := make(SnapshotReadOnlyMetadata, 0, len(md)) | ||
|
||
for k, v := range md { | ||
if _, ok := snapshotReadOnlyTags[k]; ok { | ||
metadataReadOnly = append( | ||
metadataReadOnly, | ||
SnapshotMetadata{ | ||
"key": k, | ||
"value": v, | ||
"read_only": true, | ||
}) | ||
continue | ||
} | ||
|
||
metadata[k] = v | ||
} | ||
|
||
return metadata, metadataReadOnly | ||
} |