From b04d6b02f38804f11cc39ebbb9cdb8b7b4395444 Mon Sep 17 00:00:00 2001 From: Steve Kriss Date: Wed, 27 Mar 2019 17:07:53 -0600 Subject: [PATCH] remove support for legacy restic annotations Signed-off-by: Steve Kriss --- pkg/restic/common.go | 26 +------------------------- pkg/restic/common_test.go | 34 ---------------------------------- 2 files changed, 1 insertion(+), 59 deletions(-) diff --git a/pkg/restic/common.go b/pkg/restic/common.go index 67502a09a..ca2805167 100644 --- a/pkg/restic/common.go +++ b/pkg/restic/common.go @@ -40,10 +40,6 @@ const ( podAnnotationPrefix = "snapshot.velero.io/" volumesToBackupAnnotation = "backup.velero.io/backup-volumes" - - // TODO(1.0) remove both legacy annotations - podAnnotationLegacyPrefix = "snapshot.ark.heptio.com/" - volumesToBackupLegacyAnnotation = "backup.ark.heptio.com/backup-volumes" ) // PodHasSnapshotAnnotation returns true if the object has an annotation @@ -54,11 +50,6 @@ func PodHasSnapshotAnnotation(obj metav1.Object) bool { if strings.HasPrefix(key, podAnnotationPrefix) { return true } - - // TODO(1.0): remove if statement & contents - if strings.HasPrefix(key, podAnnotationLegacyPrefix) { - return true - } } return false @@ -80,16 +71,6 @@ func GetPodSnapshotAnnotations(obj metav1.Object) map[string]string { if strings.HasPrefix(k, podAnnotationPrefix) { insertSafe(k[len(podAnnotationPrefix):], v) } - - if strings.HasPrefix(k, podAnnotationLegacyPrefix) { - volume := k[len(podAnnotationLegacyPrefix):] - - // if it has the legacy prefix, only use it if there's not - // already a value in res for the volume - if _, ok := res[volume]; !ok { - insertSafe(volume, v) - } - } } return res @@ -117,12 +98,7 @@ func GetVolumesToBackup(obj metav1.Object) []string { return nil } - backupsValue, ok := annotations[volumesToBackupAnnotation] - // TODO(1.0) remove the following if statement & contents - if !ok { - backupsValue = annotations[volumesToBackupLegacyAnnotation] - } - + backupsValue := annotations[volumesToBackupAnnotation] if backupsValue == "" { return nil } diff --git a/pkg/restic/common_test.go b/pkg/restic/common_test.go index 4a7dbaefe..f6200d695 100644 --- a/pkg/restic/common_test.go +++ b/pkg/restic/common_test.go @@ -69,16 +69,6 @@ func TestPodHasSnapshotAnnotation(t *testing.T) { annotations: map[string]string{"foo": "bar", podAnnotationPrefix + "foo": "bar"}, expected: true, }, - { - name: "has legacy snapshot annotation only, with suffix", - annotations: map[string]string{podAnnotationLegacyPrefix + "foo": "bar"}, - expected: true, - }, - { - name: "has legacy and current snapshot annotations, with suffixes", - annotations: map[string]string{podAnnotationPrefix + "curr": "baz", podAnnotationLegacyPrefix + "foo": "bar"}, - expected: true, - }, } for _, test := range tests { @@ -126,20 +116,6 @@ func TestGetPodSnapshotAnnotations(t *testing.T) { annotations: map[string]string{"x": "y", podAnnotationPrefix + "foo": "bar", podAnnotationPrefix + "abc": "123"}, expected: map[string]string{"foo": "bar", "abc": "123"}, }, - { - name: "has legacy snapshot annotation only", - annotations: map[string]string{podAnnotationLegacyPrefix + "foo": "bar"}, - expected: map[string]string{"foo": "bar"}, - }, - { - name: "when current and legacy snapshot annotations exist, current wins", - annotations: map[string]string{ - podAnnotationPrefix + "foo": "current", - podAnnotationLegacyPrefix + "foo": "legacy", - podAnnotationLegacyPrefix + "bar": "baz", - }, - expected: map[string]string{"foo": "current", "bar": "baz"}, - }, } for _, test := range tests { @@ -219,16 +195,6 @@ func TestGetVolumesToBackup(t *testing.T) { annotations: map[string]string{"foo": "bar", volumesToBackupAnnotation: "volume-1,volume-2,volume-3"}, expected: []string{"volume-1", "volume-2", "volume-3"}, }, - { - name: "legacy annotation", - annotations: map[string]string{"foo": "bar", volumesToBackupLegacyAnnotation: "volume-1"}, - expected: []string{"volume-1"}, - }, - { - name: "when legacy and current annotations are both specified, current wins", - annotations: map[string]string{volumesToBackupAnnotation: "current", volumesToBackupLegacyAnnotation: "legacy"}, - expected: []string{"current"}, - }, } for _, test := range tests {