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"
|
"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{
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
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(),
|
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),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user