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"
)
// ==============================================
// 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{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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),