CLI: SharePoint --data flag and wildcards (#2580)

## Description
Enables feature SharePoint to use "wildcard" to select all available sites with the ability to only backup selected categories.

Example 
```bash
./corso backup create sharepoint --web-url "*" --data libraries
```



<!-- Insert PR description-->

## Does this PR need a docs update or release note?
- [x]  No 

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🐛 Bugfix


## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* closes #2579<issue>

## Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
This commit is contained in:
Danny 2023-02-20 16:21:27 -05:00 committed by GitHub
parent 960cb45ca8
commit 7ba3be5242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -303,19 +303,13 @@ func sharePointBackupCreateSelectors(
for _, site := range sites {
if site == utils.Wildcard {
sel := selectors.NewSharePointBackup(selectors.Any())
sel.Include(sel.AllData())
return sel, nil
return includeAllSitesWithCategories(cats), nil
}
}
for _, wURL := range weburls {
if wURL == utils.Wildcard {
sel := selectors.NewSharePointBackup(selectors.Any())
sel.Include(sel.AllData())
return sel, nil
return includeAllSitesWithCategories(cats), nil
}
}
@ -328,10 +322,21 @@ func sharePointBackupCreateSelectors(
}
sel := selectors.NewSharePointBackup(union)
return addCategories(sel, cats), nil
}
func includeAllSitesWithCategories(categories []string) *selectors.SharePointBackup {
sel := addCategories(
selectors.NewSharePointBackup(selectors.Any()),
categories)
return sel
}
func addCategories(sel *selectors.SharePointBackup, cats []string) *selectors.SharePointBackup {
if len(cats) == 0 {
sel.Include(sel.AllData())
return sel, nil
}
for _, d := range cats {
@ -343,7 +348,7 @@ func sharePointBackupCreateSelectors(
}
}
return sel, nil
return sel
}
// ------------------------------------------------------------------------------------------------