use Backup CR labels as tags for snapshots (#1729)

* use Backup CR labels as tags for snapshots

This allows users to define custom tags to be added to snapshots, by
specifying custom labels on the Backup CR with the `velero backup create
--labels` flag.

Signed-off-by: Adnan Abdulhussein <aadnan@vmware.com>
This commit is contained in:
Adnan Abdulhussein
2019-08-06 13:01:36 -07:00
committed by KubeKween
parent de442c1106
commit 4e1b1f9457
2 changed files with 6 additions and 3 deletions
+1
View File
@@ -0,0 +1 @@
adds the ability to define custom tags to be added to snapshots by specifying custom labels on the Backup CR with the velero backup create --labels flag
+5 -3
View File
@@ -435,10 +435,12 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log
log = log.WithField("volumeID", volumeID)
tags := map[string]string{
"velero.io/backup": ib.backupRequest.Name,
"velero.io/pv": pv.Name,
tags := ib.backupRequest.GetLabels()
if tags == nil {
tags = map[string]string{}
}
tags["velero.io/backup"] = ib.backupRequest.Name
tags["velero.io/pv"] = pv.Name
log.Info("Getting volume information")
volumeType, iops, err := volumeSnapshotter.GetVolumeInfo(volumeID, pvFailureDomainZone)