Define structs that will be used for backup options and add some CLI
helpers/tests to populate those structs with flag values
Rate limiter config is pulled out as a separate struct because it will
likely be used for backup and restore operations and it has values that
are [passed separately](505c06441a/src/internal/m365/backup.go (L232)) to the rate limiter config code
---
#### Does this PR need a docs update or release note?
- [ ] ✅ Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x] ⛔ No
#### Type of change
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [x] 🧹 Tech Debt/Cleanup
#### Test Plan
- [ ] 💪 Manual
- [x] ⚡ Unit test
- [ ] 💚 E2E
68 lines
1.9 KiB
Go
68 lines
1.9 KiB
Go
package utils
|
|
|
|
import (
|
|
"github.com/alcionai/corso/src/cli/flags"
|
|
"github.com/alcionai/corso/src/pkg/config"
|
|
"github.com/alcionai/corso/src/pkg/control"
|
|
)
|
|
|
|
// Control produces the control options based on the user's flags.
|
|
func Control() control.Options {
|
|
opt := control.DefaultOptions()
|
|
|
|
if flags.FailFastFV {
|
|
opt.FailureHandling = control.FailFast
|
|
}
|
|
|
|
dps := int32(flags.DeltaPageSizeFV)
|
|
if dps > 500 || dps < 1 {
|
|
dps = 500
|
|
}
|
|
|
|
opt.DeltaPageSize = dps
|
|
opt.DisableMetrics = flags.NoStatsFV
|
|
opt.SkipReduce = flags.SkipReduceFV
|
|
opt.ToggleFeatures.DisableIncrementals = flags.DisableIncrementalsFV
|
|
opt.ToggleFeatures.ForceItemDataDownload = flags.ForceItemDataDownloadFV
|
|
opt.ToggleFeatures.DisableDelta = flags.DisableDeltaFV
|
|
opt.ToggleFeatures.DisableSlidingWindowLimiter = flags.DisableSlidingWindowLimiterFV
|
|
opt.ToggleFeatures.ExchangeImmutableIDs = flags.EnableImmutableIDFV
|
|
opt.ToggleFeatures.UseDeltaTree = flags.UseDeltaTreeFV
|
|
opt.Parallelism.ItemFetch = flags.FetchParallelismFV
|
|
|
|
return opt
|
|
}
|
|
|
|
func ControlWithConfig(cfg config.RepoDetails) control.Options {
|
|
opt := Control()
|
|
|
|
opt.Repo.User = cfg.RepoUser
|
|
opt.Repo.Host = cfg.RepoHost
|
|
|
|
return opt
|
|
}
|
|
|
|
func ParseBackupOptions() control.BackupConfig {
|
|
opt := control.DefaultBackupConfig()
|
|
|
|
if flags.FailFastFV {
|
|
opt.FailureHandling = control.FailFast
|
|
}
|
|
|
|
dps := int32(flags.DeltaPageSizeFV)
|
|
if dps > 500 || dps < 1 {
|
|
dps = 500
|
|
}
|
|
|
|
opt.M365.DeltaPageSize = dps
|
|
opt.M365.DisableDeltaEndpoint = flags.DisableDeltaFV
|
|
opt.M365.ExchangeImmutableIDs = flags.EnableImmutableIDFV
|
|
opt.M365.UseDriveDeltaTree = flags.UseDeltaTreeFV
|
|
opt.ServiceRateLimiter.DisableSlidingWindowLimiter = flags.DisableSlidingWindowLimiterFV
|
|
opt.Parallelism.ItemFetch = flags.FetchParallelismFV
|
|
opt.Incrementals.ForceFullEnumeration = flags.DisableIncrementalsFV
|
|
opt.Incrementals.ForceItemDataRefresh = flags.ForceItemDataDownloadFV
|
|
|
|
return opt
|
|
}
|