mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-15 19:56:06 +00:00
Move 'velero.io/exclude-from-backup' label string to const (#5053)
* move 'velero.io/exclude-from-backup' label name to const Signed-off-by: Niu Lechuan <lechuan.niu@daocloud.io> * add changelog file (in changelogs/unreleased) of this PR Signed-off-by: Niu Lechuan <lechuan.niu@daocloud.io>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Move 'velero.io/exclude-from-backup' label string to const
|
||||
@@ -61,6 +61,11 @@ type itemBackupper struct {
|
||||
snapshotLocationVolumeSnapshotters map[string]velero.VolumeSnapshotter
|
||||
}
|
||||
|
||||
const (
|
||||
// veleroExcludeFromBackupLabel labeled item should be exclude by velero in backup job.
|
||||
veleroExcludeFromBackupLabel = "velero.io/exclude-from-backup"
|
||||
)
|
||||
|
||||
// backupItem backs up an individual item to tarWriter. The item may be excluded based on the
|
||||
// namespaces IncludesExcludes list.
|
||||
// In addition to the error return, backupItem also returns a bool indicating whether the item
|
||||
@@ -78,8 +83,8 @@ func (ib *itemBackupper) backupItem(logger logrus.FieldLogger, obj runtime.Unstr
|
||||
log = log.WithField("resource", groupResource.String())
|
||||
log = log.WithField("namespace", namespace)
|
||||
|
||||
if metadata.GetLabels()["velero.io/exclude-from-backup"] == "true" {
|
||||
log.Info("Excluding item because it has label velero.io/exclude-from-backup=true")
|
||||
if metadata.GetLabels()[veleroExcludeFromBackupLabel] == "true" {
|
||||
log.Infof("Excluding item because it has label %s=true", veleroExcludeFromBackupLabel)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user