remove all uses of iota (#4046)
I've needed to catch gotchas that arise from contributors adding a value in the middle of an iota list, not to mention have dealt with prior bugs that happened the same way, now too many times to feel safe about its usage. This PR removes the use of iota from all const declarations. The intent is to not allow the use of iota within the codebase. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #3993 #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
2c00ca40ac
commit
9abd9d4f96
@ -13,10 +13,10 @@ var ErrNotFound = clues.New("not found")
|
|||||||
type CollectionState int
|
type CollectionState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NewState = CollectionState(iota)
|
NewState CollectionState = 0
|
||||||
NotMovedState
|
NotMovedState CollectionState = 1
|
||||||
MovedState
|
MovedState CollectionState = 2
|
||||||
DeletedState
|
DeletedState CollectionState = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
type FetchRestoreCollection struct {
|
type FetchRestoreCollection struct {
|
||||||
|
|||||||
@ -31,13 +31,13 @@ type collectionScope int
|
|||||||
const (
|
const (
|
||||||
// CollectionScopeUnknown is used when we don't know and don't need
|
// CollectionScopeUnknown is used when we don't know and don't need
|
||||||
// to know the kind, like in the case of deletes
|
// to know the kind, like in the case of deletes
|
||||||
CollectionScopeUnknown collectionScope = iota
|
CollectionScopeUnknown collectionScope = 0
|
||||||
|
|
||||||
// CollectionScopeFolder is used for regular folder collections
|
// CollectionScopeFolder is used for regular folder collections
|
||||||
CollectionScopeFolder
|
CollectionScopeFolder collectionScope = 1
|
||||||
|
|
||||||
// CollectionScopePackage is used to represent OneNote items
|
// CollectionScopePackage is used to represent OneNote items
|
||||||
CollectionScopePackage
|
CollectionScopePackage collectionScope = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
const restrictedDirectory = "Site Pages"
|
const restrictedDirectory = "Site Pages"
|
||||||
|
|||||||
@ -14,8 +14,8 @@ import (
|
|||||||
type SharingMode int
|
type SharingMode int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SharingModeCustom = SharingMode(iota)
|
SharingModeCustom SharingMode = 0
|
||||||
SharingModeInherited
|
SharingModeInherited SharingMode = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
type GV2Type string
|
type GV2Type string
|
||||||
|
|||||||
@ -59,6 +59,7 @@ func CollectPages(
|
|||||||
bpc inject.BackupProducerConfig,
|
bpc inject.BackupProducerConfig,
|
||||||
creds account.M365Config,
|
creds account.M365Config,
|
||||||
ac api.Client,
|
ac api.Client,
|
||||||
|
scope selectors.SharePointScope,
|
||||||
su support.StatusUpdater,
|
su support.StatusUpdater,
|
||||||
errs *fault.Bus,
|
errs *fault.Bus,
|
||||||
) ([]data.BackupCollection, error) {
|
) ([]data.BackupCollection, error) {
|
||||||
@ -105,7 +106,7 @@ func CollectPages(
|
|||||||
collection := NewCollection(
|
collection := NewCollection(
|
||||||
dir,
|
dir,
|
||||||
ac,
|
ac,
|
||||||
Pages,
|
scope,
|
||||||
su,
|
su,
|
||||||
bpc.Options)
|
bpc.Options)
|
||||||
collection.SetBetaService(betaService)
|
collection.SetBetaService(betaService)
|
||||||
@ -122,6 +123,7 @@ func CollectLists(
|
|||||||
bpc inject.BackupProducerConfig,
|
bpc inject.BackupProducerConfig,
|
||||||
ac api.Client,
|
ac api.Client,
|
||||||
tenantID string,
|
tenantID string,
|
||||||
|
scope selectors.SharePointScope,
|
||||||
su support.StatusUpdater,
|
su support.StatusUpdater,
|
||||||
errs *fault.Bus,
|
errs *fault.Bus,
|
||||||
) ([]data.BackupCollection, error) {
|
) ([]data.BackupCollection, error) {
|
||||||
@ -156,7 +158,7 @@ func CollectLists(
|
|||||||
collection := NewCollection(
|
collection := NewCollection(
|
||||||
dir,
|
dir,
|
||||||
ac,
|
ac,
|
||||||
List,
|
scope,
|
||||||
su,
|
su,
|
||||||
bpc.Options)
|
bpc.Options)
|
||||||
collection.AddJob(tuple.ID)
|
collection.AddJob(tuple.ID)
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/version"
|
"github.com/alcionai/corso/src/internal/version"
|
||||||
"github.com/alcionai/corso/src/pkg/control"
|
"github.com/alcionai/corso/src/pkg/control"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -61,11 +62,14 @@ func (suite *SharePointPagesSuite) TestCollectPages() {
|
|||||||
ProtectedResource: mock.NewProvider(siteID, siteID),
|
ProtectedResource: mock.NewProvider(siteID, siteID),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sel := selectors.NewSharePointBackup([]string{siteID})
|
||||||
|
|
||||||
col, err := CollectPages(
|
col, err := CollectPages(
|
||||||
ctx,
|
ctx,
|
||||||
bpc,
|
bpc,
|
||||||
creds,
|
creds,
|
||||||
ac,
|
ac,
|
||||||
|
sel.Lists(selectors.Any())[0],
|
||||||
(&MockGraphService{}).UpdateStatus,
|
(&MockGraphService{}).UpdateStatus,
|
||||||
fault.New(true))
|
fault.New(true))
|
||||||
assert.NoError(t, err, clues.ToCore(err))
|
assert.NoError(t, err, clues.ToCore(err))
|
||||||
|
|||||||
@ -21,19 +21,23 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
"github.com/alcionai/corso/src/pkg/logger"
|
"github.com/alcionai/corso/src/pkg/logger"
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DataCategory int
|
type DataCategory int
|
||||||
|
|
||||||
//go:generate stringer -type=DataCategory
|
// channel sizes
|
||||||
const (
|
const (
|
||||||
collectionChannelBufferSize = 50
|
collectionChannelBufferSize = 50
|
||||||
fetchChannelSize = 5
|
fetchChannelSize = 5
|
||||||
Unknown DataCategory = iota
|
)
|
||||||
List
|
|
||||||
Drive
|
//go:generate stringer -type=DataCategory
|
||||||
Pages
|
const (
|
||||||
|
Unknown DataCategory = 0
|
||||||
|
List DataCategory = 1
|
||||||
|
Pages DataCategory = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -53,7 +57,7 @@ type Collection struct {
|
|||||||
// jobs contain the SharePoint.Site.ListIDs for the associated list(s).
|
// jobs contain the SharePoint.Site.ListIDs for the associated list(s).
|
||||||
jobs []string
|
jobs []string
|
||||||
// M365 IDs of the items of this collection
|
// M365 IDs of the items of this collection
|
||||||
category DataCategory
|
category path.CategoryType
|
||||||
client api.Sites
|
client api.Sites
|
||||||
ctrl control.Options
|
ctrl control.Options
|
||||||
betaService *betaAPI.BetaService
|
betaService *betaAPI.BetaService
|
||||||
@ -64,7 +68,7 @@ type Collection struct {
|
|||||||
func NewCollection(
|
func NewCollection(
|
||||||
folderPath path.Path,
|
folderPath path.Path,
|
||||||
ac api.Client,
|
ac api.Client,
|
||||||
category DataCategory,
|
scope selectors.SharePointScope,
|
||||||
statusUpdater support.StatusUpdater,
|
statusUpdater support.StatusUpdater,
|
||||||
ctrlOpts control.Options,
|
ctrlOpts control.Options,
|
||||||
) *Collection {
|
) *Collection {
|
||||||
@ -74,7 +78,7 @@ func NewCollection(
|
|||||||
data: make(chan data.Item, collectionChannelBufferSize),
|
data: make(chan data.Item, collectionChannelBufferSize),
|
||||||
client: ac.Sites(),
|
client: ac.Sites(),
|
||||||
statusUpdater: statusUpdater,
|
statusUpdater: statusUpdater,
|
||||||
category: category,
|
category: scope.Category().PathType(),
|
||||||
ctrl: ctrlOpts,
|
ctrl: ctrlOpts,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,9 +202,9 @@ func (sc *Collection) runPopulate(
|
|||||||
|
|
||||||
// Switch retrieval function based on category
|
// Switch retrieval function based on category
|
||||||
switch sc.category {
|
switch sc.category {
|
||||||
case List:
|
case path.ListsCategory:
|
||||||
metrics, err = sc.retrieveLists(ctx, writer, colProgress, errs)
|
metrics, err = sc.retrieveLists(ctx, writer, colProgress, errs)
|
||||||
case Pages:
|
case path.PagesCategory:
|
||||||
metrics, err = sc.retrievePages(ctx, sc.client, writer, colProgress, errs)
|
metrics, err = sc.retrievePages(ctx, sc.client, writer, colProgress, errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/control/testdata"
|
"github.com/alcionai/corso/src/pkg/control/testdata"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
"github.com/alcionai/corso/src/pkg/services/m365/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -82,16 +83,18 @@ func (suite *SharePointCollectionSuite) TestCollection_Items() {
|
|||||||
dirRoot = "directory"
|
dirRoot = "directory"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
sel := selectors.NewSharePointBackup([]string{"site"})
|
||||||
|
|
||||||
tables := []struct {
|
tables := []struct {
|
||||||
name, itemName string
|
name, itemName string
|
||||||
category DataCategory
|
scope selectors.SharePointScope
|
||||||
getDir func(t *testing.T) path.Path
|
getDir func(t *testing.T) path.Path
|
||||||
getItem func(t *testing.T, itemName string) *Item
|
getItem func(t *testing.T, itemName string) *Item
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "List",
|
name: "List",
|
||||||
itemName: "MockListing",
|
itemName: "MockListing",
|
||||||
category: List,
|
scope: sel.Lists(selectors.Any())[0],
|
||||||
getDir: func(t *testing.T) path.Path {
|
getDir: func(t *testing.T) path.Path {
|
||||||
dir, err := path.Build(
|
dir, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
@ -127,7 +130,7 @@ func (suite *SharePointCollectionSuite) TestCollection_Items() {
|
|||||||
{
|
{
|
||||||
name: "Pages",
|
name: "Pages",
|
||||||
itemName: "MockPages",
|
itemName: "MockPages",
|
||||||
category: Pages,
|
scope: sel.Pages(selectors.Any())[0],
|
||||||
getDir: func(t *testing.T) path.Path {
|
getDir: func(t *testing.T) path.Path {
|
||||||
dir, err := path.Build(
|
dir, err := path.Build(
|
||||||
tenant,
|
tenant,
|
||||||
@ -166,7 +169,7 @@ func (suite *SharePointCollectionSuite) TestCollection_Items() {
|
|||||||
col := NewCollection(
|
col := NewCollection(
|
||||||
test.getDir(t),
|
test.getDir(t),
|
||||||
suite.ac,
|
suite.ac,
|
||||||
test.category,
|
test.scope,
|
||||||
nil,
|
nil,
|
||||||
control.DefaultOptions())
|
control.DefaultOptions())
|
||||||
col.data <- test.getItem(t, test.itemName)
|
col.data <- test.getItem(t, test.itemName)
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
// Code generated by "stringer -type=DataCategory"; DO NOT EDIT.
|
|
||||||
|
|
||||||
package site
|
|
||||||
|
|
||||||
import "strconv"
|
|
||||||
|
|
||||||
func _() {
|
|
||||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
||||||
// Re-run the stringer command to generate them again.
|
|
||||||
var x [1]struct{}
|
|
||||||
_ = x[Unknown-2]
|
|
||||||
_ = x[List-3]
|
|
||||||
_ = x[Drive-4]
|
|
||||||
_ = x[Pages-5]
|
|
||||||
}
|
|
||||||
|
|
||||||
const _DataCategory_name = "UnknownListDrivePages"
|
|
||||||
|
|
||||||
var _DataCategory_index = [...]uint8{0, 7, 11, 16, 21}
|
|
||||||
|
|
||||||
func (i DataCategory) String() string {
|
|
||||||
i -= 2
|
|
||||||
if i < 0 || i >= DataCategory(len(_DataCategory_index)-1) {
|
|
||||||
return "DataCategory(" + strconv.FormatInt(int64(i+2), 10) + ")"
|
|
||||||
}
|
|
||||||
return _DataCategory_name[_DataCategory_index[i]:_DataCategory_index[i+1]]
|
|
||||||
}
|
|
||||||
@ -63,6 +63,7 @@ func ProduceBackupCollections(
|
|||||||
bpc,
|
bpc,
|
||||||
ac,
|
ac,
|
||||||
creds.AzureTenantID,
|
creds.AzureTenantID,
|
||||||
|
scope,
|
||||||
su,
|
su,
|
||||||
errs)
|
errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -95,6 +96,7 @@ func ProduceBackupCollections(
|
|||||||
bpc,
|
bpc,
|
||||||
creds,
|
creds,
|
||||||
ac,
|
ac,
|
||||||
|
scope,
|
||||||
su,
|
su,
|
||||||
errs)
|
errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -37,10 +37,10 @@ type Operation int
|
|||||||
|
|
||||||
//go:generate stringer -type=Operation
|
//go:generate stringer -type=Operation
|
||||||
const (
|
const (
|
||||||
OpUnknown Operation = iota
|
OpUnknown Operation = 0
|
||||||
Backup
|
Backup Operation = 1
|
||||||
Restore
|
Restore Operation = 2
|
||||||
Export
|
Export Operation = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
// Constructor for ConnectorOperationStatus. If the counts do not agree, an error is returned.
|
// Constructor for ConnectorOperationStatus. If the counts do not agree, an error is returned.
|
||||||
|
|||||||
@ -22,12 +22,12 @@ func (id StableID) String() string {
|
|||||||
//
|
//
|
||||||
//go:generate go run golang.org/x/tools/cmd/stringer -type=Schema
|
//go:generate go run golang.org/x/tools/cmd/stringer -type=Schema
|
||||||
const (
|
const (
|
||||||
UnknownSchema = Schema(iota)
|
UnknownSchema Schema = 0
|
||||||
BackupOpSchema
|
BackupOpSchema Schema = 1
|
||||||
RestoreOpSchema
|
RestoreOpSchema Schema = 2
|
||||||
BackupSchema
|
BackupSchema Schema = 3
|
||||||
BackupDetailsSchema
|
BackupDetailsSchema Schema = 4
|
||||||
RepositorySchema
|
RepositorySchema Schema = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
// common tags for filtering
|
// common tags for filtering
|
||||||
@ -38,7 +38,7 @@ const (
|
|||||||
MergeBackup = "merge-backup"
|
MergeBackup = "merge-backup"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Valid returns true if the ModelType value fits within the iota range.
|
// Valid returns true if the ModelType value fits within the const range.
|
||||||
func (mt Schema) Valid() bool {
|
func (mt Schema) Valid() bool {
|
||||||
return mt > 0 && mt < RepositorySchema+1
|
return mt > 0 && mt < RepositorySchema+1
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,11 +33,11 @@ type OpStatus int
|
|||||||
|
|
||||||
//go:generate stringer -type=OpStatus -linecomment
|
//go:generate stringer -type=OpStatus -linecomment
|
||||||
const (
|
const (
|
||||||
Unknown OpStatus = iota // Status Unknown
|
Unknown OpStatus = 0 // Status Unknown
|
||||||
InProgress // In Progress
|
InProgress OpStatus = 1 // In Progress
|
||||||
Completed // Completed
|
Completed OpStatus = 2 // Completed
|
||||||
Failed // Failed
|
Failed OpStatus = 3 // Failed
|
||||||
NoData // No Data
|
NoData OpStatus = 4 // No Data
|
||||||
)
|
)
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -10,8 +10,8 @@ type accountProvider int
|
|||||||
|
|
||||||
//go:generate stringer -type=accountProvider -linecomment
|
//go:generate stringer -type=accountProvider -linecomment
|
||||||
const (
|
const (
|
||||||
ProviderUnknown accountProvider = iota // Unknown Provider
|
ProviderUnknown accountProvider = 0 // Unknown Provider
|
||||||
ProviderM365 // M365
|
ProviderM365 accountProvider = 1 // M365
|
||||||
)
|
)
|
||||||
|
|
||||||
// storage parsing errors
|
// storage parsing errors
|
||||||
|
|||||||
@ -20,16 +20,17 @@ type ItemType int
|
|||||||
// Additionally, any itemType directly assigned a number should not be altered.
|
// Additionally, any itemType directly assigned a number should not be altered.
|
||||||
// This applies to OneDriveItem and FolderItem
|
// This applies to OneDriveItem and FolderItem
|
||||||
const (
|
const (
|
||||||
UnknownType ItemType = iota // 0, global unknown value
|
UnknownType ItemType = 0
|
||||||
|
|
||||||
// Exchange (00x)
|
// Exchange (00x)
|
||||||
ExchangeContact
|
ExchangeContact ItemType = 1
|
||||||
ExchangeEvent
|
ExchangeEvent ItemType = 2
|
||||||
ExchangeMail
|
ExchangeMail ItemType = 3
|
||||||
|
|
||||||
// SharePoint (10x)
|
// SharePoint (10x)
|
||||||
SharePointLibrary ItemType = iota + 97 // 100
|
SharePointLibrary ItemType = 101
|
||||||
SharePointList // 101...
|
SharePointList ItemType = 102
|
||||||
SharePointPage
|
SharePointPage ItemType = 103
|
||||||
|
|
||||||
// OneDrive (20x)
|
// OneDrive (20x)
|
||||||
OneDriveItem ItemType = 205
|
OneDriveItem ItemType = 205
|
||||||
|
|||||||
@ -25,12 +25,10 @@ type Maintenance struct {
|
|||||||
|
|
||||||
type MaintenanceType int
|
type MaintenanceType int
|
||||||
|
|
||||||
// Can't be reordered as we rely on iota for numbering.
|
|
||||||
//
|
|
||||||
//go:generate stringer -type=MaintenanceType -linecomment
|
//go:generate stringer -type=MaintenanceType -linecomment
|
||||||
const (
|
const (
|
||||||
CompleteMaintenance MaintenanceType = iota // complete
|
CompleteMaintenance MaintenanceType = 0 // complete
|
||||||
MetadataMaintenance // metadata
|
MetadataMaintenance MaintenanceType = 1 // metadata
|
||||||
)
|
)
|
||||||
|
|
||||||
var StringToMaintenanceType = map[string]MaintenanceType{
|
var StringToMaintenanceType = map[string]MaintenanceType{
|
||||||
@ -40,16 +38,14 @@ var StringToMaintenanceType = map[string]MaintenanceType{
|
|||||||
|
|
||||||
type MaintenanceSafety int
|
type MaintenanceSafety int
|
||||||
|
|
||||||
// Can't be reordered as we rely on iota for numbering.
|
|
||||||
//
|
|
||||||
//go:generate stringer -type=MaintenanceSafety -linecomment
|
//go:generate stringer -type=MaintenanceSafety -linecomment
|
||||||
const (
|
const (
|
||||||
FullMaintenanceSafety MaintenanceSafety = iota
|
FullMaintenanceSafety MaintenanceSafety = 0
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
// Use only if there's no other kopia instances accessing the repo and the
|
// Use only if there's no other kopia instances accessing the repo and the
|
||||||
// storage backend is strongly consistent.
|
// storage backend is strongly consistent.
|
||||||
// https://github.com/kopia/kopia/blob/f9de453efc198b6e993af8922f953a7e5322dc5f/repo/maintenance/maintenance_safety.go#L42
|
// https://github.com/kopia/kopia/blob/f9de453efc198b6e993af8922f953a7e5322dc5f/repo/maintenance/maintenance_safety.go#L42
|
||||||
NoMaintenanceSafety
|
NoMaintenanceSafety MaintenanceSafety = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
type RetentionMode int
|
type RetentionMode int
|
||||||
|
|||||||
@ -17,15 +17,15 @@ type CategoryType int
|
|||||||
|
|
||||||
//go:generate stringer -type=CategoryType -linecomment
|
//go:generate stringer -type=CategoryType -linecomment
|
||||||
const (
|
const (
|
||||||
UnknownCategory CategoryType = iota
|
UnknownCategory CategoryType = 0
|
||||||
EmailCategory // email
|
EmailCategory CategoryType = 1 // email
|
||||||
ContactsCategory // contacts
|
ContactsCategory CategoryType = 2 // contacts
|
||||||
EventsCategory // events
|
EventsCategory CategoryType = 3 // events
|
||||||
FilesCategory // files
|
FilesCategory CategoryType = 4 // files
|
||||||
ListsCategory // lists
|
ListsCategory CategoryType = 5 // lists
|
||||||
LibrariesCategory // libraries
|
LibrariesCategory CategoryType = 6 // libraries
|
||||||
PagesCategory // pages
|
PagesCategory CategoryType = 7 // pages
|
||||||
DetailsCategory // details
|
DetailsCategory CategoryType = 8 // details
|
||||||
)
|
)
|
||||||
|
|
||||||
func ToCategoryType(category string) CategoryType {
|
func ToCategoryType(category string) CategoryType {
|
||||||
|
|||||||
@ -22,17 +22,17 @@ type ServiceType int
|
|||||||
|
|
||||||
//go:generate stringer -type=ServiceType -linecomment
|
//go:generate stringer -type=ServiceType -linecomment
|
||||||
const (
|
const (
|
||||||
UnknownService ServiceType = iota
|
UnknownService ServiceType = 0
|
||||||
ExchangeService // exchange
|
ExchangeService ServiceType = 1 // exchange
|
||||||
OneDriveService // onedrive
|
OneDriveService ServiceType = 2 // onedrive
|
||||||
SharePointService // sharepoint
|
SharePointService ServiceType = 3 // sharepoint
|
||||||
ExchangeMetadataService // exchangeMetadata
|
ExchangeMetadataService ServiceType = 4 // exchangeMetadata
|
||||||
OneDriveMetadataService // onedriveMetadata
|
OneDriveMetadataService ServiceType = 5 // onedriveMetadata
|
||||||
SharePointMetadataService // sharepointMetadata
|
SharePointMetadataService ServiceType = 6 // sharepointMetadata
|
||||||
GroupsService // groups
|
GroupsService ServiceType = 7 // groups
|
||||||
GroupsMetadataService // groupsMetadata
|
GroupsMetadataService ServiceType = 8 // groupsMetadata
|
||||||
TeamsService // teams
|
TeamsService ServiceType = 9 // teams
|
||||||
TeamsMetadataService // teamsMetadata
|
TeamsMetadataService ServiceType = 10 // teamsMetadata
|
||||||
)
|
)
|
||||||
|
|
||||||
func toServiceType(service string) ServiceType {
|
func toServiceType(service string) ServiceType {
|
||||||
@ -45,12 +45,20 @@ func toServiceType(service string) ServiceType {
|
|||||||
return OneDriveService
|
return OneDriveService
|
||||||
case strings.ToLower(SharePointService.String()):
|
case strings.ToLower(SharePointService.String()):
|
||||||
return SharePointService
|
return SharePointService
|
||||||
|
case strings.ToLower(GroupsService.String()):
|
||||||
|
return GroupsService
|
||||||
|
case strings.ToLower(TeamsService.String()):
|
||||||
|
return TeamsService
|
||||||
case strings.ToLower(ExchangeMetadataService.String()):
|
case strings.ToLower(ExchangeMetadataService.String()):
|
||||||
return ExchangeMetadataService
|
return ExchangeMetadataService
|
||||||
case strings.ToLower(OneDriveMetadataService.String()):
|
case strings.ToLower(OneDriveMetadataService.String()):
|
||||||
return OneDriveMetadataService
|
return OneDriveMetadataService
|
||||||
case strings.ToLower(SharePointMetadataService.String()):
|
case strings.ToLower(SharePointMetadataService.String()):
|
||||||
return SharePointMetadataService
|
return SharePointMetadataService
|
||||||
|
case strings.ToLower(GroupsMetadataService.String()):
|
||||||
|
return GroupsMetadataService
|
||||||
|
case strings.ToLower(TeamsMetadataService.String()):
|
||||||
|
return TeamsMetadataService
|
||||||
default:
|
default:
|
||||||
return UnknownService
|
return UnknownService
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,11 +17,13 @@ func _() {
|
|||||||
_ = x[SharePointMetadataService-6]
|
_ = x[SharePointMetadataService-6]
|
||||||
_ = x[GroupsService-7]
|
_ = x[GroupsService-7]
|
||||||
_ = x[GroupsMetadataService-8]
|
_ = x[GroupsMetadataService-8]
|
||||||
|
_ = x[TeamsService-9]
|
||||||
|
_ = x[TeamsMetadataService-10]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _ServiceType_name = "UnknownServiceexchangeonedrivesharepointexchangeMetadataonedriveMetadatasharepointMetadatagroupsgroupsMetadata"
|
const _ServiceType_name = "UnknownServiceexchangeonedrivesharepointexchangeMetadataonedriveMetadatasharepointMetadatagroupsgroupsMetadatateamsteamsMetadata"
|
||||||
|
|
||||||
var _ServiceType_index = [...]uint8{0, 14, 22, 30, 40, 56, 72, 90, 96, 110}
|
var _ServiceType_index = [...]uint8{0, 14, 22, 30, 40, 56, 72, 90, 96, 110, 115, 128}
|
||||||
|
|
||||||
func (i ServiceType) String() string {
|
func (i ServiceType) String() string {
|
||||||
if i < 0 || i >= ServiceType(len(_ServiceType_index)-1) {
|
if i < 0 || i >= ServiceType(len(_ServiceType_index)-1) {
|
||||||
|
|||||||
@ -20,11 +20,11 @@ type service int
|
|||||||
|
|
||||||
//go:generate stringer -type=service -linecomment
|
//go:generate stringer -type=service -linecomment
|
||||||
const (
|
const (
|
||||||
ServiceUnknown service = iota // Unknown Service
|
ServiceUnknown service = 0 // Unknown Service
|
||||||
ServiceExchange // Exchange
|
ServiceExchange service = 1 // Exchange
|
||||||
ServiceOneDrive // OneDrive
|
ServiceOneDrive service = 2 // OneDrive
|
||||||
ServiceSharePoint // SharePoint
|
ServiceSharePoint service = 3 // SharePoint
|
||||||
ServiceGroups // Groups
|
ServiceGroups service = 4 // Groups
|
||||||
)
|
)
|
||||||
|
|
||||||
var serviceToPathType = map[service]path.ServiceType{
|
var serviceToPathType = map[service]path.ServiceType{
|
||||||
|
|||||||
@ -12,8 +12,8 @@ type storageProvider int
|
|||||||
|
|
||||||
//go:generate stringer -type=storageProvider -linecomment
|
//go:generate stringer -type=storageProvider -linecomment
|
||||||
const (
|
const (
|
||||||
ProviderUnknown storageProvider = iota // Unknown Provider
|
ProviderUnknown storageProvider = 0 // Unknown Provider
|
||||||
ProviderS3 // S3
|
ProviderS3 storageProvider = 1 // S3
|
||||||
)
|
)
|
||||||
|
|
||||||
// storage parsing errors
|
// storage parsing errors
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user