Skip to content

Commit 816cb83

Browse files
authored
Remove duplicate default plugins (#555)
1 parent a101e9a commit 816cb83

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

controllers/velero.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ func (r *DPAReconciler) buildVeleroDeployment(veleroDeployment *appsv1.Deploymen
376376
}
377377
r.ReconcileRestoreResourcesVersionPriority(dpa)
378378

379+
// TODO! Reuse removeDuplicateValues with interface type
380+
dpa.Spec.Configuration.Velero.DefaultPlugins = removeDuplicatePluginValues(dpa.Spec.Configuration.Velero.DefaultPlugins)
379381
dpa.Spec.Configuration.Velero.FeatureFlags = removeDuplicateValues(dpa.Spec.Configuration.Velero.FeatureFlags)
380382
deploymentName := veleroDeployment.Name //saves desired deployment name before install.Deployment overwrites them.
381383
ownerRefs := veleroDeployment.OwnerReferences // saves desired owner refs
@@ -395,6 +397,21 @@ func (r *DPAReconciler) buildVeleroDeployment(veleroDeployment *appsv1.Deploymen
395397
return r.customizeVeleroDeployment(dpa, veleroDeployment)
396398
}
397399

400+
func removeDuplicatePluginValues(slice []oadpv1alpha1.DefaultPlugin) []oadpv1alpha1.DefaultPlugin {
401+
if slice == nil {
402+
return nil
403+
}
404+
keys := make(map[oadpv1alpha1.DefaultPlugin]bool)
405+
list := []oadpv1alpha1.DefaultPlugin{}
406+
for _, entry := range slice {
407+
if _, found := keys[entry]; !found { //add entry to list if not found in keys already
408+
keys[entry] = true
409+
list = append(list, entry)
410+
}
411+
}
412+
return list // return the result through the passed in argument
413+
}
414+
398415
// remove duplicate entry in string slice
399416
func removeDuplicateValues(slice []string) []string {
400417
if slice == nil {

0 commit comments

Comments
 (0)