Skip to content

Commit

Permalink
modify variables defination and expose err
Browse files Browse the repository at this point in the history
Signed-off-by: allenxu404 <[email protected]>
  • Loading branch information
allenxu404 committed Aug 8, 2022
1 parent eb08bde commit e5d828a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/controller/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,13 @@ func (c *backupController) prepareBackupRequest(backup *velerov1api.Backup) *pkg

// Add namespaces with label velero.io/exclude-from-backup=true into request.Spec.ExcludedNamespaces
// Essentially, adding the label velero.io/exclude-from-backup=true to a namespace would be equivalent to setting spec.ExcludedNamespaces
namespaces, excludeLabel := corev1api.NamespaceList{}, "velero.io/exclude-from-backup"
if err := c.kbClient.List(context.Background(), &namespaces, kbclient.MatchingLabels{excludeLabel: "true"}); err == nil {
namespaces := corev1api.NamespaceList{}
if err := c.kbClient.List(context.Background(), &namespaces, kbclient.MatchingLabels{"velero.io/exclude-from-backup": "true"}); err == nil {
for _, ns := range namespaces.Items {
request.Spec.ExcludedNamespaces = append(request.Spec.ExcludedNamespaces, ns.Name)
}
} else {
request.Status.ValidationErrors = append(request.Status.ValidationErrors, fmt.Sprintf("error getting namespace list: %v", err))
}

// validate the included/excluded resources
Expand Down

0 comments on commit e5d828a

Please sign in to comment.