remove support for legacy restic annotations
Signed-off-by: Steve Kriss <krisss@vmware.com>pull/1323/head
parent
7f36f78aee
commit
b04d6b02f3
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue