mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rbd: set metadata on the snapshot
Set snapshot-name/snapshot-namespace/snapshotcontent-name details on RBD backend snapshot image as metadata on snapshot Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
463990c999
commit
41fe2c7dda
@ -29,6 +29,11 @@ const (
|
||||
pvcNameKey = "csi.storage.k8s.io/pvc/name"
|
||||
pvcNamespaceKey = "csi.storage.k8s.io/pvc/namespace"
|
||||
pvNameKey = "csi.storage.k8s.io/pv/name"
|
||||
|
||||
// snapshot metadata keys.
|
||||
volSnapNameKey = "csi.storage.k8s.io/volumesnapshot/name"
|
||||
volSnapNamespaceKey = "csi.storage.k8s.io/volumesnapshot/namespace"
|
||||
volSnapContentNameKey = "csi.storage.k8s.io/volumesnapshotcontent/name"
|
||||
)
|
||||
|
||||
// RemoveCSIPrefixedParameters removes parameters prefixed with csiParameterPrefix.
|
||||
@ -79,3 +84,19 @@ func PrepareVolumeMetadata(pvcName, pvcNamespace, pvName string) map[string]stri
|
||||
|
||||
return newParam
|
||||
}
|
||||
|
||||
// GetSnapshotMetadata filter parameters, only return
|
||||
// snapshot-name/snapshot-namespace/snapshotcontent-name metadata.
|
||||
func GetSnapshotMetadata(parameters map[string]string) map[string]string {
|
||||
keys := []string{volSnapNameKey, volSnapNamespaceKey, volSnapContentNameKey}
|
||||
newParam := map[string]string{}
|
||||
for k, v := range parameters {
|
||||
for _, key := range keys {
|
||||
if strings.Contains(k, key) {
|
||||
newParam[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newParam
|
||||
}
|
||||
|
Reference in New Issue
Block a user