Compare commits

...

11 Commits

Author SHA1 Message Date
Danny Adams
5d3a46d8a6 Update cli/utils/sharepoint.go
Removal of aold print statements.
2023-03-08 08:50:36 -05:00
Danny Adams
b22c00424e Update to to cli/backup/sharepoint.go
Bug Fix: FileCreated flags updated.
Commment fixes.
2023-03-08 08:50:00 -05:00
Danny Adams
4b58ac472f Update to cli/backup/exchange.go
Removal of global variable from file.
2023-03-08 08:48:23 -05:00
Danny Adams
913327e016 Update cli/backup/backup.go
Shared backup variables added to file.
fileCreatedBefore strings are duplicated. These vars are now in the utils package.
2023-03-08 08:47:38 -05:00
Danny Adams
f404b7716f Merge clean-up 2023-03-07 13:56:54 -05:00
Danny Adams
b8c8201fa3 Update to cli/utils/sharepoint.go
Issue #2602: flags for SharePoint Libraries updated.
2023-03-07 11:21:20 -05:00
Danny Adams
7fd47828ef Updates to internal/connector/sharepoint packages.
Issue #2709: ItemTypes changed from SharePointItem to respective ItemTypes.
2023-03-07 09:54:53 -05:00
Danny Adams
77ada22b59 Update to pkg/selectors/sharepoint_test.go
Issue #2709: Reduce test for SharePoint updated to support Pages and Library ItemTypes.
2023-03-07 09:52:58 -05:00
Danny Adams
6707ef15a8 Update to pkg/selectors/testdata/details.go
Issue #2709: Selector test data updated.
2023-03-07 09:51:25 -05:00
Danny Adams
7c498b42c1 Update to pkg/backup/details/details_test.go
Tests updated to support the 3 categories within SharePoint ItemTypes.
2023-03-07 09:49:55 -05:00
Danny Adams
6bcc85a7f3 Update to pkg/backup/details.details.go
Issue #2709: Item Type extended to the three categories supported within SharePoint.
2023-03-07 09:49:08 -05:00
13 changed files with 38 additions and 48 deletions

View File

@ -18,18 +18,12 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
// ============================================== // ================================================
// Folder Object flags // Shared Backup Globals
// These options are flags for indicating
// that a time-based filter should be used for
// within returning objects for details.
// Used by: OneDrive, SharePoint
// ================================================ // ================================================
var ( var (
fileCreatedAfter string backupID string
fileCreatedBefore string user []string
fileModifiedAfter string
fileModifiedBefore string
) )
var subCommandFuncs = []func() *cobra.Command{ var subCommandFuncs = []func() *cobra.Command{

View File

@ -28,9 +28,7 @@ import (
// exchange bucket info from flags // exchange bucket info from flags
var ( var (
backupID string
exchangeData []string exchangeData []string
user []string
contact []string contact []string
contactFolder []string contactFolder []string

View File

@ -2,6 +2,7 @@ package backup
import ( import (
"context" "context"
"fmt"
"github.com/hashicorp/go-multierror" "github.com/hashicorp/go-multierror"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -55,10 +56,10 @@ const (
sharePointServiceCommandCreateExamples = `# Backup SharePoint data for <site> sharePointServiceCommandCreateExamples = `# Backup SharePoint data for <site>
corso backup create sharepoint --site <site_id> corso backup create sharepoint --site <site_id>
# Backup SharePoint for Alice and Bob # Backup SharePoint for two different sites
corso backup create sharepoint --site <site_id_1>,<site_id_2> 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 # Backup all SharePoint data for all sites
corso backup create sharepoint --site '*'` 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 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> 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. # Find all site files that were created before a certain date.
>>>>>>> main
corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd \ corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd \
--web-url https://example.com --file-created-before 2015-01-01T00:00:00 --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, LibraryPaths: libraryPaths,
Sites: site, Sites: site,
WebURLs: weburl, WebURLs: weburl,
FileCreatedAfter: fileCreatedAfter, FileCreatedAfter: utils.FileCreatedAfter,
FileCreatedBefore: fileCreatedBefore, FileCreatedBefore: utils.FileCreatedBefore,
FileModifiedAfter: fileModifiedAfter, FileModifiedAfter: utils.FileModifiedAfter,
FileModifiedBefore: fileModifiedBefore, FileModifiedBefore: utils.FileModifiedBefore,
Populated: utils.GetPopulatedFlags(cmd), Populated: utils.GetPopulatedFlags(cmd),
} }
@ -478,6 +475,7 @@ func runDetailsSharePointCmd(
skipReduce bool, skipReduce bool,
) (*details.Details, error) { ) (*details.Details, error) {
if err := utils.ValidateSharePointRestoreFlags(backupID, opts); err != nil { if err := utils.ValidateSharePointRestoreFlags(backupID, opts); err != nil {
fmt.Println("Fail on validate")
return nil, err return nil, err
} }

View File

@ -2,14 +2,13 @@ package utils
import ( import (
"errors" "errors"
"fmt"
"github.com/alcionai/corso/src/pkg/selectors" "github.com/alcionai/corso/src/pkg/selectors"
) )
const ( const (
LibraryItemFN = "library-item" LibraryItemFN = "file"
LibraryFN = "library" LibraryFN = "folder"
ListItemFN = "list-item" ListItemFN = "list-item"
ListFN = "list" ListFN = "list"
PageFolderFN = "page-folders" PageFolderFN = "page-folders"
@ -41,7 +40,6 @@ func ValidateSharePointRestoreFlags(backupID string, opts SharePointOpts) error
} }
if _, ok := opts.Populated[FileCreatedAfterFN]; ok && !IsValidTimeFormat(opts.FileCreatedAfter) { 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) return errors.New("invalid time format for " + FileCreatedAfterFN)
} }

View File

@ -263,7 +263,7 @@ func PageInfo(page models.SitePageable, size int64) *details.SharePointInfo {
) )
return &details.SharePointInfo{ return &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointPage,
ItemName: name, ItemName: name,
Created: created, Created: created,
Modified: modified, Modified: modified,

View File

@ -18,7 +18,7 @@ func sharePointListInfo(lst models.Listable, size int64) *details.SharePointInfo
) )
return &details.SharePointInfo{ return &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointList,
ItemName: name, ItemName: name,
Created: created, Created: created,
Modified: modified, Modified: modified,

View File

@ -27,7 +27,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo() {
{ {
name: "Empty List", name: "Empty List",
listAndDeets: func() (models.Listable, *details.SharePointInfo) { listAndDeets: func() (models.Listable, *details.SharePointInfo) {
i := &details.SharePointInfo{ItemType: details.SharePointItem} i := &details.SharePointInfo{ItemType: details.SharePointList}
return models.NewList(), i return models.NewList(), i
}, },
}, { }, {
@ -37,7 +37,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo() {
listing := models.NewList() listing := models.NewList()
listing.SetDisplayName(&aTitle) listing.SetDisplayName(&aTitle)
i := &details.SharePointInfo{ i := &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointList,
ItemName: aTitle, ItemName: aTitle,
} }

View File

@ -37,7 +37,7 @@ func sharePointPageInfo(page models.SitePageable, root string, size int64) *deta
} }
return &details.SharePointInfo{ return &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointPage,
ItemName: name, ItemName: name,
ParentPath: root, ParentPath: root,
Created: created, Created: created,

View File

@ -17,7 +17,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo_Pages() {
{ {
name: "Empty Page", name: "Empty Page",
pageAndDeets: func() (models.SitePageable, *details.SharePointInfo) { pageAndDeets: func() (models.SitePageable, *details.SharePointInfo) {
deets := &details.SharePointInfo{ItemType: details.SharePointItem} deets := &details.SharePointInfo{ItemType: details.SharePointPage}
return models.NewSitePage(), deets return models.NewSitePage(), deets
}, },
}, },
@ -28,7 +28,7 @@ func (suite *SharePointInfoSuite) TestSharePointInfo_Pages() {
sPage := models.NewSitePage() sPage := models.NewSitePage()
sPage.SetTitle(&title) sPage.SetTitle(&title)
deets := &details.SharePointInfo{ deets := &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointPage,
ItemName: title, ItemName: title,
} }

View File

@ -403,7 +403,9 @@ const (
ExchangeEvent ExchangeEvent
ExchangeMail ExchangeMail
SharePointItem ItemType = iota + 100 SharePointLibrary ItemType = iota + 100
SharePointList ItemType = iota + 100
SharePointPage ItemType = iota + 100
OneDriveItem ItemType = iota + 200 OneDriveItem ItemType = iota + 200
@ -416,7 +418,7 @@ func UpdateItem(item *ItemInfo, repoPath path.Path) error {
var updatePath func(path.Path) error var updatePath func(path.Path) error
switch item.infoType() { switch item.infoType() {
case SharePointItem: case SharePointLibrary:
updatePath = item.SharePoint.UpdateParentPath updatePath = item.SharePoint.UpdateParentPath
case OneDriveItem: case OneDriveItem:
updatePath = item.OneDrive.UpdateParentPath updatePath = item.OneDrive.UpdateParentPath

View File

@ -780,7 +780,7 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
name: "SharePoint", name: "SharePoint",
input: ItemInfo{ input: ItemInfo{
SharePoint: &SharePointInfo{ SharePoint: &SharePointInfo{
ItemType: SharePointItem, ItemType: SharePointLibrary,
ParentPath: folder1, ParentPath: folder1,
}, },
}, },
@ -789,7 +789,7 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
errCheck: assert.NoError, errCheck: assert.NoError,
expectedItem: ItemInfo{ expectedItem: ItemInfo{
SharePoint: &SharePointInfo{ SharePoint: &SharePointInfo{
ItemType: SharePointItem, ItemType: SharePointLibrary,
ParentPath: folder2, ParentPath: folder2,
}, },
}, },
@ -810,7 +810,7 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
name: "SharePointBadPath", name: "SharePointBadPath",
input: ItemInfo{ input: ItemInfo{
SharePoint: &SharePointInfo{ SharePoint: &SharePointInfo{
ItemType: SharePointItem, ItemType: SharePointLibrary,
ParentPath: folder1, ParentPath: folder1,
}, },
}, },

View File

@ -214,7 +214,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
RepoRef: item, RepoRef: item,
ItemInfo: details.ItemInfo{ ItemInfo: details.ItemInfo{
SharePoint: &details.SharePointInfo{ SharePoint: &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointLibrary,
}, },
}, },
}, },
@ -222,7 +222,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
RepoRef: item2, RepoRef: item2,
ItemInfo: details.ItemInfo{ ItemInfo: details.ItemInfo{
SharePoint: &details.SharePointInfo{ SharePoint: &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointLibrary,
}, },
}, },
}, },
@ -230,7 +230,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
RepoRef: item3, RepoRef: item3,
ItemInfo: details.ItemInfo{ ItemInfo: details.ItemInfo{
SharePoint: &details.SharePointInfo{ SharePoint: &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointLibrary,
}, },
}, },
}, },
@ -238,7 +238,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
RepoRef: item4, RepoRef: item4,
ItemInfo: details.ItemInfo{ ItemInfo: details.ItemInfo{
SharePoint: &details.SharePointInfo{ SharePoint: &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointPage,
}, },
}, },
}, },
@ -246,7 +246,7 @@ func (suite *SharePointSelectorSuite) TestSharePointRestore_Reduce() {
RepoRef: item5, RepoRef: item5,
ItemInfo: details.ItemInfo{ ItemInfo: details.ItemInfo{
SharePoint: &details.SharePointInfo{ SharePoint: &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointPage,
}, },
}, },
}, },
@ -411,7 +411,7 @@ func (suite *SharePointSelectorSuite) TestSharePointScope_MatchesInfo() {
itemInfo := details.ItemInfo{ itemInfo := details.ItemInfo{
SharePoint: &details.SharePointInfo{ SharePoint: &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointPage,
WebURL: test.infoURL, WebURL: test.infoURL,
Created: now, Created: now,
Modified: modification, Modified: modification,

View File

@ -249,7 +249,7 @@ var (
ParentRef: SharePointLibraryItemPath1.ToBuilder().Dir().ShortRef(), ParentRef: SharePointLibraryItemPath1.ToBuilder().Dir().ShortRef(),
ItemInfo: details.ItemInfo{ ItemInfo: details.ItemInfo{
SharePoint: &details.SharePointInfo{ SharePoint: &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointLibrary,
ParentPath: SharePointLibraryFolder, ParentPath: SharePointLibraryFolder,
ItemName: SharePointLibraryItemPath1.Item() + "name", ItemName: SharePointLibraryItemPath1.Item() + "name",
Size: int64(23), Size: int64(23),
@ -265,7 +265,7 @@ var (
ParentRef: SharePointLibraryItemPath2.ToBuilder().Dir().ShortRef(), ParentRef: SharePointLibraryItemPath2.ToBuilder().Dir().ShortRef(),
ItemInfo: details.ItemInfo{ ItemInfo: details.ItemInfo{
SharePoint: &details.SharePointInfo{ SharePoint: &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointLibrary,
ParentPath: SharePointParentLibrary1, ParentPath: SharePointParentLibrary1,
ItemName: SharePointLibraryItemPath2.Item() + "name", ItemName: SharePointLibraryItemPath2.Item() + "name",
Size: int64(42), Size: int64(42),
@ -281,7 +281,7 @@ var (
ParentRef: SharePointLibraryItemPath3.ToBuilder().Dir().ShortRef(), ParentRef: SharePointLibraryItemPath3.ToBuilder().Dir().ShortRef(),
ItemInfo: details.ItemInfo{ ItemInfo: details.ItemInfo{
SharePoint: &details.SharePointInfo{ SharePoint: &details.SharePointInfo{
ItemType: details.SharePointItem, ItemType: details.SharePointLibrary,
ParentPath: SharePointParentLibrary2, ParentPath: SharePointParentLibrary2,
ItemName: SharePointLibraryItemPath3.Item() + "name", ItemName: SharePointLibraryItemPath3.Item() + "name",
Size: int64(19), Size: int64(19),