Merge pull request #6771 from qiuming-best/bsl-fix

Fix default BSL setting not work
This commit is contained in:
qiuming
2023-12-05 19:09:50 +08:00
committed by GitHub
8 changed files with 276 additions and 56 deletions

View File

@@ -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
}