mirror of
https://github.com/vmware-tanzu/velero.git
synced 2025-12-23 06:15:21 +00:00
Merge pull request #6771 from qiuming-best/bsl-fix
Fix default BSL setting not work
This commit is contained in:
@@ -18,6 +18,7 @@ package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -92,3 +93,18 @@ func ListBackupStorageLocations(ctx context.Context, kbClient client.Client, nam
|
||||
|
||||
return locations, nil
|
||||
}
|
||||
|
||||
func GetDefaultBackupStorageLocations(ctx context.Context, kbClient client.Client, namespace string) (*velerov1api.BackupStorageLocationList, error) {
|
||||
locations := new(velerov1api.BackupStorageLocationList)
|
||||
defaultLocations := new(velerov1api.BackupStorageLocationList)
|
||||
if err := kbClient.List(context.Background(), locations, &client.ListOptions{Namespace: namespace}); err != nil {
|
||||
return defaultLocations, errors.Wrapf(err, fmt.Sprintf("failed to list backup storage locations in namespace %s", namespace))
|
||||
}
|
||||
|
||||
for _, location := range locations.Items {
|
||||
if location.Spec.Default {
|
||||
defaultLocations.Items = append(defaultLocations.Items, location)
|
||||
}
|
||||
}
|
||||
return defaultLocations, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user