GC: SharePoint: ItemType Decouple (#2720)
<!-- Insert PR description--> ItemTypes for SharePoint were `SharePointItem` only. This did not allow for data to be separated by category. Newly created categories: - SharePointLibrary - SharePointList - SharePointPage Breaks history for `SharePointItems`. All previous SharePoint items are available during `Corso List` command. However, when using the details command with the backup ID for `SharePointItems` restored prior to this PR , the return will be: ``` no items match the specified selectors ``` --- #### Does this PR need a docs update or release note? - [x] 📝 : Will need documentation #### Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * related to #2709<issue> #### Test Plan - [x] ⚡ Unit test
This commit is contained in:
parent
6fd29097e3
commit
0766ee7afd
@ -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,
|
||||
}
|
||||
|
||||
|
||||
@ -409,19 +409,32 @@ func (de DetailsEntry) Values() []string {
|
||||
|
||||
type ItemType int
|
||||
|
||||
// ItemTypes are enumerated by service (hundredth digit) and data type (ones digit).
|
||||
// Ex: exchange is 00x where x is the data type. Sharepoint is 10x, and etc.
|
||||
// Every item info struct should get its own hundredth enumeration entry.
|
||||
// Every item category for that service should get its own entry (even if differences
|
||||
// between types aren't apparent on initial implementation, this future-proofs
|
||||
// against breaking changes).
|
||||
// Entries should not be rearranged.
|
||||
// Additionally, any itemType directly assigned a number should not be altered.
|
||||
// This applies to OneDriveItem and FolderItem
|
||||
const (
|
||||
UnknownType ItemType = iota
|
||||
UnknownType ItemType = iota // 0, global unknown value
|
||||
|
||||
// separate each service by a factor of 100 for padding
|
||||
// Exchange (00x)
|
||||
ExchangeContact
|
||||
ExchangeEvent
|
||||
ExchangeMail
|
||||
// SharePoint (10x)
|
||||
SharePointLibrary ItemType = iota + 97 // 100
|
||||
SharePointList // 101...
|
||||
SharePointPage
|
||||
|
||||
SharePointItem ItemType = iota + 100
|
||||
// OneDrive (20x)
|
||||
OneDriveItem ItemType = 205
|
||||
|
||||
OneDriveItem ItemType = iota + 200
|
||||
|
||||
FolderItem ItemType = iota + 300
|
||||
// Folder Management(30x)
|
||||
FolderItem ItemType = 306
|
||||
)
|
||||
|
||||
func UpdateItem(item *ItemInfo, repoPath path.Path) error {
|
||||
@ -430,7 +443,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
|
||||
|
||||
@ -782,7 +782,7 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
|
||||
name: "SharePoint",
|
||||
input: ItemInfo{
|
||||
SharePoint: &SharePointInfo{
|
||||
ItemType: SharePointItem,
|
||||
ItemType: SharePointLibrary,
|
||||
ParentPath: folder1,
|
||||
},
|
||||
},
|
||||
@ -791,7 +791,7 @@ func (suite *DetailsUnitSuite) TestUpdateItem() {
|
||||
errCheck: assert.NoError,
|
||||
expectedItem: ItemInfo{
|
||||
SharePoint: &SharePointInfo{
|
||||
ItemType: SharePointItem,
|
||||
ItemType: SharePointLibrary,
|
||||
ParentPath: folder2,
|
||||
},
|
||||
},
|
||||
@ -812,7 +812,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,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -416,7 +416,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