Compare commits
11 Commits
main
...
2602-exten
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d3a46d8a6 | ||
|
|
b22c00424e | ||
|
|
4b58ac472f | ||
|
|
913327e016 | ||
|
|
f404b7716f | ||
|
|
b8c8201fa3 | ||
|
|
7fd47828ef | ||
|
|
77ada22b59 | ||
|
|
6707ef15a8 | ||
|
|
7c498b42c1 | ||
|
|
6bcc85a7f3 |
@ -18,18 +18,12 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// ==============================================
|
||||
// Folder Object flags
|
||||
// These options are flags for indicating
|
||||
// that a time-based filter should be used for
|
||||
// within returning objects for details.
|
||||
// Used by: OneDrive, SharePoint
|
||||
// ================================================
|
||||
// Shared Backup Globals
|
||||
// ================================================
|
||||
var (
|
||||
fileCreatedAfter string
|
||||
fileCreatedBefore string
|
||||
fileModifiedAfter string
|
||||
fileModifiedBefore string
|
||||
backupID string
|
||||
user []string
|
||||
)
|
||||
|
||||
var subCommandFuncs = []func() *cobra.Command{
|
||||
|
||||
@ -28,9 +28,7 @@ import (
|
||||
|
||||
// exchange bucket info from flags
|
||||
var (
|
||||
backupID string
|
||||
exchangeData []string
|
||||
user []string
|
||||
|
||||
contact []string
|
||||
contactFolder []string
|
||||
|
||||
@ -2,6 +2,7 @@ package backup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
@ -55,10 +56,10 @@ const (
|
||||
sharePointServiceCommandCreateExamples = `# Backup SharePoint data for <site>
|
||||
corso backup create sharepoint --site <site_id>
|
||||
|
||||
# Backup SharePoint for Alice and Bob
|
||||
corso backup create sharepoint --site <site_id_1>,<site_id_2>
|
||||
# Backup SharePoint for two different sites
|
||||
corso backup create sharepoint --web-url <url_1>,<url_2>
|
||||
|
||||
# TODO: Site IDs may contain commas. We'll need to warn the site about escaping them.
|
||||
# Site IDs may contain commas. Either use the web-url or escape the commas within the Site ID.
|
||||
|
||||
# Backup all SharePoint data for all sites
|
||||
corso backup create sharepoint --site '*'`
|
||||
@ -69,11 +70,7 @@ corso backup delete sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd`
|
||||
sharePointServiceCommandDetailsExamples = `# Explore <site>'s files from backup 1234abcd-12ab-cd34-56de-1234abcd
|
||||
|
||||
corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd --site <site_id>
|
||||
<<<<<<< HEAD
|
||||
# Explore site's files created before end of 2015 from a specific backup
|
||||
=======
|
||||
# Find all site files that were created before a certain date.
|
||||
>>>>>>> main
|
||||
corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd \
|
||||
--web-url https://example.com --file-created-before 2015-01-01T00:00:00
|
||||
`
|
||||
@ -435,10 +432,10 @@ func detailsSharePointCmd(cmd *cobra.Command, args []string) error {
|
||||
LibraryPaths: libraryPaths,
|
||||
Sites: site,
|
||||
WebURLs: weburl,
|
||||
FileCreatedAfter: fileCreatedAfter,
|
||||
FileCreatedBefore: fileCreatedBefore,
|
||||
FileModifiedAfter: fileModifiedAfter,
|
||||
FileModifiedBefore: fileModifiedBefore,
|
||||
FileCreatedAfter: utils.FileCreatedAfter,
|
||||
FileCreatedBefore: utils.FileCreatedBefore,
|
||||
FileModifiedAfter: utils.FileModifiedAfter,
|
||||
FileModifiedBefore: utils.FileModifiedBefore,
|
||||
|
||||
Populated: utils.GetPopulatedFlags(cmd),
|
||||
}
|
||||
@ -478,6 +475,7 @@ func runDetailsSharePointCmd(
|
||||
skipReduce bool,
|
||||
) (*details.Details, error) {
|
||||
if err := utils.ValidateSharePointRestoreFlags(backupID, opts); err != nil {
|
||||
fmt.Println("Fail on validate")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@ -2,14 +2,13 @@ package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/alcionai/corso/src/pkg/selectors"
|
||||
)
|
||||
|
||||
const (
|
||||
LibraryItemFN = "library-item"
|
||||
LibraryFN = "library"
|
||||
LibraryItemFN = "file"
|
||||
LibraryFN = "folder"
|
||||
ListItemFN = "list-item"
|
||||
ListFN = "list"
|
||||
PageFolderFN = "page-folders"
|
||||
@ -41,7 +40,6 @@ func ValidateSharePointRestoreFlags(backupID string, opts SharePointOpts) error
|
||||
}
|
||||
|
||||
if _, ok := opts.Populated[FileCreatedAfterFN]; ok && !IsValidTimeFormat(opts.FileCreatedAfter) {
|
||||
fmt.Printf("What was I sent: %v\n", opts.FileCreatedAfter)
|
||||
return errors.New("invalid time format for " + FileCreatedAfterFN)
|
||||
}
|
||||
|
||||
|
||||
@ -263,7 +263,7 @@ func PageInfo(page models.SitePageable, size int64) *details.SharePointInfo {
|
||||
)
|
||||
|
||||
return &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointPage,
|
||||
ItemName: name,
|
||||
Created: created,
|
||||
Modified: modified,
|
||||
|
||||
@ -18,7 +18,7 @@ func sharePointListInfo(lst models.Listable, size int64) *details.SharePointInfo
|
||||
)
|
||||
|
||||
return &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointList,
|
||||
ItemName: name,
|
||||
Created: created,
|
||||
Modified: modified,
|
||||
|
||||
@ -27,7 +27,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo() {
|
||||
{
|
||||
name: "Empty List",
|
||||
listAndDeets: func() (models.Listable, *details.SharePointInfo) {
|
||||
i := &details.SharePointInfo{ItemType: details.SharePointItem}
|
||||
i := &details.SharePointInfo{ItemType: details.SharePointList}
|
||||
return models.NewList(), i
|
||||
},
|
||||
}, {
|
||||
@ -37,7 +37,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo() {
|
||||
listing := models.NewList()
|
||||
listing.SetDisplayName(&aTitle)
|
||||
i := &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointList,
|
||||
ItemName: aTitle,
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ func sharePointPageInfo(page models.SitePageable, root string, size int64) *deta
|
||||
}
|
||||
|
||||
return &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointPage,
|
||||
ItemName: name,
|
||||
ParentPath: root,
|
||||
Created: created,
|
||||
|
||||
@ -17,7 +17,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo_Pages() {
|
||||
{
|
||||
name: "Empty Page",
|
||||
pageAndDeets: func() (models.SitePageable, *details.SharePointInfo) {
|
||||
deets := &details.SharePointInfo{ItemType: details.SharePointItem}
|
||||
deets := &details.SharePointInfo{ItemType: details.SharePointPage}
|
||||
return models.NewSitePage(), deets
|
||||
},
|
||||
},
|
||||
@ -28,7 +28,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo_Pages() {
|
||||
sPage := models.NewSitePage()
|
||||
sPage.SetTitle(&title)
|
||||
deets := &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointPage,
|
||||
ItemName: title,
|
||||
}
|
||||
|
||||
|
||||
@ -403,7 +403,9 @@ const (
|
||||
ExchangeEvent
|
||||
ExchangeMail
|
||||
|
||||
SharePointItem ItemType = iota + 100
|
||||
SharePointLibrary ItemType = iota + 100
|
||||
SharePointList ItemType = iota + 100
|
||||
SharePointPage ItemType = iota + 100
|
||||
|
||||
OneDriveItem ItemType = iota + 200
|
||||
|
||||
@ -416,7 +418,7 @@ func UpdateItem(item *ItemInfo, repoPath path.Path) error {
|
||||
var updatePath func(path.Path) error
|
||||
|
||||
switch item.infoType() {
|
||||
case SharePointItem:
|
||||
case SharePointLibrary:
|
||||
updatePath = item.SharePoint.UpdateParentPath
|
||||
case OneDriveItem:
|
||||
updatePath = item.OneDrive.UpdateParentPath
|
||||
|
||||
@ -780,7 +780,7 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
|
||||
name: "SharePoint",
|
||||
input: ItemInfo{
|
||||
SharePoint: &SharePointInfo{
|
||||
ItemType: SharePointItem,
|
||||
ItemType: SharePointLibrary,
|
||||
ParentPath: folder1,
|
||||
},
|
||||
},
|
||||
@ -789,7 +789,7 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
|
||||
errCheck: assert.NoError,
|
||||
expectedItem: ItemInfo{
|
||||
SharePoint: &SharePointInfo{
|
||||
ItemType: SharePointItem,
|
||||
ItemType: SharePointLibrary,
|
||||
ParentPath: folder2,
|
||||
},
|
||||
},
|
||||
@ -810,7 +810,7 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
|
||||
name: "SharePointBadPath",
|
||||
input: ItemInfo{
|
||||
SharePoint: &SharePointInfo{
|
||||
ItemType: SharePointItem,
|
||||
ItemType: SharePointLibrary,
|
||||
ParentPath: folder1,
|
||||
},
|
||||
},
|
||||
|
||||
@ -214,7 +214,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
RepoRef: item,
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointLibrary,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -222,7 +222,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
RepoRef: item2,
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointLibrary,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -230,7 +230,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
RepoRef: item3,
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointLibrary,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -238,7 +238,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
RepoRef: item4,
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointPage,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -246,7 +246,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
|
||||
RepoRef: item5,
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointPage,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -411,7 +411,7 @@ func (suite *SharePointSelectorSuite) TestSharePointScope_MatchesInfo() {
|
||||
|
||||
itemInfo := details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointPage,
|
||||
WebURL: test.infoURL,
|
||||
Created: now,
|
||||
Modified: modification,
|
||||
|
||||
6
src/pkg/selectors/testdata/details.go
vendored
6
src/pkg/selectors/testdata/details.go
vendored
@ -249,7 +249,7 @@ var (
|
||||
ParentRef: SharePointLibraryItemPath1.ToBuilder().Dir().ShortRef(),
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointLibrary,
|
||||
ParentPath: SharePointLibraryFolder,
|
||||
ItemName: SharePointLibraryItemPath1.Item() + "name",
|
||||
Size: int64(23),
|
||||
@ -265,7 +265,7 @@ var (
|
||||
ParentRef: SharePointLibraryItemPath2.ToBuilder().Dir().ShortRef(),
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointLibrary,
|
||||
ParentPath: SharePointParentLibrary1,
|
||||
ItemName: SharePointLibraryItemPath2.Item() + "name",
|
||||
Size: int64(42),
|
||||
@ -281,7 +281,7 @@ var (
|
||||
ParentRef: SharePointLibraryItemPath3.ToBuilder().Dir().ShortRef(),
|
||||
ItemInfo: details.ItemInfo{
|
||||
SharePoint: &details.SharePointInfo{
|
||||
ItemType: details.SharePointItem,
|
||||
ItemType: details.SharePointLibrary,
|
||||
ParentPath: SharePointParentLibrary2,
|
||||
ItemName: SharePointLibraryItemPath3.Item() + "name",
|
||||
Size: int64(19),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user