replace errors.* with clues.* (#2924)
Mostly find/replace on errors.N and errors.W. Also turns all wrapf into wrap, and removes as many errorf calls as possible. Might follow up with a linter to enforce this change. --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #1970 #### Test Plan - [x] ⚡ Unit test - [x] 💚 E2E
This commit is contained in:
parent
c6be513ea6
commit
9d73d0c8e2
@ -6,6 +6,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/config"
|
"github.com/alcionai/corso/src/cli/config"
|
||||||
"github.com/alcionai/corso/src/cli/options"
|
"github.com/alcionai/corso/src/cli/options"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
@ -19,8 +22,6 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/repository"
|
"github.com/alcionai/corso/src/pkg/repository"
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/alcionai/corso/src/pkg/store"
|
"github.com/alcionai/corso/src/pkg/store"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@ -235,7 +236,7 @@ func runBackups(
|
|||||||
|
|
||||||
bups, berrs := r.Backups(ctx, bIDs)
|
bups, berrs := r.Backups(ctx, bIDs)
|
||||||
if berrs.Failure() != nil {
|
if berrs.Failure() != nil {
|
||||||
return Only(ctx, errors.Wrap(berrs.Failure(), "Unable to retrieve backup results from storage"))
|
return Only(ctx, clues.Wrap(berrs.Failure(), "Unable to retrieve backup results from storage"))
|
||||||
}
|
}
|
||||||
|
|
||||||
Info(ctx, "Completed Backups:")
|
Info(ctx, "Completed Backups:")
|
||||||
@ -258,7 +259,7 @@ func runBackups(
|
|||||||
// genericDeleteCommand is a helper function that all services can use
|
// genericDeleteCommand is a helper function that all services can use
|
||||||
// for the removal of an entry from the repository
|
// for the removal of an entry from the repository
|
||||||
func genericDeleteCommand(cmd *cobra.Command, bID, designation string, args []string) error {
|
func genericDeleteCommand(cmd *cobra.Command, bID, designation string, args []string) error {
|
||||||
ctx := cmd.Context()
|
ctx := clues.Add(cmd.Context(), "delete_backup_id", bID)
|
||||||
|
|
||||||
if utils.HasNoFlagsAndShownHelp(cmd) {
|
if utils.HasNoFlagsAndShownHelp(cmd) {
|
||||||
return nil
|
return nil
|
||||||
@ -272,7 +273,7 @@ func genericDeleteCommand(cmd *cobra.Command, bID, designation string, args []st
|
|||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
|
|
||||||
if err := r.DeleteBackup(ctx, model.StableID(bID)); err != nil {
|
if err := r.DeleteBackup(ctx, model.StableID(bID)); err != nil {
|
||||||
return Only(ctx, errors.Wrapf(err, "Deleting backup %s", bID))
|
return Only(ctx, clues.Wrap(err, "Deleting backup "+bID))
|
||||||
}
|
}
|
||||||
|
|
||||||
Infof(ctx, "Deleted %s backup %s", designation, bID)
|
Infof(ctx, "Deleted %s backup %s", designation, bID)
|
||||||
@ -296,10 +297,10 @@ func genericListCommand(cmd *cobra.Command, bID string, service path.ServiceType
|
|||||||
fe, b, errs := r.GetBackupErrors(ctx, bID)
|
fe, b, errs := r.GetBackupErrors(ctx, bID)
|
||||||
if errs.Failure() != nil {
|
if errs.Failure() != nil {
|
||||||
if errors.Is(errs.Failure(), data.ErrNotFound) {
|
if errors.Is(errs.Failure(), data.ErrNotFound) {
|
||||||
return Only(ctx, errors.Errorf("No backup exists with the id %s", bID))
|
return Only(ctx, clues.New("No backup exists with the id "+bID))
|
||||||
}
|
}
|
||||||
|
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to find backup "+bID))
|
return Only(ctx, clues.Wrap(err, "Failed to find backup "+bID))
|
||||||
}
|
}
|
||||||
|
|
||||||
b.Print(ctx)
|
b.Print(ctx)
|
||||||
@ -310,7 +311,7 @@ func genericListCommand(cmd *cobra.Command, bID string, service path.ServiceType
|
|||||||
|
|
||||||
bs, err := r.BackupsByTag(ctx, store.Service(service))
|
bs, err := r.BackupsByTag(ctx, store.Service(service))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to list backups in the repository"))
|
return Only(ctx, clues.Wrap(err, "Failed to list backups in the repository"))
|
||||||
}
|
}
|
||||||
|
|
||||||
backup.PrintAll(ctx, bs)
|
backup.PrintAll(ctx, bs)
|
||||||
@ -326,7 +327,7 @@ func getAccountAndConnect(ctx context.Context) (repository.Repository, *account.
|
|||||||
|
|
||||||
r, err := repository.Connect(ctx, cfg.Account, cfg.Storage, options.Control())
|
r, err := repository.Connect(ctx, cfg.Account, cfg.Storage, options.Control())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrapf(err, "Failed to connect to the %s repository", cfg.Storage.Provider)
|
return nil, nil, clues.Wrap(err, "Failed to connect to the "+cfg.Storage.Provider.String()+" repository")
|
||||||
}
|
}
|
||||||
|
|
||||||
return r, &cfg.Account, nil
|
return r, &cfg.Account, nil
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package backup
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli/options"
|
"github.com/alcionai/corso/src/cli/options"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
@ -171,7 +171,7 @@ func createExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
users, err := m365.UserPNs(ctx, *acct, errs)
|
users, err := m365.UserPNs(ctx, *acct, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to retrieve M365 user(s)"))
|
return Only(ctx, clues.Wrap(err, "Failed to retrieve M365 user(s)"))
|
||||||
}
|
}
|
||||||
|
|
||||||
selectorSet := []selectors.Selector{}
|
selectorSet := []selectors.Selector{}
|
||||||
@ -213,12 +213,12 @@ func exchangeBackupCreateSelectors(userIDs, cats []string) *selectors.ExchangeBa
|
|||||||
|
|
||||||
func validateExchangeBackupCreateFlags(userIDs, cats []string) error {
|
func validateExchangeBackupCreateFlags(userIDs, cats []string) error {
|
||||||
if len(userIDs) == 0 {
|
if len(userIDs) == 0 {
|
||||||
return errors.New("--user requires one or more email addresses or the wildcard '*'")
|
return clues.New("--user requires one or more email addresses or the wildcard '*'")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, d := range cats {
|
for _, d := range cats {
|
||||||
if d != dataContacts && d != dataEmail && d != dataEvents {
|
if d != dataContacts && d != dataEmail && d != dataEvents {
|
||||||
return errors.New(
|
return clues.New(
|
||||||
d + " is an unrecognized data type; must be one of " + dataContacts + ", " + dataEmail + ", or " + dataEvents)
|
d + " is an unrecognized data type; must be one of " + dataContacts + ", " + dataEmail + ", or " + dataEvents)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,10 +336,10 @@ func runDetailsExchangeCmd(
|
|||||||
// TODO: log/track recoverable errors
|
// TODO: log/track recoverable errors
|
||||||
if errs.Failure() != nil {
|
if errs.Failure() != nil {
|
||||||
if errors.Is(errs.Failure(), data.ErrNotFound) {
|
if errors.Is(errs.Failure(), data.ErrNotFound) {
|
||||||
return nil, errors.Errorf("No backup exists with the id %s", backupID)
|
return nil, clues.New("No backup exists with the id " + backupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.Wrap(errs.Failure(), "Failed to get backup details in the repository")
|
return nil, clues.Wrap(errs.Failure(), "Failed to get backup details in the repository")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = clues.Add(ctx, "details_entries", len(d.Entries))
|
ctx = clues.Add(ctx, "details_entries", len(d.Entries))
|
||||||
|
|||||||
@ -5,13 +5,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli"
|
"github.com/alcionai/corso/src/cli"
|
||||||
"github.com/alcionai/corso/src/cli/config"
|
"github.com/alcionai/corso/src/cli/config"
|
||||||
"github.com/alcionai/corso/src/cli/print"
|
"github.com/alcionai/corso/src/cli/print"
|
||||||
|
|||||||
@ -3,12 +3,12 @@ package backup
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/cli/utils/testdata"
|
"github.com/alcionai/corso/src/cli/utils/testdata"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package backup
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli/options"
|
"github.com/alcionai/corso/src/cli/options"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
@ -146,7 +146,7 @@ func createOneDriveCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
users, err := m365.UserPNs(ctx, *acct, errs)
|
users, err := m365.UserPNs(ctx, *acct, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to retrieve M365 users"))
|
return Only(ctx, clues.Wrap(err, "Failed to retrieve M365 users"))
|
||||||
}
|
}
|
||||||
|
|
||||||
selectorSet := []selectors.Selector{}
|
selectorSet := []selectors.Selector{}
|
||||||
@ -165,7 +165,7 @@ func createOneDriveCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
func validateOneDriveBackupCreateFlags(users []string) error {
|
func validateOneDriveBackupCreateFlags(users []string) error {
|
||||||
if len(users) == 0 {
|
if len(users) == 0 {
|
||||||
return errors.New("requires one or more --user ids or the wildcard --user *")
|
return clues.New("requires one or more --user ids or the wildcard --user *")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -275,10 +275,10 @@ func runDetailsOneDriveCmd(
|
|||||||
// TODO: log/track recoverable errors
|
// TODO: log/track recoverable errors
|
||||||
if errs.Failure() != nil {
|
if errs.Failure() != nil {
|
||||||
if errors.Is(errs.Failure(), data.ErrNotFound) {
|
if errors.Is(errs.Failure(), data.ErrNotFound) {
|
||||||
return nil, errors.Errorf("no backup exists with the id %s", backupID)
|
return nil, clues.New("no backup exists with the id " + backupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.Wrap(errs.Failure(), "Failed to get backup details in the repository")
|
return nil, clues.Wrap(errs.Failure(), "Failed to get backup details in the repository")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = clues.Add(ctx, "details_entries", len(d.Entries))
|
ctx = clues.Add(ctx, "details_entries", len(d.Entries))
|
||||||
|
|||||||
@ -5,13 +5,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli"
|
"github.com/alcionai/corso/src/cli"
|
||||||
"github.com/alcionai/corso/src/cli/config"
|
"github.com/alcionai/corso/src/cli/config"
|
||||||
"github.com/alcionai/corso/src/cli/print"
|
"github.com/alcionai/corso/src/cli/print"
|
||||||
|
|||||||
@ -3,12 +3,12 @@ package backup
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils/testdata"
|
"github.com/alcionai/corso/src/cli/utils/testdata"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package backup
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli/options"
|
"github.com/alcionai/corso/src/cli/options"
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
@ -161,12 +161,12 @@ func createSharePointCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(ctx, graph.HTTPClient(graph.NoTimeout()), *acct, connector.Sites, errs)
|
gc, err := connector.NewGraphConnector(ctx, graph.HTTPClient(graph.NoTimeout()), *acct, connector.Sites, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to connect to Microsoft APIs"))
|
return Only(ctx, clues.Wrap(err, "Failed to connect to Microsoft APIs"))
|
||||||
}
|
}
|
||||||
|
|
||||||
sel, err := sharePointBackupCreateSelectors(ctx, utils.SiteID, utils.WebURL, sharepointData, gc)
|
sel, err := sharePointBackupCreateSelectors(ctx, utils.SiteID, utils.WebURL, sharepointData, gc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Retrieving up sharepoint sites by ID and URL"))
|
return Only(ctx, clues.Wrap(err, "Retrieving up sharepoint sites by ID and URL"))
|
||||||
}
|
}
|
||||||
|
|
||||||
selectorSet := []selectors.Selector{}
|
selectorSet := []selectors.Selector{}
|
||||||
@ -185,7 +185,7 @@ func createSharePointCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
func validateSharePointBackupCreateFlags(sites, weburls, cats []string) error {
|
func validateSharePointBackupCreateFlags(sites, weburls, cats []string) error {
|
||||||
if len(sites) == 0 && len(weburls) == 0 {
|
if len(sites) == 0 && len(weburls) == 0 {
|
||||||
return errors.New(
|
return clues.New(
|
||||||
"requires one or more --" +
|
"requires one or more --" +
|
||||||
utils.SiteFN + " urls, or the wildcard --" +
|
utils.SiteFN + " urls, or the wildcard --" +
|
||||||
utils.SiteFN + " *",
|
utils.SiteFN + " *",
|
||||||
@ -194,7 +194,7 @@ func validateSharePointBackupCreateFlags(sites, weburls, cats []string) error {
|
|||||||
|
|
||||||
for _, d := range cats {
|
for _, d := range cats {
|
||||||
if d != dataLibraries && d != dataPages {
|
if d != dataLibraries && d != dataPages {
|
||||||
return errors.New(
|
return clues.New(
|
||||||
d + " is an unrecognized data type; either " + dataLibraries + "or " + dataPages,
|
d + " is an unrecognized data type; either " + dataLibraries + "or " + dataPages,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -383,10 +383,10 @@ func runDetailsSharePointCmd(
|
|||||||
// TODO: log/track recoverable errors
|
// TODO: log/track recoverable errors
|
||||||
if errs.Failure() != nil {
|
if errs.Failure() != nil {
|
||||||
if errors.Is(errs.Failure(), data.ErrNotFound) {
|
if errors.Is(errs.Failure(), data.ErrNotFound) {
|
||||||
return nil, errors.Errorf("no backup exists with the id %s", backupID)
|
return nil, clues.New("no backup exists with the id " + backupID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, errors.Wrap(errs.Failure(), "Failed to get backup details in the repository")
|
return nil, clues.Wrap(errs.Failure(), "Failed to get backup details in the repository")
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = clues.Add(ctx, "details_entries", len(d.Entries))
|
ctx = clues.Add(ctx, "details_entries", len(d.Entries))
|
||||||
|
|||||||
@ -5,13 +5,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli"
|
"github.com/alcionai/corso/src/cli"
|
||||||
"github.com/alcionai/corso/src/cli/config"
|
"github.com/alcionai/corso/src/cli/config"
|
||||||
"github.com/alcionai/corso/src/cli/print"
|
"github.com/alcionai/corso/src/cli/print"
|
||||||
|
|||||||
@ -3,12 +3,12 @@ package backup
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/cli/utils/testdata"
|
"github.com/alcionai/corso/src/cli/utils/testdata"
|
||||||
"github.com/alcionai/corso/src/internal/connector"
|
"github.com/alcionai/corso/src/internal/connector"
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package config
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
@ -18,7 +18,7 @@ func m365ConfigsFromViper(vpr *viper.Viper) (account.M365Config, error) {
|
|||||||
|
|
||||||
providerType := vpr.GetString(AccountProviderTypeKey)
|
providerType := vpr.GetString(AccountProviderTypeKey)
|
||||||
if providerType != account.ProviderM365.String() {
|
if providerType != account.ProviderM365.String() {
|
||||||
return m365, errors.New("unsupported account provider: " + providerType)
|
return m365, clues.New("unsupported account provider: " + providerType)
|
||||||
}
|
}
|
||||||
|
|
||||||
m365.AzureTenantID = vpr.GetString(AzureTenantIDKey)
|
m365.AzureTenantID = vpr.GetString(AzureTenantIDKey)
|
||||||
@ -49,18 +49,18 @@ func configureAccount(
|
|||||||
if readConfigFromViper {
|
if readConfigFromViper {
|
||||||
m365Cfg, err = m365ConfigsFromViper(vpr)
|
m365Cfg, err = m365ConfigsFromViper(vpr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return acct, errors.Wrap(err, "reading m365 configs from corso config file")
|
return acct, clues.Wrap(err, "reading m365 configs from corso config file")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mustMatchConfig(vpr, m365Overrides(overrides)); err != nil {
|
if err := mustMatchConfig(vpr, m365Overrides(overrides)); err != nil {
|
||||||
return acct, errors.Wrap(err, "verifying m365 configs in corso config file")
|
return acct, clues.Wrap(err, "verifying m365 configs in corso config file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// compose the m365 config and credentials
|
// compose the m365 config and credentials
|
||||||
m365 := credentials.GetM365()
|
m365 := credentials.GetM365()
|
||||||
if err := m365.Validate(); err != nil {
|
if err := m365.Validate(); err != nil {
|
||||||
return acct, errors.Wrap(err, "validating m365 credentials")
|
return acct, clues.Wrap(err, "validating m365 credentials")
|
||||||
}
|
}
|
||||||
|
|
||||||
m365Cfg = account.M365Config{
|
m365Cfg = account.M365Config{
|
||||||
@ -83,7 +83,7 @@ func configureAccount(
|
|||||||
// build the account
|
// build the account
|
||||||
acct, err = account.NewAccount(account.ProviderM365, m365Cfg)
|
acct, err = account.NewAccount(account.ProviderM365, m365Cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return acct, errors.Wrap(err, "retrieving m365 account configuration")
|
return acct, clues.Wrap(err, "retrieving m365 account configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
return acct, nil
|
return acct, nil
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ func initWithViper(vpr *viper.Viper, configFP string) error {
|
|||||||
|
|
||||||
ext := filepath.Ext(configFP)
|
ext := filepath.Ext(configFP)
|
||||||
if len(ext) == 0 {
|
if len(ext) == 0 {
|
||||||
return errors.New("config file requires an extension e.g. `toml`")
|
return clues.New("config file requires an extension e.g. `toml`")
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName := filepath.Base(configFP)
|
fileName := filepath.Base(configFP)
|
||||||
@ -265,7 +265,7 @@ func getStorageAndAccountWithViper(
|
|||||||
err = vpr.ReadInConfig()
|
err = vpr.ReadInConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
|
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
|
||||||
return config, errors.Wrap(err, "reading corso config file: "+vpr.ConfigFileUsed())
|
return config, clues.Wrap(err, "reading corso config file: "+vpr.ConfigFileUsed())
|
||||||
}
|
}
|
||||||
|
|
||||||
readConfigFromViper = false
|
readConfigFromViper = false
|
||||||
@ -277,12 +277,12 @@ func getStorageAndAccountWithViper(
|
|||||||
|
|
||||||
config.Account, err = configureAccount(vpr, readConfigFromViper, overrides)
|
config.Account, err = configureAccount(vpr, readConfigFromViper, overrides)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config, errors.Wrap(err, "retrieving account configuration details")
|
return config, clues.Wrap(err, "retrieving account configuration details")
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Storage, err = configureStorage(vpr, readConfigFromViper, overrides)
|
config.Storage, err = configureStorage(vpr, readConfigFromViper, overrides)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config, errors.Wrap(err, "retrieving storage provider details")
|
return config, clues.Wrap(err, "retrieving storage provider details")
|
||||||
}
|
}
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
@ -317,7 +317,7 @@ func mustMatchConfig(vpr *viper.Viper, m map[string]string) error {
|
|||||||
|
|
||||||
vv := vpr.GetString(tomlK)
|
vv := vpr.GetString(tomlK)
|
||||||
if v != vv {
|
if v != vv {
|
||||||
return errors.New("value of " + k + " (" + v + ") does not match corso configuration value (" + vv + ")")
|
return clues.New("value of " + k + " (" + v + ") does not match corso configuration value (" + vv + ")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,12 +6,12 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
"github.com/alcionai/corso/src/pkg/credentials"
|
"github.com/alcionai/corso/src/pkg/credentials"
|
||||||
|
|||||||
@ -5,8 +5,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/aws/aws-sdk-go/aws/defaults"
|
"github.com/aws/aws-sdk-go/aws/defaults"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
@ -21,7 +21,7 @@ func s3ConfigsFromViper(vpr *viper.Viper) (storage.S3Config, error) {
|
|||||||
|
|
||||||
providerType := vpr.GetString(StorageProviderTypeKey)
|
providerType := vpr.GetString(StorageProviderTypeKey)
|
||||||
if providerType != storage.ProviderS3.String() {
|
if providerType != storage.ProviderS3.String() {
|
||||||
return s3Config, errors.New("unsupported storage provider: " + providerType)
|
return s3Config, clues.New("unsupported storage provider: " + providerType)
|
||||||
}
|
}
|
||||||
|
|
||||||
s3Config.Bucket = vpr.GetString(BucketNameKey)
|
s3Config.Bucket = vpr.GetString(BucketNameKey)
|
||||||
@ -59,7 +59,7 @@ func configureStorage(
|
|||||||
|
|
||||||
if readConfigFromViper {
|
if readConfigFromViper {
|
||||||
if s3Cfg, err = s3ConfigsFromViper(vpr); err != nil {
|
if s3Cfg, err = s3ConfigsFromViper(vpr); err != nil {
|
||||||
return store, errors.Wrap(err, "reading s3 configs from corso config file")
|
return store, clues.Wrap(err, "reading s3 configs from corso config file")
|
||||||
}
|
}
|
||||||
|
|
||||||
if b, ok := overrides[storage.Bucket]; ok {
|
if b, ok := overrides[storage.Bucket]; ok {
|
||||||
@ -71,13 +71,13 @@ func configureStorage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := mustMatchConfig(vpr, s3Overrides(overrides)); err != nil {
|
if err := mustMatchConfig(vpr, s3Overrides(overrides)); err != nil {
|
||||||
return store, errors.Wrap(err, "verifying s3 configs in corso config file")
|
return store, clues.Wrap(err, "verifying s3 configs in corso config file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = defaults.CredChain(defaults.Config().WithCredentialsChainVerboseErrors(true), defaults.Handlers()).Get()
|
_, err = defaults.CredChain(defaults.Config().WithCredentialsChainVerboseErrors(true), defaults.Handlers()).Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return store, errors.Wrap(err, "validating aws credentials")
|
return store, clues.Wrap(err, "validating aws credentials")
|
||||||
}
|
}
|
||||||
|
|
||||||
s3Cfg = storage.S3Config{
|
s3Cfg = storage.S3Config{
|
||||||
@ -97,7 +97,7 @@ func configureStorage(
|
|||||||
// compose the common config and credentials
|
// compose the common config and credentials
|
||||||
corso := credentials.GetCorso()
|
corso := credentials.GetCorso()
|
||||||
if err := corso.Validate(); err != nil {
|
if err := corso.Validate(); err != nil {
|
||||||
return store, errors.Wrap(err, "validating corso credentials")
|
return store, clues.Wrap(err, "validating corso credentials")
|
||||||
}
|
}
|
||||||
|
|
||||||
cCfg := storage.CommonConfig{
|
cCfg := storage.CommonConfig{
|
||||||
@ -122,7 +122,7 @@ func configureStorage(
|
|||||||
// build the storage
|
// build the storage
|
||||||
store, err = storage.NewStorage(storage.ProviderS3, s3Cfg, cCfg)
|
store, err = storage.NewStorage(storage.ProviderS3, s3Cfg, cCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return store, errors.Wrap(err, "configuring repository storage")
|
return store, clues.Wrap(err, "configuring repository storage")
|
||||||
}
|
}
|
||||||
|
|
||||||
return store, nil
|
return store, nil
|
||||||
|
|||||||
@ -4,11 +4,11 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -126,19 +127,19 @@ func initS3Cmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
s3Cfg, err := cfg.Storage.S3Config()
|
s3Cfg, err := cfg.Storage.S3Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Retrieving s3 configuration"))
|
return Only(ctx, clues.Wrap(err, "Retrieving s3 configuration"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(s3Cfg.Endpoint, "http://") || strings.HasPrefix(s3Cfg.Endpoint, "https://") {
|
if strings.HasPrefix(s3Cfg.Endpoint, "http://") || strings.HasPrefix(s3Cfg.Endpoint, "https://") {
|
||||||
invalidEndpointErr := "endpoint doesn't support specifying protocol. " +
|
invalidEndpointErr := "endpoint doesn't support specifying protocol. " +
|
||||||
"pass --disable-tls flag to use http:// instead of default https://"
|
"pass --disable-tls flag to use http:// instead of default https://"
|
||||||
|
|
||||||
return Only(ctx, errors.New(invalidEndpointErr))
|
return Only(ctx, clues.New(invalidEndpointErr))
|
||||||
}
|
}
|
||||||
|
|
||||||
m365, err := cfg.Account.M365Config()
|
m365, err := cfg.Account.M365Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to parse m365 account config"))
|
return Only(ctx, clues.Wrap(err, "Failed to parse m365 account config"))
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := repository.Initialize(ctx, cfg.Account, cfg.Storage, options.Control())
|
r, err := repository.Initialize(ctx, cfg.Account, cfg.Storage, options.Control())
|
||||||
@ -147,7 +148,7 @@ func initS3Cmd(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to initialize a new S3 repository"))
|
return Only(ctx, clues.Wrap(err, "Failed to initialize a new S3 repository"))
|
||||||
}
|
}
|
||||||
|
|
||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
@ -155,7 +156,7 @@ func initS3Cmd(cmd *cobra.Command, args []string) error {
|
|||||||
Infof(ctx, "Initialized a S3 repository within bucket %s.", s3Cfg.Bucket)
|
Infof(ctx, "Initialized a S3 repository within bucket %s.", s3Cfg.Bucket)
|
||||||
|
|
||||||
if err = config.WriteRepoConfig(ctx, s3Cfg, m365, r.GetID()); err != nil {
|
if err = config.WriteRepoConfig(ctx, s3Cfg, m365, r.GetID()); err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to write repository configuration"))
|
return Only(ctx, clues.Wrap(err, "Failed to write repository configuration"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -192,24 +193,24 @@ func connectS3Cmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
s3Cfg, err := cfg.Storage.S3Config()
|
s3Cfg, err := cfg.Storage.S3Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Retrieving s3 configuration"))
|
return Only(ctx, clues.Wrap(err, "Retrieving s3 configuration"))
|
||||||
}
|
}
|
||||||
|
|
||||||
m365, err := cfg.Account.M365Config()
|
m365, err := cfg.Account.M365Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to parse m365 account config"))
|
return Only(ctx, clues.Wrap(err, "Failed to parse m365 account config"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(s3Cfg.Endpoint, "http://") || strings.HasPrefix(s3Cfg.Endpoint, "https://") {
|
if strings.HasPrefix(s3Cfg.Endpoint, "http://") || strings.HasPrefix(s3Cfg.Endpoint, "https://") {
|
||||||
invalidEndpointErr := "endpoint doesn't support specifying protocol. " +
|
invalidEndpointErr := "endpoint doesn't support specifying protocol. " +
|
||||||
"pass --disable-tls flag to use http:// instead of default https://"
|
"pass --disable-tls flag to use http:// instead of default https://"
|
||||||
|
|
||||||
return Only(ctx, errors.New(invalidEndpointErr))
|
return Only(ctx, clues.New(invalidEndpointErr))
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := repository.ConnectAndSendConnectEvent(ctx, cfg.Account, cfg.Storage, options.Control())
|
r, err := repository.ConnectAndSendConnectEvent(ctx, cfg.Account, cfg.Storage, options.Control())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to connect to the S3 repository"))
|
return Only(ctx, clues.Wrap(err, "Failed to connect to the S3 repository"))
|
||||||
}
|
}
|
||||||
|
|
||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
@ -217,7 +218,7 @@ func connectS3Cmd(cmd *cobra.Command, args []string) error {
|
|||||||
Infof(ctx, "Connected to S3 bucket %s.", s3Cfg.Bucket)
|
Infof(ctx, "Connected to S3 bucket %s.", s3Cfg.Bucket)
|
||||||
|
|
||||||
if err = config.WriteRepoConfig(ctx, s3Cfg, m365, r.GetID()); err != nil {
|
if err = config.WriteRepoConfig(ctx, s3Cfg, m365, r.GetID()); err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to write repository configuration"))
|
return Only(ctx, clues.Wrap(err, "Failed to write repository configuration"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -4,11 +4,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli"
|
"github.com/alcionai/corso/src/cli"
|
||||||
"github.com/alcionai/corso/src/cli/config"
|
"github.com/alcionai/corso/src/cli/config"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package restore
|
package restore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -138,7 +139,7 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
r, err := repository.Connect(ctx, cfg.Account, cfg.Storage, options.Control())
|
r, err := repository.Connect(ctx, cfg.Account, cfg.Storage, options.Control())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrapf(err, "Failed to connect to the %s repository", cfg.Storage.Provider))
|
return Only(ctx, clues.Wrap(err, "Failed to connect to the "+cfg.Storage.Provider.String()+" repository"))
|
||||||
}
|
}
|
||||||
|
|
||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
@ -151,16 +152,16 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
ro, err := r.NewRestore(ctx, utils.BackupID, sel.Selector, dest)
|
ro, err := r.NewRestore(ctx, utils.BackupID, sel.Selector, dest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to initialize Exchange restore"))
|
return Only(ctx, clues.Wrap(err, "Failed to initialize Exchange restore"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ds, err := ro.Run(ctx)
|
ds, err := ro.Run(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, data.ErrNotFound) {
|
if errors.Is(err, data.ErrNotFound) {
|
||||||
return Only(ctx, errors.Errorf("Backup or backup details missing for id %s", utils.BackupID))
|
return Only(ctx, clues.New("Backup or backup details missing for id "+utils.BackupID))
|
||||||
}
|
}
|
||||||
|
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to run Exchange restore"))
|
return Only(ctx, clues.Wrap(err, "Failed to run Exchange restore"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ds.PrintEntries(ctx)
|
ds.PrintEntries(ctx)
|
||||||
|
|||||||
@ -4,11 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli"
|
"github.com/alcionai/corso/src/cli"
|
||||||
"github.com/alcionai/corso/src/cli/config"
|
"github.com/alcionai/corso/src/cli/config"
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package restore
|
package restore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -103,7 +104,7 @@ func restoreOneDriveCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
r, err := repository.Connect(ctx, cfg.Account, cfg.Storage, options.Control())
|
r, err := repository.Connect(ctx, cfg.Account, cfg.Storage, options.Control())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrapf(err, "Failed to connect to the %s repository", cfg.Storage.Provider))
|
return Only(ctx, clues.Wrap(err, "Failed to connect to the "+cfg.Storage.Provider.String()+" repository"))
|
||||||
}
|
}
|
||||||
|
|
||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
@ -116,16 +117,16 @@ func restoreOneDriveCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
ro, err := r.NewRestore(ctx, utils.BackupID, sel.Selector, dest)
|
ro, err := r.NewRestore(ctx, utils.BackupID, sel.Selector, dest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to initialize OneDrive restore"))
|
return Only(ctx, clues.Wrap(err, "Failed to initialize OneDrive restore"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ds, err := ro.Run(ctx)
|
ds, err := ro.Run(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, data.ErrNotFound) {
|
if errors.Is(err, data.ErrNotFound) {
|
||||||
return Only(ctx, errors.Errorf("Backup or backup details missing for id %s", utils.BackupID))
|
return Only(ctx, clues.New("Backup or backup details missing for id "+utils.BackupID))
|
||||||
}
|
}
|
||||||
|
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to run OneDrive restore"))
|
return Only(ctx, clues.Wrap(err, "Failed to run OneDrive restore"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ds.PrintEntries(ctx)
|
ds.PrintEntries(ctx)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package restore
|
package restore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -117,7 +118,7 @@ func restoreSharePointCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
r, err := repository.Connect(ctx, cfg.Account, cfg.Storage, options.Control())
|
r, err := repository.Connect(ctx, cfg.Account, cfg.Storage, options.Control())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrapf(err, "Failed to connect to the %s repository", cfg.Storage.Provider))
|
return Only(ctx, clues.Wrap(err, "Failed to connect to the "+cfg.Storage.Provider.String()+" repository"))
|
||||||
}
|
}
|
||||||
|
|
||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
@ -130,16 +131,16 @@ func restoreSharePointCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
ro, err := r.NewRestore(ctx, utils.BackupID, sel.Selector, dest)
|
ro, err := r.NewRestore(ctx, utils.BackupID, sel.Selector, dest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to initialize SharePoint restore"))
|
return Only(ctx, clues.Wrap(err, "Failed to initialize SharePoint restore"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ds, err := ro.Run(ctx)
|
ds, err := ro.Run(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, data.ErrNotFound) {
|
if errors.Is(err, data.ErrNotFound) {
|
||||||
return Only(ctx, errors.Errorf("Backup or backup details missing for id %s", utils.BackupID))
|
return Only(ctx, clues.New("Backup or backup details missing for id "+utils.BackupID))
|
||||||
}
|
}
|
||||||
|
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to run SharePoint restore"))
|
return Only(ctx, clues.Wrap(err, "Failed to run SharePoint restore"))
|
||||||
}
|
}
|
||||||
|
|
||||||
ds.PrintEntries(ctx)
|
ds.PrintEntries(ctx)
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"github.com/alcionai/clues"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// flag names
|
// flag names
|
||||||
@ -197,27 +197,27 @@ func AddExchangeInfo(
|
|||||||
// ValidateExchangeRestoreFlags checks common flags for correctness and interdependencies
|
// ValidateExchangeRestoreFlags checks common flags for correctness and interdependencies
|
||||||
func ValidateExchangeRestoreFlags(backupID string, opts ExchangeOpts) error {
|
func ValidateExchangeRestoreFlags(backupID string, opts ExchangeOpts) error {
|
||||||
if len(backupID) == 0 {
|
if len(backupID) == 0 {
|
||||||
return errors.New("a backup ID is required")
|
return clues.New("a backup ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[EmailReceivedAfterFN]; ok && !IsValidTimeFormat(opts.EmailReceivedAfter) {
|
if _, ok := opts.Populated[EmailReceivedAfterFN]; ok && !IsValidTimeFormat(opts.EmailReceivedAfter) {
|
||||||
return errors.New("invalid time format for email-received-after")
|
return clues.New("invalid time format for email-received-after")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[EmailReceivedBeforeFN]; ok && !IsValidTimeFormat(opts.EmailReceivedBefore) {
|
if _, ok := opts.Populated[EmailReceivedBeforeFN]; ok && !IsValidTimeFormat(opts.EmailReceivedBefore) {
|
||||||
return errors.New("invalid time format for email-received-before")
|
return clues.New("invalid time format for email-received-before")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[EventStartsAfterFN]; ok && !IsValidTimeFormat(opts.EventStartsAfter) {
|
if _, ok := opts.Populated[EventStartsAfterFN]; ok && !IsValidTimeFormat(opts.EventStartsAfter) {
|
||||||
return errors.New("invalid time format for event-starts-after")
|
return clues.New("invalid time format for event-starts-after")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[EventStartsBeforeFN]; ok && !IsValidTimeFormat(opts.EventStartsBefore) {
|
if _, ok := opts.Populated[EventStartsBeforeFN]; ok && !IsValidTimeFormat(opts.EventStartsBefore) {
|
||||||
return errors.New("invalid time format for event-starts-before")
|
return clues.New("invalid time format for event-starts-before")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[EventRecursFN]; ok && !IsValidBool(opts.EventRecurs) {
|
if _, ok := opts.Populated[EventRecursFN]; ok && !IsValidBool(opts.EventRecurs) {
|
||||||
return errors.New("invalid format for event-recurs")
|
return clues.New("invalid format for event-recurs")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -3,10 +3,10 @@ package utils_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"github.com/alcionai/clues"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type OneDriveOpts struct {
|
type OneDriveOpts struct {
|
||||||
@ -57,23 +57,23 @@ func AddOneDriveDetailsAndRestoreFlags(cmd *cobra.Command) {
|
|||||||
// ValidateOneDriveRestoreFlags checks common flags for correctness and interdependencies
|
// ValidateOneDriveRestoreFlags checks common flags for correctness and interdependencies
|
||||||
func ValidateOneDriveRestoreFlags(backupID string, opts OneDriveOpts) error {
|
func ValidateOneDriveRestoreFlags(backupID string, opts OneDriveOpts) error {
|
||||||
if len(backupID) == 0 {
|
if len(backupID) == 0 {
|
||||||
return errors.New("a backup ID is required")
|
return clues.New("a backup ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[FileCreatedAfterFN]; ok && !IsValidTimeFormat(opts.FileCreatedAfter) {
|
if _, ok := opts.Populated[FileCreatedAfterFN]; ok && !IsValidTimeFormat(opts.FileCreatedAfter) {
|
||||||
return errors.New("invalid time format for created-after")
|
return clues.New("invalid time format for created-after")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[FileCreatedBeforeFN]; ok && !IsValidTimeFormat(opts.FileCreatedBefore) {
|
if _, ok := opts.Populated[FileCreatedBeforeFN]; ok && !IsValidTimeFormat(opts.FileCreatedBefore) {
|
||||||
return errors.New("invalid time format for created-before")
|
return clues.New("invalid time format for created-before")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[FileModifiedAfterFN]; ok && !IsValidTimeFormat(opts.FileModifiedAfter) {
|
if _, ok := opts.Populated[FileModifiedAfterFN]; ok && !IsValidTimeFormat(opts.FileModifiedAfter) {
|
||||||
return errors.New("invalid time format for modified-after")
|
return clues.New("invalid time format for modified-after")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[FileModifiedBeforeFN]; ok && !IsValidTimeFormat(opts.FileModifiedBefore) {
|
if _, ok := opts.Populated[FileModifiedBeforeFN]; ok && !IsValidTimeFormat(opts.FileModifiedBefore) {
|
||||||
return errors.New("invalid time format for modified-before")
|
return clues.New("invalid time format for modified-before")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"github.com/alcionai/clues"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -97,23 +97,23 @@ func AddSharePointDetailsAndRestoreFlags(cmd *cobra.Command) {
|
|||||||
// ValidateSharePointRestoreFlags checks common flags for correctness and interdependencies
|
// ValidateSharePointRestoreFlags checks common flags for correctness and interdependencies
|
||||||
func ValidateSharePointRestoreFlags(backupID string, opts SharePointOpts) error {
|
func ValidateSharePointRestoreFlags(backupID string, opts SharePointOpts) error {
|
||||||
if len(backupID) == 0 {
|
if len(backupID) == 0 {
|
||||||
return errors.New("a backup ID is required")
|
return clues.New("a backup ID is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[FileCreatedAfterFN]; ok && !IsValidTimeFormat(opts.FileCreatedAfter) {
|
if _, ok := opts.Populated[FileCreatedAfterFN]; ok && !IsValidTimeFormat(opts.FileCreatedAfter) {
|
||||||
return errors.New("invalid time format for " + FileCreatedAfterFN)
|
return clues.New("invalid time format for " + FileCreatedAfterFN)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[FileCreatedBeforeFN]; ok && !IsValidTimeFormat(opts.FileCreatedBefore) {
|
if _, ok := opts.Populated[FileCreatedBeforeFN]; ok && !IsValidTimeFormat(opts.FileCreatedBefore) {
|
||||||
return errors.New("invalid time format for " + FileCreatedBeforeFN)
|
return clues.New("invalid time format for " + FileCreatedBeforeFN)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[FileModifiedAfterFN]; ok && !IsValidTimeFormat(opts.FileModifiedAfter) {
|
if _, ok := opts.Populated[FileModifiedAfterFN]; ok && !IsValidTimeFormat(opts.FileModifiedAfter) {
|
||||||
return errors.New("invalid time format for " + FileModifiedAfterFN)
|
return clues.New("invalid time format for " + FileModifiedAfterFN)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := opts.Populated[FileModifiedBeforeFN]; ok && !IsValidTimeFormat(opts.FileModifiedBefore) {
|
if _, ok := opts.Populated[FileModifiedBeforeFN]; ok && !IsValidTimeFormat(opts.FileModifiedBefore) {
|
||||||
return errors.New("invalid time format for " + FileModifiedBeforeFN)
|
return clues.New("invalid time format for " + FileModifiedBeforeFN)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
13
src/cli/utils/testdata/opts.go
vendored
13
src/cli/utils/testdata/opts.go
vendored
@ -2,9 +2,10 @@ package testdata
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/model"
|
"github.com/alcionai/corso/src/internal/model"
|
||||||
@ -560,21 +561,21 @@ func (MockBackupGetter) Backup(
|
|||||||
context.Context,
|
context.Context,
|
||||||
model.StableID,
|
model.StableID,
|
||||||
) (*backup.Backup, error) {
|
) (*backup.Backup, error) {
|
||||||
return nil, errors.New("unexpected call to mock")
|
return nil, clues.New("unexpected call to mock")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (MockBackupGetter) Backups(
|
func (MockBackupGetter) Backups(
|
||||||
context.Context,
|
context.Context,
|
||||||
[]model.StableID,
|
[]model.StableID,
|
||||||
) ([]*backup.Backup, *fault.Bus) {
|
) ([]*backup.Backup, *fault.Bus) {
|
||||||
return nil, fault.New(false).Fail(errors.New("unexpected call to mock"))
|
return nil, fault.New(false).Fail(clues.New("unexpected call to mock"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (MockBackupGetter) BackupsByTag(
|
func (MockBackupGetter) BackupsByTag(
|
||||||
context.Context,
|
context.Context,
|
||||||
...store.FilterOption,
|
...store.FilterOption,
|
||||||
) ([]*backup.Backup, error) {
|
) ([]*backup.Backup, error) {
|
||||||
return nil, errors.New("unexpected call to mock")
|
return nil, clues.New("unexpected call to mock")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bg *MockBackupGetter) GetBackupDetails(
|
func (bg *MockBackupGetter) GetBackupDetails(
|
||||||
@ -585,7 +586,7 @@ func (bg *MockBackupGetter) GetBackupDetails(
|
|||||||
return testdata.GetDetailsSet(), nil, fault.New(true)
|
return testdata.GetDetailsSet(), nil, fault.New(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil, fault.New(false).Fail(errors.New("unexpected call to mock"))
|
return nil, nil, fault.New(false).Fail(clues.New("unexpected call to mock"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bg *MockBackupGetter) GetBackupErrors(
|
func (bg *MockBackupGetter) GetBackupErrors(
|
||||||
@ -597,5 +598,5 @@ func (bg *MockBackupGetter) GetBackupErrors(
|
|||||||
return &fe, nil, fault.New(true)
|
return &fe, nil, fault.New(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil, fault.New(false).Fail(errors.New("unexpected call to mock"))
|
return nil, nil, fault.New(false).Fail(clues.New("unexpected call to mock"))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,9 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ const (
|
|||||||
func RequireProps(props map[string]string) error {
|
func RequireProps(props map[string]string) error {
|
||||||
for name, val := range props {
|
for name, val := range props {
|
||||||
if len(val) == 0 {
|
if len(val) == 0 {
|
||||||
return errors.New(name + " is required to perform this command")
|
return clues.New(name + " is required to perform this command")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,10 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/print"
|
"github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
@ -34,9 +33,9 @@ var (
|
|||||||
User string
|
User string
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: ErrGenerating = errors.New("not all items were successfully generated")
|
// TODO: ErrGenerating = clues.New("not all items were successfully generated")
|
||||||
|
|
||||||
var ErrNotYetImplemeted = errors.New("not yet implemented")
|
var ErrNotYetImplemeted = clues.New("not yet implemented")
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------
|
||||||
// Restoration
|
// Restoration
|
||||||
@ -115,7 +114,7 @@ func getGCAndVerifyUser(ctx context.Context, userID string) (*connector.GraphCon
|
|||||||
|
|
||||||
acct, err := account.NewAccount(account.ProviderM365, m365Cfg)
|
acct, err := account.NewAccount(account.ProviderM365, m365Cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, account.Account{}, errors.Wrap(err, "finding m365 account details")
|
return nil, account.Account{}, clues.Wrap(err, "finding m365 account details")
|
||||||
}
|
}
|
||||||
|
|
||||||
// build a graph connector
|
// build a graph connector
|
||||||
@ -133,7 +132,7 @@ func getGCAndVerifyUser(ctx context.Context, userID string) (*connector.GraphCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := normUsers[strings.ToLower(User)]; !ok {
|
if _, ok := normUsers[strings.ToLower(User)]; !ok {
|
||||||
return nil, account.Account{}, errors.New("user not found within tenant")
|
return nil, account.Account{}, clues.New("user not found within tenant")
|
||||||
}
|
}
|
||||||
|
|
||||||
gc, err := connector.NewGraphConnector(
|
gc, err := connector.NewGraphConnector(
|
||||||
@ -143,7 +142,7 @@ func getGCAndVerifyUser(ctx context.Context, userID string) (*connector.GraphCon
|
|||||||
connector.Users,
|
connector.Users,
|
||||||
errs)
|
errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, account.Account{}, errors.Wrap(err, "connecting to graph api")
|
return nil, account.Account{}, clues.Wrap(err, "connecting to graph api")
|
||||||
}
|
}
|
||||||
|
|
||||||
return gc, acct, nil
|
return gc, acct, nil
|
||||||
|
|||||||
@ -9,9 +9,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
"github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
kw "github.com/microsoft/kiota-serialization-json-go"
|
kw "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
@ -83,7 +83,7 @@ func handleGetCommand(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
err = runDisplayM365JSON(ctx, creds, user, m365ID, fault.New(true))
|
err = runDisplayM365JSON(ctx, creds, user, m365ID, fault.New(true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrapf(err, "unable to create mock from M365: %s", m365ID))
|
return Only(ctx, clues.Wrap(err, "Error displaying item: "+m365ID))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -126,12 +126,12 @@ func runDisplayM365JSON(
|
|||||||
|
|
||||||
err = sw.WriteStringValue("", &str)
|
err = sw.WriteStringValue("", &str)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "unable to %s to string value", itemID)
|
return clues.Wrap(err, "Error writing string value: "+itemID)
|
||||||
}
|
}
|
||||||
|
|
||||||
array, err := sw.GetSerializedContent()
|
array, err := sw.GetSerializedContent()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "unable to serialize new value from M365:%s", itemID)
|
return clues.Wrap(err, "Error serializing item: "+itemID)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(string(array))
|
fmt.Println(string(array))
|
||||||
@ -160,7 +160,7 @@ func getItem(
|
|||||||
) ([]byte, error) {
|
) ([]byte, error) {
|
||||||
sp, _, err := itm.GetItem(ctx, user, itemID, errs)
|
sp, _, err := itm.GetItem(ctx, user, itemID, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "getting item")
|
return nil, clues.Wrap(err, "getting item")
|
||||||
}
|
}
|
||||||
|
|
||||||
return itm.Serialize(ctx, sp, user, itemID)
|
return itm.Serialize(ctx, sp, user, itemID)
|
||||||
@ -179,7 +179,7 @@ func getGC(ctx context.Context) (*connector.GraphConnector, account.M365Config,
|
|||||||
|
|
||||||
acct, err := account.NewAccount(account.ProviderM365, m365Cfg)
|
acct, err := account.NewAccount(account.ProviderM365, m365Cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, m365Cfg, Only(ctx, errors.Wrap(err, "finding m365 account details"))
|
return nil, m365Cfg, Only(ctx, clues.Wrap(err, "finding m365 account details"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: log/print recoverable errors
|
// TODO: log/print recoverable errors
|
||||||
@ -187,7 +187,7 @@ func getGC(ctx context.Context) (*connector.GraphConnector, account.M365Config,
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(ctx, graph.HTTPClient(graph.NoTimeout()), acct, connector.Users, errs)
|
gc, err := connector.NewGraphConnector(ctx, graph.HTTPClient(graph.NoTimeout()), acct, connector.Users, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, m365Cfg, Only(ctx, errors.Wrap(err, "connecting to graph API"))
|
return nil, m365Cfg, Only(ctx, clues.Wrap(err, "connecting to graph API"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return gc, m365Cfg, nil
|
return gc, m365Cfg, nil
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -45,35 +46,35 @@ func main() {
|
|||||||
|
|
||||||
func genDocs(cmd *cobra.Command, args []string) {
|
func genDocs(cmd *cobra.Command, args []string) {
|
||||||
if err := makeDir(cliMarkdownDir); err != nil {
|
if err := makeDir(cliMarkdownDir); err != nil {
|
||||||
fatal(errors.Wrap(err, "preparing directory for markdown generation"))
|
fatal(clues.Wrap(err, "preparing directory for markdown generation"))
|
||||||
}
|
}
|
||||||
|
|
||||||
corsoCmd := cli.CorsoCommand()
|
corsoCmd := cli.CorsoCommand()
|
||||||
|
|
||||||
err := genMarkdownCorso(corsoCmd, cliMarkdownDir)
|
err := genMarkdownCorso(corsoCmd, cliMarkdownDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatal(errors.Wrap(err, "generating the Corso CLI markdown"))
|
fatal(clues.Wrap(err, "generating the Corso CLI markdown"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeDir(dir string) error {
|
func makeDir(dir string) error {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "finding current working directory")
|
return clues.Wrap(err, "finding current working directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasSuffix(wd, "/src") {
|
if !strings.HasSuffix(wd, "/src") {
|
||||||
return errors.New("must be called from /corso/src")
|
return clues.New("must be called from /corso/src")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = os.Stat(dir)
|
_, err = os.Stat(dir)
|
||||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||||
return errors.Wrap(err, "unable to discover directory")
|
return clues.Wrap(err, "unable to discover directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
if err := os.Mkdir(dir, os.ModePerm); err != nil {
|
if err := os.Mkdir(dir, os.ModePerm); err != nil {
|
||||||
return errors.Wrap(err, "generating directory to hold markdown")
|
return clues.Wrap(err, "generating directory to hold markdown")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,10 +6,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
|
. "github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
. "github.com/alcionai/corso/src/cli/print"
|
|
||||||
"github.com/alcionai/corso/src/cli/utils"
|
"github.com/alcionai/corso/src/cli/utils"
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/connector"
|
"github.com/alcionai/corso/src/internal/connector"
|
||||||
@ -41,7 +41,7 @@ var (
|
|||||||
prefix string
|
prefix string
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrPurging = errors.New("not all items were successfully purged")
|
var ErrPurging = clues.New("not all items were successfully purged")
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------
|
||||||
// CLI command handlers
|
// CLI command handlers
|
||||||
@ -109,7 +109,7 @@ func handleOneDriveFolderPurge(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
if err := runPurgeForEachUser(ctx, acct, gc, t, purgeOneDriveFolders); err != nil {
|
if err := runPurgeForEachUser(ctx, acct, gc, t, purgeOneDriveFolders); err != nil {
|
||||||
logger.Ctx(ctx).Error(err)
|
logger.Ctx(ctx).Error(err)
|
||||||
return Only(ctx, errors.Wrap(ErrPurging, "OneDrive folders"))
|
return Only(ctx, clues.Wrap(ErrPurging, "OneDrive folders"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -182,7 +182,7 @@ func purgeOneDriveFolders(
|
|||||||
deleter := func(gs graph.Servicer, uid string, f purgable) error {
|
deleter := func(gs graph.Servicer, uid string, f purgable) error {
|
||||||
driveFolder, ok := f.(*onedrive.Displayable)
|
driveFolder, ok := f.(*onedrive.Displayable)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("non-OneDrive item")
|
return clues.New("non-OneDrive item")
|
||||||
}
|
}
|
||||||
|
|
||||||
return onedrive.DeleteItem(
|
return onedrive.DeleteItem(
|
||||||
@ -211,7 +211,7 @@ func purgeFolders(
|
|||||||
// get them folders
|
// get them folders
|
||||||
fs, err := getter(gc.Service, uid, prefix)
|
fs, err := getter(gc.Service, uid, prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrapf(err, "retrieving %s folders", data))
|
return Only(ctx, clues.Wrap(err, "retrieving folders: "+data))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(fs) == 0 {
|
if len(fs) == 0 {
|
||||||
@ -228,7 +228,7 @@ func purgeFolders(
|
|||||||
|
|
||||||
dnTime, err := common.ExtractTime(displayName)
|
dnTime, err := common.ExtractTime(displayName)
|
||||||
if err != nil && !errors.Is(err, common.ErrNoTimeString) {
|
if err != nil && !errors.Is(err, common.ErrNoTimeString) {
|
||||||
err = errors.Wrapf(err, "!! Error: parsing container named [%s]", displayName)
|
err = clues.Wrap(err, "!! Error: parsing container: "+displayName)
|
||||||
Info(ctx, err)
|
Info(ctx, err)
|
||||||
|
|
||||||
return err
|
return err
|
||||||
@ -242,7 +242,7 @@ func purgeFolders(
|
|||||||
|
|
||||||
err = deleter(gc.Service, uid, fld)
|
err = deleter(gc.Service, uid, fld)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrapf(err, "!! Error")
|
err = clues.Wrap(err, "!! Error")
|
||||||
Info(ctx, err)
|
Info(ctx, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ func getGC(ctx context.Context) (account.Account, *connector.GraphConnector, err
|
|||||||
|
|
||||||
acct, err := account.NewAccount(account.ProviderM365, m365Cfg)
|
acct, err := account.NewAccount(account.ProviderM365, m365Cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return account.Account{}, nil, Only(ctx, errors.Wrap(err, "finding m365 account details"))
|
return account.Account{}, nil, Only(ctx, clues.Wrap(err, "finding m365 account details"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// build a graph connector
|
// build a graph connector
|
||||||
@ -272,7 +272,7 @@ func getGC(ctx context.Context) (account.Account, *connector.GraphConnector, err
|
|||||||
|
|
||||||
gc, err := connector.NewGraphConnector(ctx, graph.HTTPClient(graph.NoTimeout()), acct, connector.Users, errs)
|
gc, err := connector.NewGraphConnector(ctx, graph.HTTPClient(graph.NoTimeout()), acct, connector.Users, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return account.Account{}, nil, Only(ctx, errors.Wrap(err, "connecting to graph api"))
|
return account.Account{}, nil, Only(ctx, clues.Wrap(err, "connecting to graph api"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return acct, gc, nil
|
return acct, gc, nil
|
||||||
@ -288,7 +288,7 @@ func getBoundaryTime(ctx context.Context) (time.Time, error) {
|
|||||||
if len(before) > 0 {
|
if len(before) > 0 {
|
||||||
boundaryTime, err = common.ParseTime(before)
|
boundaryTime, err = common.ParseTime(before)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return time.Time{}, Only(ctx, errors.Wrap(err, "parsing before flag to time"))
|
return time.Time{}, Only(ctx, clues.Wrap(err, "parsing before flag to time"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,10 @@ package common_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -4,10 +4,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/alcionai/corso/src/internal/common/crash"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/src/internal/common/crash"
|
||||||
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CrashTestDummySuite struct {
|
type CrashTestDummySuite struct {
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type TimeFormat string
|
type TimeFormat string
|
||||||
@ -87,8 +86,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrNoTimeString = errors.New("no substring contains a known time format")
|
ErrNoTimeString = clues.New("no substring contains a known time format")
|
||||||
errParsingStringToTime = errors.New("parsing string as time.Time")
|
errParsingStringToTime = clues.New("parsing string as time.Time")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Now produces the current time as a string in the standard format.
|
// Now produces the current time as a string in the standard format.
|
||||||
@ -136,7 +135,7 @@ func FormatLegacyTime(t time.Time) string {
|
|||||||
// the provided string. Always returns a UTC timezone value.
|
// the provided string. Always returns a UTC timezone value.
|
||||||
func ParseTime(s string) (time.Time, error) {
|
func ParseTime(s string) (time.Time, error) {
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
return time.Time{}, clues.Stack(errParsingStringToTime, errors.New("empty string"))
|
return time.Time{}, clues.Stack(errParsingStringToTime, clues.New("empty string"))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, form := range formats {
|
for _, form := range formats {
|
||||||
@ -146,14 +145,14 @@ func ParseTime(s string) (time.Time, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return time.Time{}, clues.Stack(errParsingStringToTime, errors.New(s))
|
return time.Time{}, clues.Stack(errParsingStringToTime, clues.New(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExtractTime greedily retrieves a timestamp substring from the provided string.
|
// ExtractTime greedily retrieves a timestamp substring from the provided string.
|
||||||
// returns ErrNoTimeString if no match is found.
|
// returns ErrNoTimeString if no match is found.
|
||||||
func ExtractTime(s string) (time.Time, error) {
|
func ExtractTime(s string) (time.Time, error) {
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
return time.Time{}, clues.Stack(errParsingStringToTime, errors.New("empty string"))
|
return time.Time{}, clues.Stack(errParsingStringToTime, clues.New("empty string"))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, re := range regexes {
|
for _, re := range regexes {
|
||||||
@ -163,5 +162,5 @@ func ExtractTime(s string) (time.Time, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return time.Time{}, clues.Stack(ErrNoTimeString, errors.New(s))
|
return time.Time{}, clues.Stack(ErrNoTimeString, clues.New(s))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,11 +4,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -4,9 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/discovery"
|
"github.com/alcionai/corso/src/internal/connector/discovery"
|
||||||
"github.com/alcionai/corso/src/internal/connector/discovery/api"
|
"github.com/alcionai/corso/src/internal/connector/discovery/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange"
|
"github.com/alcionai/corso/src/internal/connector/exchange"
|
||||||
@ -212,7 +211,7 @@ func (gc *GraphConnector) RestoreDataCollections(
|
|||||||
|
|
||||||
creds, err := acct.M365Config()
|
creds, err := acct.M365Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "malformed azure credentials")
|
return nil, clues.Wrap(err, "malformed azure credentials")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch selector.Service {
|
switch selector.Service {
|
||||||
|
|||||||
@ -5,11 +5,11 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange"
|
"github.com/alcionai/corso/src/internal/connector/exchange"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/sharepoint"
|
"github.com/alcionai/corso/src/internal/connector/sharepoint"
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/alcionai/clues"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
@ -49,7 +49,7 @@ func newService(creds account.M365Config) (*graph.Service, error) {
|
|||||||
creds.AzureClientID,
|
creds.AzureClientID,
|
||||||
creds.AzureClientSecret)
|
creds.AzureClientSecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "generating graph api service client")
|
return nil, clues.Wrap(err, "generating graph api service client")
|
||||||
}
|
}
|
||||||
|
|
||||||
return graph.NewService(adapter), nil
|
return graph.NewService(adapter), nil
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/alcionai/clues"
|
||||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph/betasdk"
|
"github.com/alcionai/corso/src/internal/connector/graph/betasdk"
|
||||||
)
|
)
|
||||||
@ -32,12 +32,12 @@ func (s BetaService) Serialize(object absser.Parsable) ([]byte, error) {
|
|||||||
GetSerializationWriterFactory().
|
GetSerializationWriterFactory().
|
||||||
GetSerializationWriter("application/json")
|
GetSerializationWriter("application/json")
|
||||||
if err != nil || writer == nil {
|
if err != nil || writer == nil {
|
||||||
return nil, errors.Wrap(err, "creating json serialization writer")
|
return nil, clues.Wrap(err, "creating json serialization writer")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = writer.WriteObjectValue("", object)
|
err = writer.WriteObjectValue("", object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "writeObjecValue serialization")
|
return nil, clues.Wrap(err, "writeObjecValue serialization")
|
||||||
}
|
}
|
||||||
|
|
||||||
return writer.GetSerializedContent()
|
return writer.GetSerializedContent()
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package api
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph/betasdk/models"
|
"github.com/alcionai/corso/src/internal/connector/graph/betasdk/models"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -2,13 +2,13 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
absser "github.com/microsoft/kiota-abstractions-go"
|
absser "github.com/microsoft/kiota-abstractions-go"
|
||||||
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/users"
|
"github.com/microsoftgraph/msgraph-sdk-go/users"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
@ -182,7 +182,7 @@ func (c Users) GetInfo(ctx context.Context, userID string) (*UserInfo, error) {
|
|||||||
func validateUser(item any) (models.Userable, error) {
|
func validateUser(item any) (models.Userable, error) {
|
||||||
m, ok := item.(models.Userable)
|
m, ok := item.(models.Userable)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, clues.Stack(clues.New("unexpected model"), errors.Errorf("%T", item))
|
return nil, clues.New(fmt.Sprintf("unexpected model: %T", item))
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.GetId() == nil {
|
if m.GetId() == nil {
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package api
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/discovery/api"
|
"github.com/alcionai/corso/src/internal/connector/discovery/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -61,12 +60,12 @@ func User(ctx context.Context, gwi getWithInfoer, userID string) (models.Userabl
|
|||||||
return nil, nil, fmt.Errorf("resource owner [%s] not found within tenant", userID)
|
return nil, nil, fmt.Errorf("resource owner [%s] not found within tenant", userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil, errors.Wrap(err, "getting user")
|
return nil, nil, clues.Wrap(err, "getting user")
|
||||||
}
|
}
|
||||||
|
|
||||||
ui, err := gwi.GetInfo(ctx, userID)
|
ui, err := gwi.GetInfo(ctx, userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrap(err, "getting user info")
|
return nil, nil, clues.Wrap(err, "getting user info")
|
||||||
}
|
}
|
||||||
|
|
||||||
return u, ui, nil
|
return u, ui, nil
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package discovery_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/discovery"
|
"github.com/alcionai/corso/src/internal/connector/discovery"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
"github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -95,7 +94,7 @@ func newService(creds account.M365Config) (*graph.Service, error) {
|
|||||||
creds.AzureClientID,
|
creds.AzureClientID,
|
||||||
creds.AzureClientSecret)
|
creds.AzureClientSecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "generating no-timeout graph adapter")
|
return nil, clues.Wrap(err, "generating no-timeout graph adapter")
|
||||||
}
|
}
|
||||||
|
|
||||||
return graph.NewService(a), nil
|
return graph.NewService(a), nil
|
||||||
@ -108,7 +107,7 @@ func newLargeItemService(creds account.M365Config) (*graph.Service, error) {
|
|||||||
creds.AzureClientSecret,
|
creds.AzureClientSecret,
|
||||||
graph.NoTimeout())
|
graph.NoTimeout())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "generating no-timeout graph adapter")
|
return nil, clues.Wrap(err, "generating no-timeout graph adapter")
|
||||||
}
|
}
|
||||||
|
|
||||||
return graph.NewService(a), nil
|
return graph.NewService(a), nil
|
||||||
@ -123,7 +122,7 @@ func newLargeItemService(creds account.M365Config) (*graph.Service, error) {
|
|||||||
func checkIDAndName(c graph.Container) error {
|
func checkIDAndName(c graph.Container) error {
|
||||||
id := ptr.Val(c.GetId())
|
id := ptr.Val(c.GetId())
|
||||||
if len(id) == 0 {
|
if len(id) == 0 {
|
||||||
return errors.New("container missing ID")
|
return clues.New("container missing ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
dn := ptr.Val(c.GetDisplayName())
|
dn := ptr.Val(c.GetDisplayName())
|
||||||
|
|||||||
@ -3,12 +3,12 @@ package api
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
|
|||||||
@ -4,12 +4,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/connector/uploadsession"
|
"github.com/alcionai/corso/src/internal/connector/uploadsession"
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
package exchange
|
package exchange
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
)
|
)
|
||||||
@ -13,7 +12,7 @@ import (
|
|||||||
func checkIDAndName(c graph.Container) error {
|
func checkIDAndName(c graph.Container) error {
|
||||||
id, ok := ptr.ValOK(c.GetId())
|
id, ok := ptr.ValOK(c.GetId())
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("container missing ID")
|
return clues.New("container missing ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := ptr.ValOK(c.GetDisplayName()); !ok {
|
if _, ok := ptr.ValOK(c.GetDisplayName()); !ok {
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
@ -52,16 +51,16 @@ func (cfc *contactFolderCache) Populate(
|
|||||||
baseContainerPather ...string,
|
baseContainerPather ...string,
|
||||||
) error {
|
) error {
|
||||||
if err := cfc.init(ctx, baseID, baseContainerPather); err != nil {
|
if err := cfc.init(ctx, baseID, baseContainerPather); err != nil {
|
||||||
return errors.Wrap(err, "initializing")
|
return clues.Wrap(err, "initializing")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := cfc.enumer.EnumerateContainers(ctx, cfc.userID, baseID, cfc.addFolder, errs)
|
err := cfc.enumer.EnumerateContainers(ctx, cfc.userID, baseID, cfc.addFolder, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "enumerating containers")
|
return clues.Wrap(err, "enumerating containers")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cfc.populatePaths(ctx, false, errs); err != nil {
|
if err := cfc.populatePaths(ctx, false, errs); err != nil {
|
||||||
return errors.Wrap(err, "populating paths")
|
return clues.Wrap(err, "populating paths")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -87,7 +86,7 @@ func (cr *containerResolver) idToPath(
|
|||||||
depth+1,
|
depth+1,
|
||||||
useIDInPath)
|
useIDInPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrap(err, "retrieving parent folder")
|
return nil, nil, clues.Wrap(err, "retrieving parent folder")
|
||||||
}
|
}
|
||||||
|
|
||||||
toAppend := ptr.Val(c.GetDisplayName())
|
toAppend := ptr.Val(c.GetDisplayName())
|
||||||
@ -135,11 +134,11 @@ func (cr *containerResolver) addFolder(cf graph.CacheFolder) error {
|
|||||||
// Only require a non-nil non-empty parent if the path isn't already populated.
|
// Only require a non-nil non-empty parent if the path isn't already populated.
|
||||||
if cf.Path() != nil {
|
if cf.Path() != nil {
|
||||||
if err := checkIDAndName(cf.Container); err != nil {
|
if err := checkIDAndName(cf.Container); err != nil {
|
||||||
return errors.Wrap(err, "adding item to cache")
|
return clues.Wrap(err, "adding item to cache")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := checkRequiredValues(cf.Container); err != nil {
|
if err := checkRequiredValues(cf.Container); err != nil {
|
||||||
return errors.Wrap(err, "adding item to cache")
|
return clues.Wrap(err, "adding item to cache")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +179,7 @@ func (cr *containerResolver) AddToCache(
|
|||||||
// when they're made.
|
// when they're made.
|
||||||
_, _, err := cr.IDToPath(ctx, ptr.Val(f.GetId()), useIDInPath)
|
_, _, err := cr.IDToPath(ctx, ptr.Val(f.GetId()), useIDInPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "adding cache entry")
|
return clues.Wrap(err, "adding cache entry")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -5,12 +5,12 @@ import (
|
|||||||
stdpath "path"
|
stdpath "path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -286,7 +285,7 @@ func createCollections(
|
|||||||
|
|
||||||
resolver, err := PopulateExchangeContainerResolver(ctx, qp, errs)
|
resolver, err := PopulateExchangeContainerResolver(ctx, qp, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "populating container cache")
|
return nil, clues.Wrap(err, "populating container cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = filterContainersAndFillCollections(
|
err = filterContainersAndFillCollections(
|
||||||
@ -301,7 +300,7 @@ func createCollections(
|
|||||||
ctrlOpts,
|
ctrlOpts,
|
||||||
errs)
|
errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "filling collections")
|
return nil, clues.Wrap(err, "filling collections")
|
||||||
}
|
}
|
||||||
|
|
||||||
foldersComplete <- struct{}{}
|
foldersComplete <- struct{}{}
|
||||||
|
|||||||
@ -5,11 +5,11 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -44,7 +43,7 @@ func (ecc *eventCalendarCache) populateEventRoot(ctx context.Context) error {
|
|||||||
|
|
||||||
f, err := ecc.getter.GetContainerByID(ctx, ecc.userID, container)
|
f, err := ecc.getter.GetContainerByID(ctx, ecc.userID, container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "fetching calendar")
|
return clues.Wrap(err, "fetching calendar")
|
||||||
}
|
}
|
||||||
|
|
||||||
temp := graph.NewCacheFolder(
|
temp := graph.NewCacheFolder(
|
||||||
@ -68,7 +67,7 @@ func (ecc *eventCalendarCache) Populate(
|
|||||||
baseContainerPath ...string,
|
baseContainerPath ...string,
|
||||||
) error {
|
) error {
|
||||||
if err := ecc.init(ctx); err != nil {
|
if err := ecc.init(ctx); err != nil {
|
||||||
return errors.Wrap(err, "initializing")
|
return clues.Wrap(err, "initializing")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := ecc.enumer.EnumerateContainers(
|
err := ecc.enumer.EnumerateContainers(
|
||||||
@ -78,11 +77,11 @@ func (ecc *eventCalendarCache) Populate(
|
|||||||
ecc.addFolder,
|
ecc.addFolder,
|
||||||
errs)
|
errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "enumerating containers")
|
return clues.Wrap(err, "enumerating containers")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ecc.populatePaths(ctx, true, errs); err != nil {
|
if err := ecc.populatePaths(ctx, true, errs); err != nil {
|
||||||
return errors.Wrap(err, "establishing calendar paths")
|
return clues.Wrap(err, "establishing calendar paths")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -116,7 +115,7 @@ func (ecc *eventCalendarCache) AddToCache(ctx context.Context, f graph.Container
|
|||||||
_, _, err := ecc.IDToPath(ctx, ptr.Val(f.GetId()), true)
|
_, _, err := ecc.IDToPath(ctx, ptr.Val(f.GetId()), true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
delete(ecc.newAdditions, ptr.Val(f.GetDisplayName()))
|
delete(ecc.newAdditions, ptr.Val(f.GetDisplayName()))
|
||||||
return errors.Wrap(err, "setting path to container id")
|
return clues.Wrap(err, "setting path to container id")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -5,12 +5,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
"github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
@ -72,16 +71,16 @@ func (mc *mailFolderCache) Populate(
|
|||||||
baseContainerPath ...string,
|
baseContainerPath ...string,
|
||||||
) error {
|
) error {
|
||||||
if err := mc.init(ctx); err != nil {
|
if err := mc.init(ctx); err != nil {
|
||||||
return errors.Wrap(err, "initializing")
|
return clues.Wrap(err, "initializing")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := mc.enumer.EnumerateContainers(ctx, mc.userID, "", mc.addFolder, errs)
|
err := mc.enumer.EnumerateContainers(ctx, mc.userID, "", mc.addFolder, errs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "enumerating containers")
|
return clues.Wrap(err, "enumerating containers")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mc.populatePaths(ctx, false, errs); err != nil {
|
if err := mc.populatePaths(ctx, false, errs); err != nil {
|
||||||
return errors.Wrap(err, "populating paths")
|
return clues.Wrap(err, "populating paths")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -4,11 +4,11 @@ import (
|
|||||||
stdpath "path"
|
stdpath "path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
|
|||||||
@ -5,11 +5,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
||||||
@ -15,7 +14,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrFolderNotFound = errors.New("folder not found")
|
var ErrFolderNotFound = clues.New("folder not found")
|
||||||
|
|
||||||
func createService(credentials account.M365Config) (*graph.Service, error) {
|
func createService(credentials account.M365Config) (*graph.Service, error) {
|
||||||
adapter, err := graph.CreateAdapter(
|
adapter, err := graph.CreateAdapter(
|
||||||
@ -23,7 +22,7 @@ func createService(credentials account.M365Config) (*graph.Service, error) {
|
|||||||
credentials.AzureClientID,
|
credentials.AzureClientID,
|
||||||
credentials.AzureClientSecret)
|
credentials.AzureClientSecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "creating microsoft graph service for exchange")
|
return nil, clues.Wrap(err, "creating microsoft graph service for exchange")
|
||||||
}
|
}
|
||||||
|
|
||||||
return graph.NewService(adapter), nil
|
return graph.NewService(adapter), nil
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
||||||
@ -235,7 +234,7 @@ func makeTombstones(dps DeltaPaths) map[string]string {
|
|||||||
func pathFromPrevString(ps string) (path.Path, error) {
|
func pathFromPrevString(ps string) (path.Path, error) {
|
||||||
p, err := path.FromDataLayerPath(ps, false)
|
p, err := path.FromDataLayerPath(ps, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "parsing previous path string")
|
return nil, clues.Wrap(err, "parsing previous path string")
|
||||||
}
|
}
|
||||||
|
|
||||||
return p, nil
|
return p, nil
|
||||||
|
|||||||
@ -4,12 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
"github.com/alcionai/corso/src/internal/connector/exchange/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -50,7 +49,7 @@ func (mg mockGetter) GetAddedAndRemovedItemIDs(
|
|||||||
) {
|
) {
|
||||||
results, ok := mg[cID]
|
results, ok := mg[cID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, api.DeltaUpdate{}, errors.New("mock not found for " + cID)
|
return nil, nil, api.DeltaUpdate{}, clues.New("mock not found for " + cID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return results.added, results.removed, results.newDelta, results.err
|
return results.added, results.removed, results.newDelta, results.err
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
@ -283,7 +282,7 @@ func SendMailToBackStore(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
el.AddRecoverable(errors.Wrap(err, "uploading mail attachment"))
|
el.AddRecoverable(clues.Wrap(err, "uploading mail attachment"))
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -622,7 +621,7 @@ func establishMailRestoreLocation(
|
|||||||
// call even if we make a new cache.
|
// call even if we make a new cache.
|
||||||
if isNewCache {
|
if isNewCache {
|
||||||
if err := mfc.Populate(ctx, errs, rootFolderAlias); err != nil {
|
if err := mfc.Populate(ctx, errs, rootFolderAlias); err != nil {
|
||||||
return "", errors.Wrap(err, "populating folder cache")
|
return "", clues.Wrap(err, "populating folder cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
isNewCache = false
|
isNewCache = false
|
||||||
@ -630,7 +629,7 @@ func establishMailRestoreLocation(
|
|||||||
|
|
||||||
// NOOP if the folder is already in the cache.
|
// NOOP if the folder is already in the cache.
|
||||||
if err = mfc.AddToCache(ctx, temp, false); err != nil {
|
if err = mfc.AddToCache(ctx, temp, false); err != nil {
|
||||||
return "", errors.Wrap(err, "adding folder to cache")
|
return "", clues.Wrap(err, "adding folder to cache")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,11 +667,11 @@ func establishContactsRestoreLocation(
|
|||||||
|
|
||||||
if isNewCache {
|
if isNewCache {
|
||||||
if err := cfc.Populate(ctx, errs, folderID, folders[0]); err != nil {
|
if err := cfc.Populate(ctx, errs, folderID, folders[0]); err != nil {
|
||||||
return "", errors.Wrap(err, "populating contact cache")
|
return "", clues.Wrap(err, "populating contact cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = cfc.AddToCache(ctx, temp, false); err != nil {
|
if err = cfc.AddToCache(ctx, temp, false); err != nil {
|
||||||
return "", errors.Wrap(err, "adding contact folder to cache")
|
return "", clues.Wrap(err, "adding contact folder to cache")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,12 +704,12 @@ func establishEventsRestoreLocation(
|
|||||||
|
|
||||||
if isNewCache {
|
if isNewCache {
|
||||||
if err = ecc.Populate(ctx, errs, folderID, folders[0]); err != nil {
|
if err = ecc.Populate(ctx, errs, folderID, folders[0]); err != nil {
|
||||||
return "", errors.Wrap(err, "populating event cache")
|
return "", clues.Wrap(err, "populating event cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
displayable := api.CalendarDisplayable{Calendarable: temp}
|
displayable := api.CalendarDisplayable{Calendarable: temp}
|
||||||
if err = ecc.AddToCache(ctx, displayable, true); err != nil {
|
if err = ecc.AddToCache(ctx, displayable, true); err != nil {
|
||||||
return "", errors.Wrap(err, "adding new calendar to cache")
|
return "", clues.Wrap(err, "adding new calendar to cache")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
@ -175,7 +174,7 @@ func CreateCalendarDisplayable(entry any, parentID string) *CalendarDisplayable
|
|||||||
func CheckRequiredValues(c Container) error {
|
func CheckRequiredValues(c Container) error {
|
||||||
id, ok := ptr.ValOK(c.GetId())
|
id, ok := ptr.ValOK(c.GetId())
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("container missing ID")
|
return clues.New("container missing ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := ptr.ValOK(c.GetDisplayName()); !ok {
|
if _, ok := ptr.ValOK(c.GetDisplayName()); !ok {
|
||||||
|
|||||||
@ -9,12 +9,12 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"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"
|
||||||
|
|||||||
@ -5,12 +5,12 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -4,11 +4,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph/metadata"
|
"github.com/alcionai/corso/src/internal/connector/graph/metadata"
|
||||||
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/alcionai/clues"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
@ -42,18 +42,18 @@ func NewMetadataEntry(fileName string, mData any) MetadataCollectionEntry {
|
|||||||
|
|
||||||
func (mce MetadataCollectionEntry) toMetadataItem() (MetadataItem, error) {
|
func (mce MetadataCollectionEntry) toMetadataItem() (MetadataItem, error) {
|
||||||
if len(mce.fileName) == 0 {
|
if len(mce.fileName) == 0 {
|
||||||
return MetadataItem{}, errors.New("missing metadata filename")
|
return MetadataItem{}, clues.New("missing metadata filename")
|
||||||
}
|
}
|
||||||
|
|
||||||
if mce.data == nil {
|
if mce.data == nil {
|
||||||
return MetadataItem{}, errors.New("missing metadata")
|
return MetadataItem{}, clues.New("missing metadata")
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
encoder := json.NewEncoder(buf)
|
encoder := json.NewEncoder(buf)
|
||||||
|
|
||||||
if err := encoder.Encode(mce.data); err != nil {
|
if err := encoder.Encode(mce.data); err != nil {
|
||||||
return MetadataItem{}, errors.Wrap(err, "serializing metadata")
|
return MetadataItem{}, clues.Wrap(err, "serializing metadata")
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewMetadataItem(mce.fileName, buf.Bytes()), nil
|
return NewMetadataItem(mce.fileName, buf.Bytes()), nil
|
||||||
@ -81,7 +81,7 @@ func MakeMetadataCollection(
|
|||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "making metadata path")
|
return nil, clues.Wrap(err, "making metadata path")
|
||||||
}
|
}
|
||||||
|
|
||||||
items := make([]MetadataItem, 0, len(metadata))
|
items := make([]MetadataItem, 0, len(metadata))
|
||||||
|
|||||||
@ -5,12 +5,12 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
|
|||||||
@ -10,16 +10,15 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
|
||||||
|
"github.com/alcionai/clues"
|
||||||
backoff "github.com/cenkalti/backoff/v4"
|
backoff "github.com/cenkalti/backoff/v4"
|
||||||
"github.com/microsoft/kiota-abstractions-go/serialization"
|
"github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
ka "github.com/microsoft/kiota-authentication-azure-go"
|
ka "github.com/microsoft/kiota-authentication-azure-go"
|
||||||
khttp "github.com/microsoft/kiota-http-go"
|
khttp "github.com/microsoft/kiota-http-go"
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||||
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
msgraphgocore "github.com/microsoftgraph/msgraph-sdk-go-core"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
"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"
|
||||||
@ -81,12 +80,12 @@ func (s Service) Client() *msgraphsdk.GraphServiceClient {
|
|||||||
func (s Service) Serialize(object serialization.Parsable) ([]byte, error) {
|
func (s Service) Serialize(object serialization.Parsable) ([]byte, error) {
|
||||||
writer, err := s.adapter.GetSerializationWriterFactory().GetSerializationWriter("application/json")
|
writer, err := s.adapter.GetSerializationWriterFactory().GetSerializationWriter("application/json")
|
||||||
if err != nil || writer == nil {
|
if err != nil || writer == nil {
|
||||||
return nil, errors.Wrap(err, "creating json serialization writer")
|
return nil, clues.Wrap(err, "creating json serialization writer")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = writer.WriteObjectValue("", object)
|
err = writer.WriteObjectValue("", object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "serializing object")
|
return nil, clues.Wrap(err, "serializing object")
|
||||||
}
|
}
|
||||||
|
|
||||||
return writer.GetSerializedContent()
|
return writer.GetSerializedContent()
|
||||||
@ -175,7 +174,7 @@ func CreateAdapter(
|
|||||||
// Client Provider: Uses Secret for access to tenant-level data
|
// Client Provider: Uses Secret for access to tenant-level data
|
||||||
cred, err := azidentity.NewClientSecretCredential(tenant, client, secret, nil)
|
cred, err := azidentity.NewClientSecretCredential(tenant, client, secret, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "creating m365 client identity")
|
return nil, clues.Wrap(err, "creating m365 client identity")
|
||||||
}
|
}
|
||||||
|
|
||||||
auth, err := ka.NewAzureIdentityAuthenticationProviderWithScopes(
|
auth, err := ka.NewAzureIdentityAuthenticationProviderWithScopes(
|
||||||
@ -183,7 +182,7 @@ func CreateAdapter(
|
|||||||
[]string{"https://graph.microsoft.com/.default"},
|
[]string{"https://graph.microsoft.com/.default"},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "creating azure authentication")
|
return nil, clues.Wrap(err, "creating azure authentication")
|
||||||
}
|
}
|
||||||
|
|
||||||
httpClient := HTTPClient(opts...)
|
httpClient := HTTPClient(opts...)
|
||||||
|
|||||||
@ -5,12 +5,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -93,7 +93,7 @@ func NewGraphConnector(
|
|||||||
|
|
||||||
if r == AllResources || r == Sites {
|
if r == AllResources || r == Sites {
|
||||||
if err = gc.setTenantSites(ctx, errs); err != nil {
|
if err = gc.setTenantSites(ctx, errs); err != nil {
|
||||||
return nil, errors.Wrap(err, "retrieveing tenant site list")
|
return nil, clues.Wrap(err, "retrieveing tenant site list")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ func (gc *GraphConnector) setTenantSites(ctx context.Context, errs *fault.Bus) e
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var errKnownSkippableCase = errors.New("case is known and skippable")
|
var errKnownSkippableCase = clues.New("case is known and skippable")
|
||||||
|
|
||||||
const personalSitePath = "sharepoint.com/personal/"
|
const personalSitePath = "sharepoint.com/personal/"
|
||||||
|
|
||||||
|
|||||||
@ -4,11 +4,11 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -10,13 +10,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
||||||
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
||||||
|
|||||||
@ -8,12 +8,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
||||||
|
|||||||
@ -5,12 +5,12 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
|
|||||||
@ -5,13 +5,13 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
kioser "github.com/microsoft/kiota-serialization-json-go"
|
kioser "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
|
|||||||
@ -6,11 +6,11 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
kw "github.com/microsoft/kiota-serialization-json-go"
|
kw "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
"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"
|
||||||
|
|||||||
@ -5,13 +5,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
absser "github.com/microsoft/kiota-abstractions-go/serialization"
|
||||||
js "github.com/microsoft/kiota-serialization-json-go"
|
js "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -748,12 +747,12 @@ func serialize(t *testing.T, item absser.Parsable) []byte {
|
|||||||
func hydrateMessage(byteArray []byte) (models.Messageable, error) {
|
func hydrateMessage(byteArray []byte) (models.Messageable, error) {
|
||||||
parseNode, err := js.NewJsonParseNodeFactory().GetRootParseNode("application/json", byteArray)
|
parseNode, err := js.NewJsonParseNodeFactory().GetRootParseNode("application/json", byteArray)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "deserializing bytes into base m365 object")
|
return nil, clues.Wrap(err, "deserializing bytes into base m365 object")
|
||||||
}
|
}
|
||||||
|
|
||||||
anObject, err := parseNode.GetObjectValue(models.CreateMessageFromDiscriminatorValue)
|
anObject, err := parseNode.GetObjectValue(models.CreateMessageFromDiscriminatorValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "parsing m365 object factory")
|
return nil, clues.Wrap(err, "parsing m365 object factory")
|
||||||
}
|
}
|
||||||
|
|
||||||
message := anObject.(models.Messageable)
|
message := anObject.(models.Messageable)
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package api_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/onedrive/api"
|
"github.com/alcionai/corso/src/internal/connector/onedrive/api"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/spatialcurrent/go-lazy/pkg/lazy"
|
"github.com/spatialcurrent/go-lazy/pkg/lazy"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
@ -329,7 +328,7 @@ func (oc *Collection) getDriveItemContent(
|
|||||||
// refresh that download url.
|
// refresh that download url.
|
||||||
di, diErr := oc.itemGetter(ctx, oc.service, oc.driveID, itemID)
|
di, diErr := oc.itemGetter(ctx, oc.service, oc.driveID, itemID)
|
||||||
if diErr != nil {
|
if diErr != nil {
|
||||||
err = errors.Wrap(diErr, "retrieving expired item")
|
err = clues.Wrap(diErr, "retrieving expired item")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,13 +11,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
|
|||||||
@ -231,7 +231,7 @@ func deserializeMap[T any](reader io.ReadCloser, alreadyFound map[string]T) erro
|
|||||||
tmp := map[string]T{}
|
tmp := map[string]T{}
|
||||||
|
|
||||||
if err := json.NewDecoder(reader).Decode(&tmp); err != nil {
|
if err := json.NewDecoder(reader).Decode(&tmp); err != nil {
|
||||||
return errors.Wrap(err, "deserializing file contents")
|
return clues.Wrap(err, "deserializing file contents")
|
||||||
}
|
}
|
||||||
|
|
||||||
var duplicate bool
|
var duplicate bool
|
||||||
@ -853,7 +853,7 @@ func GetCanonicalPath(p, tenant, resourceOwner string, source driveSource) (path
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "converting to canonical path")
|
return nil, clues.Wrap(err, "converting to canonical path")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
|
||||||
@ -14,7 +15,6 @@ import (
|
|||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
gapi "github.com/alcionai/corso/src/internal/connector/graph/api"
|
gapi "github.com/alcionai/corso/src/internal/connector/graph/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/onedrive/api"
|
"github.com/alcionai/corso/src/internal/connector/onedrive/api"
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/data"
|
"github.com/alcionai/corso/src/internal/data"
|
||||||
@ -13,7 +15,6 @@ import (
|
|||||||
"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/selectors"
|
||||||
"golang.org/x/exp/maps"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type odFolderMatcher struct {
|
type odFolderMatcher struct {
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
msdrive "github.com/microsoftgraph/msgraph-sdk-go/drive"
|
msdrive "github.com/microsoftgraph/msgraph-sdk-go/drive"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
@ -55,7 +54,7 @@ func PagerForSource(
|
|||||||
case SharePointSource:
|
case SharePointSource:
|
||||||
return api.NewSiteDrivePager(servicer, resourceOwner, fields), nil
|
return api.NewSiteDrivePager(servicer, resourceOwner, fields), nil
|
||||||
default:
|
default:
|
||||||
return nil, errors.Errorf("unrecognized drive data source")
|
return nil, clues.New("unrecognized drive data source")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +285,7 @@ func GetAllFolders(
|
|||||||
) ([]*Displayable, error) {
|
) ([]*Displayable, error) {
|
||||||
drives, err := api.GetAllDrives(ctx, pager, true, maxDrivesRetries)
|
drives, err := api.GetAllDrives(ctx, pager, true, maxDrivesRetries)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "getting OneDrive folders")
|
return nil, clues.Wrap(err, "getting OneDrive folders")
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
msdrives "github.com/microsoftgraph/msgraph-sdk-go/drives"
|
msdrives "github.com/microsoftgraph/msgraph-sdk-go/drives"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -52,7 +51,7 @@ func sharePointItemReader(
|
|||||||
) (details.ItemInfo, io.ReadCloser, error) {
|
) (details.ItemInfo, io.ReadCloser, error) {
|
||||||
resp, err := downloadItem(ctx, hc, item)
|
resp, err := downloadItem(ctx, hc, item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return details.ItemInfo{}, nil, errors.Wrap(err, "downloading item")
|
return details.ItemInfo{}, nil, clues.Wrap(err, "downloading item")
|
||||||
}
|
}
|
||||||
|
|
||||||
dii := details.ItemInfo{
|
dii := details.ItemInfo{
|
||||||
@ -135,7 +134,7 @@ func oneDriveItemReader(
|
|||||||
if isFile {
|
if isFile {
|
||||||
resp, err := downloadItem(ctx, hc, item)
|
resp, err := downloadItem(ctx, hc, item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return details.ItemInfo{}, nil, errors.Wrap(err, "downloading item")
|
return details.ItemInfo{}, nil, clues.Wrap(err, "downloading item")
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = resp.Body
|
rc = resp.Body
|
||||||
|
|||||||
@ -6,12 +6,12 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
msdrive "github.com/microsoftgraph/msgraph-sdk-go/drive"
|
msdrive "github.com/microsoftgraph/msgraph-sdk-go/drive"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
@ -24,11 +23,11 @@ func getParentMetadata(
|
|||||||
if !ok {
|
if !ok {
|
||||||
onedrivePath, err := path.ToOneDrivePath(parentPath)
|
onedrivePath, err := path.ToOneDrivePath(parentPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Metadata{}, errors.Wrap(err, "invalid restore path")
|
return Metadata{}, clues.Wrap(err, "invalid restore path")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(onedrivePath.Folders) != 0 {
|
if len(onedrivePath.Folders) != 0 {
|
||||||
return Metadata{}, errors.Wrap(err, "computing item permissions")
|
return Metadata{}, clues.Wrap(err, "computing item permissions")
|
||||||
}
|
}
|
||||||
|
|
||||||
parentMeta = Metadata{}
|
parentMeta = Metadata{}
|
||||||
|
|||||||
@ -4,12 +4,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
|
||||||
"github.com/alcionai/corso/src/internal/version"
|
|
||||||
"github.com/alcionai/corso/src/pkg/path"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
"github.com/alcionai/corso/src/internal/version"
|
||||||
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RestoreUnitSuite struct {
|
type RestoreUnitSuite struct {
|
||||||
|
|||||||
@ -3,10 +3,10 @@ package onedrive
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/support"
|
"github.com/alcionai/corso/src/internal/connector/support"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
@ -3,9 +3,9 @@ package api_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
discover "github.com/alcionai/corso/src/internal/connector/discovery/api"
|
discover "github.com/alcionai/corso/src/internal/connector/discovery/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/pkg/account"
|
"github.com/alcionai/corso/src/pkg/account"
|
||||||
|
|||||||
@ -6,9 +6,10 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
|
msmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
|
mssites "github.com/microsoftgraph/msgraph-sdk-go/sites"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
discover "github.com/alcionai/corso/src/internal/connector/discovery/api"
|
discover "github.com/alcionai/corso/src/internal/connector/discovery/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
@ -19,8 +20,6 @@ import (
|
|||||||
D "github.com/alcionai/corso/src/internal/diagnostics"
|
D "github.com/alcionai/corso/src/internal/diagnostics"
|
||||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
msmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
|
|
||||||
mssites "github.com/microsoftgraph/msgraph-sdk-go/sites"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetSitePages retrieves a collection of Pages related to the give Site.
|
// GetSitePages retrieves a collection of Pages related to the give Site.
|
||||||
@ -206,7 +205,7 @@ func RestoreSitePage(
|
|||||||
// Hydrate Page
|
// Hydrate Page
|
||||||
page, err := support.CreatePageFromBytes(byteArray)
|
page, err := support.CreatePageFromBytes(byteArray)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dii, errors.Wrapf(err, "creating Page object %s", pageID)
|
return dii, clues.Wrap(err, "creating Page object").WithClues(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
name, ok := ptr.ValOK(page.GetName())
|
name, ok := ptr.ValOK(page.GetName())
|
||||||
|
|||||||
@ -5,11 +5,11 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
discover "github.com/alcionai/corso/src/internal/connector/discovery/api"
|
discover "github.com/alcionai/corso/src/internal/connector/discovery/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
||||||
|
|||||||
@ -5,13 +5,13 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
kioser "github.com/microsoft/kiota-serialization-json-go"
|
kioser "github.com/microsoft/kiota-serialization-json-go"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/sites"
|
"github.com/microsoftgraph/msgraph-sdk-go/sites"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/common/ptr"
|
"github.com/alcionai/corso/src/internal/common/ptr"
|
||||||
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
"github.com/alcionai/corso/src/internal/connector/mockconnector"
|
||||||
|
|||||||
@ -4,9 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/discovery/api"
|
"github.com/alcionai/corso/src/internal/connector/discovery/api"
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
||||||
@ -40,7 +39,7 @@ func DataCollections(
|
|||||||
) ([]data.BackupCollection, map[string]map[string]struct{}, error) {
|
) ([]data.BackupCollection, map[string]map[string]struct{}, error) {
|
||||||
b, err := selector.ToSharePointBackup()
|
b, err := selector.ToSharePointBackup()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Wrap(err, "sharePointDataCollection: parsing selector")
|
return nil, nil, clues.Wrap(err, "sharePointDataCollection: parsing selector")
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@ -3,12 +3,12 @@ package sharepoint
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
"github.com/alcionai/clues"
|
|
||||||
"github.com/alcionai/corso/src/internal/connector/graph"
|
"github.com/alcionai/corso/src/internal/connector/graph"
|
||||||
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
"github.com/alcionai/corso/src/internal/connector/onedrive"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user