Set line length to 120 characters (#506)
* Enable line width linter Set to 120 which should be long enough to not be annoying but keep things from getting "too long." Adding to get rid of the subjectiveness of what is "too long." Tabs count as a single character.
This commit is contained in:
parent
53a0207870
commit
e76860fd80
@ -6,6 +6,7 @@ linters:
|
||||
- gci
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- lll
|
||||
- misspell
|
||||
- revive
|
||||
|
||||
@ -16,6 +17,8 @@ linters-settings:
|
||||
- default
|
||||
- prefix(github.com/alcionai/corso)
|
||||
skip-generated: true
|
||||
lll:
|
||||
line-length: 120
|
||||
revive:
|
||||
max-open-files: 2048
|
||||
# Don't know why, but false means ignore generated files.
|
||||
|
||||
@ -54,7 +54,12 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
|
||||
|
||||
case createCommand:
|
||||
c, fs = utils.AddCommand(parent, exchangeCreateCmd())
|
||||
fs.StringSliceVar(&user, "user", nil, "Backup Exchange data by user ID; accepts "+utils.Wildcard+" to select all users")
|
||||
fs.StringSliceVar(
|
||||
&user,
|
||||
"user",
|
||||
nil,
|
||||
"Backup Exchange data by user ID; accepts "+utils.Wildcard+" to select all users",
|
||||
)
|
||||
fs.BoolVar(&exchangeAll, "all", false, "Backup all Exchange data for all users")
|
||||
fs.StringSliceVar(
|
||||
&exchangeData,
|
||||
@ -72,20 +77,41 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
|
||||
cobra.CheckErr(c.MarkFlagRequired("backup"))
|
||||
|
||||
// per-data-type flags
|
||||
fs.StringSliceVar(&contact, "contact", nil, "Select backup details by contact ID; accepts "+utils.Wildcard+" to select all contacts")
|
||||
fs.StringSliceVar(
|
||||
&contact,
|
||||
"contact",
|
||||
nil,
|
||||
"Select backup details by contact ID; accepts "+utils.Wildcard+" to select all contacts",
|
||||
)
|
||||
fs.StringSliceVar(
|
||||
&contactFolder,
|
||||
"contact-folder",
|
||||
nil,
|
||||
"Select backup details by contact folder ID; accepts "+utils.Wildcard+" to select all contact folders")
|
||||
fs.StringSliceVar(&email, "email", nil, "Select backup details by emails ID; accepts "+utils.Wildcard+" to select all emails")
|
||||
"Select backup details by contact folder ID; accepts "+utils.Wildcard+" to select all contact folders",
|
||||
)
|
||||
fs.StringSliceVar(
|
||||
&email,
|
||||
"email",
|
||||
nil,
|
||||
"Select backup details by emails ID; accepts "+utils.Wildcard+" to select all emails",
|
||||
)
|
||||
fs.StringSliceVar(
|
||||
&emailFolder,
|
||||
"email-folder",
|
||||
nil,
|
||||
"Select backup details by email folder ID; accepts "+utils.Wildcard+" to select all email folderss")
|
||||
fs.StringSliceVar(&event, "event", nil, "Select backup details by event ID; accepts "+utils.Wildcard+" to select all events")
|
||||
fs.StringSliceVar(&user, "user", nil, "Select backup details by user ID; accepts "+utils.Wildcard+" to select all users")
|
||||
fs.StringSliceVar(
|
||||
&event,
|
||||
"event",
|
||||
nil,
|
||||
"Select backup details by event ID; accepts "+utils.Wildcard+" to select all events",
|
||||
)
|
||||
fs.StringSliceVar(
|
||||
&user,
|
||||
"user",
|
||||
nil,
|
||||
"Select backup details by user ID; accepts "+utils.Wildcard+" to select all users",
|
||||
)
|
||||
|
||||
// TODO: reveal these flags when their production is supported in GC
|
||||
cobra.CheckErr(fs.MarkHidden("contact"))
|
||||
@ -93,10 +119,25 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
|
||||
cobra.CheckErr(fs.MarkHidden("event"))
|
||||
|
||||
// exchange-info flags
|
||||
fs.StringVar(&emailReceivedAfter, "email-received-after", "", "Select backup details where the email was received after this datetime")
|
||||
fs.StringVar(&emailReceivedBefore, "email-received-before", "", "Select backup details where the email was received before this datetime")
|
||||
fs.StringVar(
|
||||
&emailReceivedAfter,
|
||||
"email-received-after",
|
||||
"",
|
||||
"Select backup details where the email was received after this datetime",
|
||||
)
|
||||
fs.StringVar(
|
||||
&emailReceivedBefore,
|
||||
"email-received-before",
|
||||
"",
|
||||
"Select backup details where the email was received before this datetime",
|
||||
)
|
||||
fs.StringVar(&emailSender, "email-sender", "", "Select backup details where the email sender matches this user id")
|
||||
fs.StringVar(&emailSubject, "email-subject", "", "Select backup details where the email subject lines contain this value")
|
||||
fs.StringVar(
|
||||
&emailSubject,
|
||||
"email-subject",
|
||||
"",
|
||||
"Select backup details where the email subject lines contain this value",
|
||||
)
|
||||
}
|
||||
|
||||
return c
|
||||
@ -204,7 +245,8 @@ func validateExchangeBackupCreateFlags(all bool, users, data []string) error {
|
||||
}
|
||||
for _, d := range data {
|
||||
if d != dataContacts && d != dataEmail && d != dataEvents {
|
||||
return errors.New(d + " is an unrecognized data type; must be one of " + dataContacts + ", " + dataEmail + ", or " + dataEvents)
|
||||
return errors.New(
|
||||
d + " is an unrecognized data type; must be one of " + dataContacts + ", " + dataEmail + ", or " + dataEvents)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -459,10 +501,12 @@ func validateExchangeBackupDetailFlags(
|
||||
return errors.New("requires one or more --user ids, the wildcard --user *, or the --all flag")
|
||||
}
|
||||
if lc > 0 && lcf == 0 {
|
||||
return errors.New("one or more --contact-folder ids or the wildcard --contact-folder * must be included to specify a --contact")
|
||||
return errors.New(
|
||||
"one or more --contact-folder ids or the wildcard --contact-folder * must be included to specify a --contact")
|
||||
}
|
||||
if le > 0 && lef == 0 {
|
||||
return errors.New("one or more --email-folder ids or the wildcard --email-folder * must be included to specify a --email")
|
||||
return errors.New(
|
||||
"one or more --email-folder ids or the wildcard --email-folder * must be included to specify a --email")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -33,7 +33,11 @@ func m365Overrides(in map[string]string) map[string]string {
|
||||
|
||||
// configureAccount builds a complete account configuration from a mix of
|
||||
// viper properties and manual overrides.
|
||||
func configureAccount(vpr *viper.Viper, readConfigFromViper bool, overrides map[string]string) (account.Account, error) {
|
||||
func configureAccount(
|
||||
vpr *viper.Viper,
|
||||
readConfigFromViper bool,
|
||||
overrides map[string]string,
|
||||
) (account.Account, error) {
|
||||
var (
|
||||
m365Cfg account.M365Config
|
||||
acct account.Account
|
||||
|
||||
@ -179,7 +179,11 @@ func GetStorageAndAccount(
|
||||
|
||||
// getSorageAndAccountWithViper implements GetSorageAndAccount, but takes in a viper
|
||||
// struct for testing.
|
||||
func getStorageAndAccountWithViper(vpr *viper.Viper, readFromFile bool, overrides map[string]string) (storage.Storage, account.Account, error) {
|
||||
func getStorageAndAccountWithViper(
|
||||
vpr *viper.Viper,
|
||||
readFromFile bool,
|
||||
overrides map[string]string,
|
||||
) (storage.Storage, account.Account, error) {
|
||||
var (
|
||||
store storage.Storage
|
||||
acct account.Account
|
||||
|
||||
@ -37,7 +37,11 @@ func s3Overrides(in map[string]string) map[string]string {
|
||||
|
||||
// configureStorage builds a complete storage configuration from a mix of
|
||||
// viper properties and manual overrides.
|
||||
func configureStorage(vpr *viper.Viper, readConfigFromViper bool, overrides map[string]string) (storage.Storage, error) {
|
||||
func configureStorage(
|
||||
vpr *viper.Viper,
|
||||
readConfigFromViper bool,
|
||||
overrides map[string]string,
|
||||
) (storage.Storage, error) {
|
||||
var (
|
||||
s3Cfg storage.S3Config
|
||||
store storage.Storage
|
||||
|
||||
@ -43,7 +43,12 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
|
||||
cobra.CheckErr(c.MarkFlagRequired("backup"))
|
||||
|
||||
// per-data-type flags
|
||||
fs.StringSliceVar(&contact, "contact", nil, "Restore contacts by ID; accepts "+utils.Wildcard+" to select all contacts")
|
||||
fs.StringSliceVar(
|
||||
&contact,
|
||||
"contact",
|
||||
nil,
|
||||
"Restore contacts by ID; accepts "+utils.Wildcard+" to select all contacts",
|
||||
)
|
||||
fs.StringSliceVar(
|
||||
&contactFolder,
|
||||
"contact-folder",
|
||||
@ -54,7 +59,8 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
|
||||
&emailFolder,
|
||||
"email-folder",
|
||||
nil,
|
||||
"Restore all emails by folder ID; accepts "+utils.Wildcard+" to select all email folders")
|
||||
"Restore all emails by folder ID; accepts "+utils.Wildcard+" to select all email folders",
|
||||
)
|
||||
fs.StringSliceVar(&event, "event", nil, "Restore events by ID; accepts "+utils.Wildcard+" to select all events")
|
||||
fs.StringSliceVar(&user, "user", nil, "Restore all data by user ID; accepts "+utils.Wildcard+" to select all users")
|
||||
|
||||
@ -64,8 +70,18 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
|
||||
cobra.CheckErr(fs.MarkHidden("event"))
|
||||
|
||||
// exchange-info flags
|
||||
fs.StringVar(&emailReceivedAfter, "email-received-after", "", "Restore mail where the email was received after this datetime")
|
||||
fs.StringVar(&emailReceivedBefore, "email-received-before", "", "Restore mail where the email was received before this datetime")
|
||||
fs.StringVar(
|
||||
&emailReceivedAfter,
|
||||
"email-received-after",
|
||||
"",
|
||||
"Restore mail where the email was received after this datetime",
|
||||
)
|
||||
fs.StringVar(
|
||||
&emailReceivedBefore,
|
||||
"email-received-before",
|
||||
"",
|
||||
"Restore mail where the email was received before this datetime",
|
||||
)
|
||||
fs.StringVar(&emailSender, "email-sender", "", "Restore mail where the email sender matches this user id")
|
||||
fs.StringVar(&emailSubject, "email-subject", "", "Restore mail where the email subject lines contain this value")
|
||||
|
||||
@ -278,10 +294,12 @@ func validateExchangeRestoreFlags(
|
||||
return errors.New("requires one or more --user ids, the wildcard --user *, or the --all flag")
|
||||
}
|
||||
if lc > 0 && lcf == 0 {
|
||||
return errors.New("one or more --contact-folder ids or the wildcard --contact-folder * must be included to specify a --contact")
|
||||
return errors.New(
|
||||
"one or more --contact-folder ids or the wildcard --contact-folder * must be included to specify a --contact")
|
||||
}
|
||||
if le > 0 && lef == 0 {
|
||||
return errors.New("one or more --email-folder ids or the wildcard --email-folder * must be included to specify a --email")
|
||||
return errors.New(
|
||||
"one or more --email-folder ids or the wildcard --email-folder * must be included to specify a --email")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -29,7 +29,8 @@ var (
|
||||
const (
|
||||
collectionChannelBufferSize = 1000
|
||||
numberOfRetries = 4
|
||||
// RestorePropertyTag defined: https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagmessageflags-canonical-property
|
||||
// RestorePropertyTag defined:
|
||||
// https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagmessageflags-canonical-property
|
||||
RestorePropertyTag = "Integer 0x0E07"
|
||||
RestoreCanonicalEnableValue = "4"
|
||||
)
|
||||
|
||||
@ -100,7 +100,8 @@ func GetAllMailFolders(gs graph.Service, user, nameContains string) ([]MailFolde
|
||||
return nil, err
|
||||
}
|
||||
|
||||
iter, err := msgraphgocore.NewPageIterator(resp, gs.Adapter(), models.CreateMailFolderCollectionResponseFromDiscriminatorValue)
|
||||
iter, err := msgraphgocore.NewPageIterator(
|
||||
resp, gs.Adapter(), models.CreateMailFolderCollectionResponseFromDiscriminatorValue)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -140,14 +141,22 @@ func GetMailFolderID(service graph.Service, folderName, user string) (*string, e
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := service.Client().UsersById(user).MailFolders().GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
response, err := service.
|
||||
Client().
|
||||
UsersById(user).
|
||||
MailFolders().
|
||||
GetWithRequestConfigurationAndResponseHandler(options, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response == nil {
|
||||
return nil, errors.New("mail folder query to m365 back store returned nil")
|
||||
}
|
||||
pageIterator, err := msgraphgocore.NewPageIterator(response, service.Adapter(), models.CreateMailFolderCollectionResponseFromDiscriminatorValue)
|
||||
pageIterator, err := msgraphgocore.NewPageIterator(
|
||||
response,
|
||||
service.Adapter(),
|
||||
models.CreateMailFolderCollectionResponseFromDiscriminatorValue,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -14,7 +14,10 @@ func CreateAdapter(tenant, client, secret string) (*msgraphsdk.GraphRequestAdapt
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
auth, err := ka.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{"https://graph.microsoft.com/.default"})
|
||||
auth, err := ka.NewAzureIdentityAuthenticationProviderWithScopes(
|
||||
cred,
|
||||
[]string{"https://graph.microsoft.com/.default"},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -132,7 +132,11 @@ func (gc *GraphConnector) setTenantUsers() error {
|
||||
err = support.WrapAndAppend("general access", errors.New("connector failed: No access"), err)
|
||||
return err
|
||||
}
|
||||
userIterator, err := msgraphgocore.NewPageIterator(response, &gc.graphService.adapter, models.CreateUserCollectionResponseFromDiscriminatorValue)
|
||||
userIterator, err := msgraphgocore.NewPageIterator(
|
||||
response,
|
||||
&gc.graphService.adapter,
|
||||
models.CreateUserCollectionResponseFromDiscriminatorValue,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -183,7 +187,10 @@ func buildFromMap(isKey bool, mapping map[string]string) []string {
|
||||
// use to read mailbox data out for the specified user
|
||||
// Assumption: User exists
|
||||
// Add iota to this call -> mail, contacts, calendar, etc.
|
||||
func (gc *GraphConnector) ExchangeDataCollection(ctx context.Context, selector selectors.Selector) ([]data.Collection, error) {
|
||||
func (gc *GraphConnector) ExchangeDataCollection(
|
||||
ctx context.Context,
|
||||
selector selectors.Selector,
|
||||
) ([]data.Collection, error) {
|
||||
eb, err := selector.ToExchangeBackup()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "collecting exchange data")
|
||||
|
||||
@ -100,7 +100,12 @@ func (suite *DisconnectedGraphConnectorSuite) TestGraphConnector_Status() {
|
||||
context.Background(),
|
||||
support.Restore,
|
||||
12, 9, 8,
|
||||
support.WrapAndAppend("tres", errors.New("three"), support.WrapAndAppend("arc376", errors.New("one"), errors.New("two"))))
|
||||
support.WrapAndAppend(
|
||||
"tres",
|
||||
errors.New("three"),
|
||||
support.WrapAndAppend("arc376", errors.New("one"), errors.New("two")),
|
||||
),
|
||||
)
|
||||
gc.statusCh <- status
|
||||
}()
|
||||
gc.AwaitStatus()
|
||||
|
||||
@ -81,7 +81,13 @@ func (med *MockExchangeData) ToReader() io.ReadCloser {
|
||||
}
|
||||
|
||||
func (med *MockExchangeData) Info() details.ItemInfo {
|
||||
return details.ItemInfo{Exchange: &details.ExchangeInfo{Sender: "foo@bar.com", Subject: "Hello world!", Received: time.Now()}}
|
||||
return details.ItemInfo{
|
||||
Exchange: &details.ExchangeInfo{
|
||||
Sender: "foo@bar.com",
|
||||
Subject: "Hello world!",
|
||||
Received: time.Now(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GetMockMessageBytes returns bytes for Messageable item.
|
||||
@ -89,7 +95,9 @@ func (med *MockExchangeData) Info() details.ItemInfo {
|
||||
func GetMockMessageBytes(subject string) []byte {
|
||||
userID := "foobar@8qzvrj.onmicrosoft.com"
|
||||
|
||||
//nolint:lll
|
||||
message := "{\n \"@odata.etag\": \"W/\\\"CQAAABYAAAB8wYc0thTTTYl3RpEYIUq+AAAZ0f0I\\\"\",\n \"id\": \"AAMkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4NWRlZDA2Y2UxOABGAAAAAAAPvVwUramXT7jlSGpVU8_7BwB8wYc0thTTTYl3RpEYIUq_AAAAAAEMAAB8wYc0thTTTYl3RpEYIUq_AAAZ3wG3AAA=\",\n \"createdDateTime\": \"2022-04-08T18:08:02Z\",\n \"lastModifiedDateTime\": \"2022-05-17T13:46:55Z\",\n \"changeKey\": \"CQAAABYAAAB8wYc0thTTTYl3RpEYIUq+AAAZ0f0I\",\n \"categories\": [],\n \"receivedDateTime\": \"2022-04-08T18:08:02Z\",\n \"sentDateTime\": \"2022-04-08T18:07:53Z\",\n \"hasAttachments\": false,\n \"internetMessageId\": \"<MWHPR1401MB1952C46D4A46B6398F562B0FA6E99@MWHPR1401MB1952.namprd14.prod.outlook.com>\",\n \"subject\": \"" +
|
||||
//nolint:lll
|
||||
subject + " " + common.FormatNow(common.SimpleDateTimeFormat) + " Different\",\n \"bodyPreview\": \"Who is coming to next week's party? I cannot imagine it is July soon\",\n \"importance\": \"normal\",\n \"parentFolderId\": \"AQMkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4ADVkZWQwNmNlMTgALgAAAw_9XBStqZdPuOVIalVTz7sBAHzBhzS2FNNNiXdGkRghSr4AAAIBDAAAAA==\",\n \"conversationId\": \"AAQkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4NWRlZDA2Y2UxOAAQAI7SSzmEPaRJsY-TWIALn1g=\",\n \"conversationIndex\": \"AQHYS3N3jtJLOYQ9pEmxj9NYgAufWA==\",\n \"isDeliveryReceiptRequested\": null,\n \"isReadReceiptRequested\": false,\n \"isRead\": true,\n \"isDraft\": false,\n \"webLink\": \"https://outlook.office365.com/owa/?ItemID=AAMkAGQ1NzViZTdhLTEwMTMtNGJjNi05YWI2LTg4NWRlZDA2Y2UxOABGAAAAAAAPvVwUramXT7jlSGpVU8%2B7BwB8wYc0thTTTYl3RpEYIUq%2BAAAAAAEMAAB8wYc0thTTTYl3RpEYIUq%2BAAAZ3wG3AAA%3D&exvsurl=1&viewmodel=ReadMessageItem\",\n \"inferenceClassification\": \"focused\",\n \"body\": {\n \"contentType\": \"html\",\n \"content\": \"<html><head><meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=utf-8\\\"><meta name=\\\"Generator\\\" content=\\\"Microsoft Word 15 (filtered medium)\\\"><style><!--@font-face{font-family:\\\"Cambria Math\\\"}@font-face{font-family:Calibri}p.MsoNormal, li.MsoNormal, div.MsoNormal{margin:0in;font-size:11.0pt;font-family:\\\"Calibri\\\",sans-serif}span.EmailStyle17{font-family:\\\"Calibri\\\",sans-serif;color:windowtext}.MsoChpDefault{font-family:\\\"Calibri\\\",sans-serif}@page WordSection1{margin:1.0in 1.0in 1.0in 1.0in}div.WordSection1{}--></style></head><body lang=\\\"EN-US\\\" link=\\\"#0563C1\\\" vlink=\\\"#954F72\\\" style=\\\"word-wrap:break-word\\\"><div class=\\\"WordSection1\\\"><p class=\\\"MsoNormal\\\">I've been going through with the changing of messages. It shouldn't have the same calls, right? Call Me? </p><p class=\\\"MsoNormal\\\"> </p><p class=\\\"MsoNormal\\\">We want to be able to send multiple messages and we want to be able to respond and do other things that make sense for our users. In this case. Let’s consider a Mailbox</p></div></body></html>\"\n },\n \"sender\": {\n \"emailAddress\": {\n \"name\": \"Lidia Holloway\",\n \"address\": \"" + userID + "\"\n }\n },\n \"from\": {\n \"emailAddress\": {\n \"name\": \"Lidia Holloway\",\n \"address\": \"lidiah@8qzvrj.onmicrosoft.com\"\n }\n },\n \"toRecipients\": [\n {\n \"emailAddress\": {\n \"name\": \"Dustin Abbot\",\n \"address\": \"dustina@8qzvrj.onmicrosoft.com\"\n }\n }\n ],\n \"ccRecipients\": [],\n \"bccRecipients\": [],\n \"replyTo\": [],\n \"flag\": {\n \"flagStatus\": \"notFlagged\"\n }\n}\n"
|
||||
|
||||
return []byte(message)
|
||||
|
||||
@ -112,7 +112,12 @@ func SetEventMessageResponse(orig models.Messageable, adtl map[string]any) (mode
|
||||
}
|
||||
rType, ok := temp.(*models.ResponseType)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%s : responseType not returned from models.ParseResponseType: %v\t%T", *orig.GetId(), temp, temp)
|
||||
return nil, fmt.Errorf(
|
||||
"%s : responseType not returned from models.ParseResponseType: %v\t%T",
|
||||
*orig.GetId(),
|
||||
temp,
|
||||
temp,
|
||||
)
|
||||
}
|
||||
message.SetResponseType(rType)
|
||||
default:
|
||||
@ -214,7 +219,10 @@ func setEventRequestableFields(
|
||||
}
|
||||
|
||||
// SetAdditionalDataToEventMessage sets shared fields for 2 types of EventMessage: Response and Request
|
||||
func SetAdditionalDataToEventMessage(adtl map[string]any, newMessage models.EventMessageable) (models.EventMessageable, error) {
|
||||
func SetAdditionalDataToEventMessage(
|
||||
adtl map[string]any,
|
||||
newMessage models.EventMessageable,
|
||||
) (models.EventMessageable, error) {
|
||||
for key, entry := range adtl {
|
||||
if key == "endDateTime" {
|
||||
dateTime := models.NewDateTimeTimeZone()
|
||||
|
||||
@ -27,7 +27,12 @@ const (
|
||||
)
|
||||
|
||||
// Constructor for ConnectorOperationStatus. If the counts do not agree, an error is returned.
|
||||
func CreateStatus(ctx context.Context, op Operation, objects, success, folders int, err error) *ConnectorOperationStatus {
|
||||
func CreateStatus(
|
||||
ctx context.Context,
|
||||
op Operation,
|
||||
objects, success, folders int,
|
||||
err error,
|
||||
) *ConnectorOperationStatus {
|
||||
hasErrors := err != nil
|
||||
var reason string
|
||||
if err != nil {
|
||||
|
||||
@ -40,8 +40,12 @@ func (suite *GCStatusTestSuite) TestCreateStatus() {
|
||||
expect: assert.False,
|
||||
},
|
||||
{
|
||||
name: "Test: Status Failed",
|
||||
params: statusParams{Restore, 12, 9, 8, WrapAndAppend("tres", errors.New("three"), WrapAndAppend("arc376", errors.New("one"), errors.New("two")))},
|
||||
name: "Test: Status Failed",
|
||||
params: statusParams{
|
||||
Restore,
|
||||
12, 9, 8,
|
||||
WrapAndAppend("tres", errors.New("three"), WrapAndAppend("arc376", errors.New("one"), errors.New("two"))),
|
||||
},
|
||||
expect: assert.True,
|
||||
},
|
||||
}
|
||||
|
||||
@ -159,7 +159,11 @@ func newTreeMap() *treeMap {
|
||||
// ancestor of the streams and uses virtualfs.StaticDirectory for internal nodes
|
||||
// in the hierarchy. Leaf nodes are virtualfs.StreamingDirectory with the given
|
||||
// DataCollections.
|
||||
func inflateDirTree(ctx context.Context, collections []data.Collection, snapshotDetails *details.Details) (fs.Directory, error) {
|
||||
func inflateDirTree(
|
||||
ctx context.Context,
|
||||
collections []data.Collection,
|
||||
snapshotDetails *details.Details,
|
||||
) (fs.Directory, error) {
|
||||
roots := make(map[string]*treeMap)
|
||||
|
||||
for _, s := range collections {
|
||||
|
||||
@ -144,7 +144,11 @@ func (op *BackupOperation) persistResults(
|
||||
}
|
||||
|
||||
// stores the operation details, results, and selectors in the backup manifest.
|
||||
func (op *BackupOperation) createBackupModels(ctx context.Context, snapID string, backupDetails *details.Details) error {
|
||||
func (op *BackupOperation) createBackupModels(
|
||||
ctx context.Context,
|
||||
snapID string,
|
||||
backupDetails *details.Details,
|
||||
) error {
|
||||
err := op.store.Put(ctx, model.BackupDetailsSchema, &backupDetails.DetailsModel)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "creating backupdetails model")
|
||||
|
||||
@ -98,7 +98,13 @@ func readTestConfig() (map[string]string, error) {
|
||||
fallbackTo(testEnv, TestCfgEndpoint, vpr.GetString(TestCfgEndpoint), "s3.amazonaws.com")
|
||||
fallbackTo(testEnv, TestCfgPrefix, vpr.GetString(TestCfgPrefix))
|
||||
fallbackTo(testEnv, TestCfgTenantID, os.Getenv(account.TenantID), vpr.GetString(TestCfgTenantID))
|
||||
fallbackTo(testEnv, TestCfgUserID, os.Getenv(EnvCorsoM365TestUserID), vpr.GetString(TestCfgTenantID), "lidiah@8qzvrj.onmicrosoft.com")
|
||||
fallbackTo(
|
||||
testEnv,
|
||||
TestCfgUserID,
|
||||
os.Getenv(EnvCorsoM365TestUserID),
|
||||
vpr.GetString(TestCfgTenantID),
|
||||
"lidiah@8qzvrj.onmicrosoft.com",
|
||||
)
|
||||
testEnv[EnvCorsoTestConfigFilePath] = os.Getenv(EnvCorsoTestConfigFilePath)
|
||||
|
||||
testConfig = testEnv
|
||||
|
||||
@ -130,7 +130,11 @@ func (r *Repository) Close(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// NewBackup generates a BackupOperation runner.
|
||||
func (r Repository) NewBackup(ctx context.Context, selector selectors.Selector, opts control.Options) (operations.BackupOperation, error) {
|
||||
func (r Repository) NewBackup(
|
||||
ctx context.Context,
|
||||
selector selectors.Selector,
|
||||
opts control.Options,
|
||||
) (operations.BackupOperation, error) {
|
||||
return operations.NewBackupOperation(
|
||||
ctx,
|
||||
opts,
|
||||
|
||||
@ -63,10 +63,16 @@ const All = "All"
|
||||
// The core selector. Has no api for setting or retrieving data.
|
||||
// Is only used to pass along more specific selector instances.
|
||||
type Selector struct {
|
||||
Service service `json:"service,omitempty"` // The service scope of the data. Exchange, Teams, Sharepoint, etc.
|
||||
Excludes []map[string]string `json:"exclusions,omitempty"` // A slice of exclusion scopes. Exclusions apply globally to all inclusions/filters, with any-match behavior.
|
||||
Filters []map[string]string `json:"filters,omitempty"` // A slice of filter scopes. All inclusions must also match ALL filters.
|
||||
Includes []map[string]string `json:"includes,omitempty"` // A slice of inclusion scopes. Comparators must match either one of these, or all filters, to be included.
|
||||
// The service scope of the data. Exchange, Teams, Sharepoint, etc.
|
||||
Service service `json:"service,omitempty"`
|
||||
// A slice of exclusion scopes. Exclusions apply globally to all
|
||||
// inclusions/filters, with any-match behavior.
|
||||
Excludes []map[string]string `json:"exclusions,omitempty"`
|
||||
// A slice of filter scopes. All inclusions must also match ALL filters.
|
||||
Filters []map[string]string `json:"filters,omitempty"`
|
||||
// A slice of inclusion scopes. Comparators must match either one of these,
|
||||
// or all filters, to be included.
|
||||
Includes []map[string]string `json:"includes,omitempty"`
|
||||
}
|
||||
|
||||
// helper for specific selector instance constructors.
|
||||
|
||||
@ -50,7 +50,10 @@ func (w Wrapper) GetDetails(ctx context.Context, detailsID manifest.ID) (*detail
|
||||
}
|
||||
|
||||
// GetDetailsFromBackupID retrieves the backup.Details within the specified backup.
|
||||
func (w Wrapper) GetDetailsFromBackupID(ctx context.Context, backupID model.StableID) (*details.Details, *backup.Backup, error) {
|
||||
func (w Wrapper) GetDetailsFromBackupID(
|
||||
ctx context.Context,
|
||||
backupID model.StableID,
|
||||
) (*details.Details, *backup.Backup, error) {
|
||||
b, err := w.GetBackup(ctx, backupID)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user