Rename restorepoint to backup (#314)
This commit is contained in:
parent
e5f5c38d4e
commit
fa190da682
@ -59,7 +59,7 @@ func handleCreateCmd(cmd *cobra.Command, args []string) {
|
|||||||
var listCommand = "list"
|
var listCommand = "list"
|
||||||
var listCmd = &cobra.Command{
|
var listCmd = &cobra.Command{
|
||||||
Use: listCommand,
|
Use: listCommand,
|
||||||
Short: "List the history of restore points for a service",
|
Short: "List the history of backups for a service",
|
||||||
Run: handleListCmd,
|
Run: handleListCmd,
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ func handleListCmd(cmd *cobra.Command, args []string) {
|
|||||||
var detailsCommand = "details"
|
var detailsCommand = "details"
|
||||||
var detailsCmd = &cobra.Command{
|
var detailsCmd = &cobra.Command{
|
||||||
Use: detailsCommand,
|
Use: detailsCommand,
|
||||||
Short: "Shows the details of a restore point for a service",
|
Short: "Shows the details of a backup for a service",
|
||||||
Run: handleDetailsCmd,
|
Run: handleDetailsCmd,
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,8 +17,8 @@ import (
|
|||||||
|
|
||||||
// exchange bucket info from flags
|
// exchange bucket info from flags
|
||||||
var (
|
var (
|
||||||
user string
|
user string
|
||||||
rpID string
|
backupDetailsID string
|
||||||
)
|
)
|
||||||
|
|
||||||
// called by backup.go to map parent subcommands to provider-specific handling.
|
// called by backup.go to map parent subcommands to provider-specific handling.
|
||||||
@ -35,8 +35,8 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
|
|||||||
c, _ = utils.AddCommand(parent, exchangeListCmd)
|
c, _ = utils.AddCommand(parent, exchangeListCmd)
|
||||||
case detailsCommand:
|
case detailsCommand:
|
||||||
c, fs = utils.AddCommand(parent, exchangeDetailsCmd)
|
c, fs = utils.AddCommand(parent, exchangeDetailsCmd)
|
||||||
fs.StringVar(&rpID, "restore-point-details", "", "ID of the restore point details to be shown.")
|
fs.StringVar(&backupDetailsID, "backup-details", "", "ID of the backup details to be shown.")
|
||||||
c.MarkFlagRequired("restore-point-details")
|
c.MarkFlagRequired("backup-details")
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@ -94,8 +94,8 @@ func createExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return errors.Wrap(err, "Failed to run Exchange backup")
|
return errors.Wrap(err, "Failed to run Exchange backup")
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: revive when restorePoints are hooked up to backupOperation results
|
// todo: revive when backups are hooked up to backupOperation results
|
||||||
// fmt.Printf("Backed up restore point %s in %s for Exchange user %s.\n", result.SnapshotID, s.Provider, user)
|
// fmt.Printf("Created backup %s in %s for Exchange user %s.\n", result.SnapshotID, s.Provider, user)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,9 +131,9 @@ func listExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
|
|
||||||
rps, err := r.RestorePoints(ctx)
|
rps, err := r.Backups(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to list restorepoints in the repository")
|
return errors.Wrap(err, "Failed to list backups in the repository")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Can be used to print in alternative forms (e.g. json)
|
// TODO: Can be used to print in alternative forms (e.g. json)
|
||||||
@ -180,9 +180,9 @@ func detailsExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
|
|
||||||
rpd, err := r.RestorePointDetails(ctx, rpID)
|
rpd, err := r.BackupDetails(ctx, backupDetailsID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to get restorepoint details in the repository")
|
return errors.Wrap(err, "Failed to get backup details in the repository")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Can be used to print in alternative forms
|
// TODO: Can be used to print in alternative forms
|
||||||
|
|||||||
@ -15,10 +15,10 @@ import (
|
|||||||
|
|
||||||
// exchange bucket info from flags
|
// exchange bucket info from flags
|
||||||
var (
|
var (
|
||||||
folder string
|
folder string
|
||||||
mail string
|
mail string
|
||||||
restorePointID string
|
backupID string
|
||||||
user string
|
user string
|
||||||
)
|
)
|
||||||
|
|
||||||
// called by restore.go to map parent subcommands to provider-specific handling.
|
// called by restore.go to map parent subcommands to provider-specific handling.
|
||||||
@ -33,8 +33,8 @@ func addExchangeCommands(parent *cobra.Command) *cobra.Command {
|
|||||||
c, fs = utils.AddCommand(parent, exchangeRestoreCmd)
|
c, fs = utils.AddCommand(parent, exchangeRestoreCmd)
|
||||||
fs.StringVar(&folder, "folder", "", "Name of the mail folder being restored")
|
fs.StringVar(&folder, "folder", "", "Name of the mail folder being restored")
|
||||||
fs.StringVar(&mail, "mail", "", "ID of the mail message being restored")
|
fs.StringVar(&mail, "mail", "", "ID of the mail message being restored")
|
||||||
fs.StringVar(&restorePointID, "restore-point", "", "ID of the backup restore point")
|
fs.StringVar(&backupID, "backup", "", "ID of the backup to restore")
|
||||||
c.MarkFlagRequired("restore-point")
|
c.MarkFlagRequired("backup")
|
||||||
fs.StringVar(&user, "user", "", "ID of the user whose exchange data will get restored")
|
fs.StringVar(&user, "user", "", "ID of the user whose exchange data will get restored")
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
@ -58,7 +58,7 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateRestoreFlags(user, folder, mail, restorePointID); err != nil {
|
if err := validateRestoreFlags(user, folder, mail, backupID); err != nil {
|
||||||
return errors.Wrap(err, "Missing required flags")
|
return errors.Wrap(err, "Missing required flags")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
logger.Ctx(ctx).Debugw(
|
logger.Ctx(ctx).Debugw(
|
||||||
"Called - "+cmd.CommandPath(),
|
"Called - "+cmd.CommandPath(),
|
||||||
"restorePointID", restorePointID,
|
"backupID", backupID,
|
||||||
"tenantID", m365.TenantID,
|
"tenantID", m365.TenantID,
|
||||||
"clientID", m365.ClientID,
|
"clientID", m365.ClientID,
|
||||||
"hasClientSecret", len(m365.ClientSecret) > 0)
|
"hasClientSecret", len(m365.ClientSecret) > 0)
|
||||||
@ -85,7 +85,7 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
defer utils.CloseRepo(ctx, r)
|
defer utils.CloseRepo(ctx, r)
|
||||||
|
|
||||||
ro, err := r.NewRestore(ctx, restorePointID, []string{m365.TenantID, user, "mail", folder, mail})
|
ro, err := r.NewRestore(ctx, backupID, []string{m365.TenantID, user, "mail", folder, mail})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Failed to initialize Exchange restore")
|
return errors.Wrap(err, "Failed to initialize Exchange restore")
|
||||||
}
|
}
|
||||||
@ -98,9 +98,9 @@ func restoreExchangeCmd(cmd *cobra.Command, args []string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateRestoreFlags(u, f, m, rpid string) error {
|
func validateRestoreFlags(u, f, m, bID string) error {
|
||||||
if len(rpid) == 0 {
|
if len(bID) == 0 {
|
||||||
return errors.New("a restore point ID is requried")
|
return errors.New("a backup ID is requried")
|
||||||
}
|
}
|
||||||
lu, lf, lm := len(u), len(f), len(m)
|
lu, lf, lm := len(u), len(f), len(m)
|
||||||
if (lu == 0 || u == "*") && (lf+lm > 0) {
|
if (lu == 0 || u == "*") && (lf+lm > 0) {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ func (suite *ExchangeSuite) TestValidateRestoreFlags() {
|
|||||||
{"mail missing user", "", "", "m", "rpid", assert.Error},
|
{"mail missing user", "", "", "m", "rpid", assert.Error},
|
||||||
{"mail missing folder", "u", "", "m", "rpid", assert.Error},
|
{"mail missing folder", "u", "", "m", "rpid", assert.Error},
|
||||||
{"mail with wildcard folder", "u", "*", "m", "rpid", assert.Error},
|
{"mail with wildcard folder", "u", "*", "m", "rpid", assert.Error},
|
||||||
{"missing restore point id", "u", "f", "m", "", assert.Error},
|
{"missing backup id", "u", "f", "m", "", assert.Error},
|
||||||
{"all missing", "", "", "", "rpid", assert.NoError},
|
{"all missing", "", "", "", "rpid", assert.NoError},
|
||||||
}
|
}
|
||||||
for _, test := range table {
|
for _, test := range table {
|
||||||
|
|||||||
@ -3,11 +3,11 @@ package exchange
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alcionai/corso/pkg/restorepoint"
|
"github.com/alcionai/corso/pkg/backup"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MessageInfo(msg models.Messageable) *restorepoint.ExchangeInfo {
|
func MessageInfo(msg models.Messageable) *backup.ExchangeInfo {
|
||||||
sender := ""
|
sender := ""
|
||||||
subject := ""
|
subject := ""
|
||||||
received := time.Time{}
|
received := time.Time{}
|
||||||
@ -22,7 +22,7 @@ func MessageInfo(msg models.Messageable) *restorepoint.ExchangeInfo {
|
|||||||
if msg.GetReceivedDateTime() != nil {
|
if msg.GetReceivedDateTime() != nil {
|
||||||
received = *msg.GetReceivedDateTime()
|
received = *msg.GetReceivedDateTime()
|
||||||
}
|
}
|
||||||
return &restorepoint.ExchangeInfo{
|
return &backup.ExchangeInfo{
|
||||||
Sender: sender,
|
Sender: sender,
|
||||||
Subject: subject,
|
Subject: subject,
|
||||||
Received: received,
|
Received: received,
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alcionai/corso/pkg/restorepoint"
|
"github.com/alcionai/corso/pkg/backup"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
@ -20,17 +20,17 @@ func TestMessageSuite(t *testing.T) {
|
|||||||
func (suite *MessageSuite) TestMessageInfo() {
|
func (suite *MessageSuite) TestMessageInfo() {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
msgAndRP func() (models.Messageable, *restorepoint.ExchangeInfo)
|
msgAndRP func() (models.Messageable, *backup.ExchangeInfo)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Empty message",
|
name: "Empty message",
|
||||||
msgAndRP: func() (models.Messageable, *restorepoint.ExchangeInfo) {
|
msgAndRP: func() (models.Messageable, *backup.ExchangeInfo) {
|
||||||
return models.NewMessage(), &restorepoint.ExchangeInfo{}
|
return models.NewMessage(), &backup.ExchangeInfo{}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Just sender",
|
name: "Just sender",
|
||||||
msgAndRP: func() (models.Messageable, *restorepoint.ExchangeInfo) {
|
msgAndRP: func() (models.Messageable, *backup.ExchangeInfo) {
|
||||||
sender := "foo@bar.com"
|
sender := "foo@bar.com"
|
||||||
sr := models.NewRecipient()
|
sr := models.NewRecipient()
|
||||||
sea := models.NewEmailAddress()
|
sea := models.NewEmailAddress()
|
||||||
@ -38,30 +38,30 @@ func (suite *MessageSuite) TestMessageInfo() {
|
|||||||
sea.SetAddress(&sender)
|
sea.SetAddress(&sender)
|
||||||
sr.SetEmailAddress(sea)
|
sr.SetEmailAddress(sea)
|
||||||
msg.SetSender(sr)
|
msg.SetSender(sr)
|
||||||
return msg, &restorepoint.ExchangeInfo{Sender: sender}
|
return msg, &backup.ExchangeInfo{Sender: sender}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Just subject",
|
name: "Just subject",
|
||||||
msgAndRP: func() (models.Messageable, *restorepoint.ExchangeInfo) {
|
msgAndRP: func() (models.Messageable, *backup.ExchangeInfo) {
|
||||||
subject := "Hello world"
|
subject := "Hello world"
|
||||||
msg := models.NewMessage()
|
msg := models.NewMessage()
|
||||||
msg.SetSubject(&subject)
|
msg.SetSubject(&subject)
|
||||||
return msg, &restorepoint.ExchangeInfo{Subject: subject}
|
return msg, &backup.ExchangeInfo{Subject: subject}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Just receivedtime",
|
name: "Just receivedtime",
|
||||||
msgAndRP: func() (models.Messageable, *restorepoint.ExchangeInfo) {
|
msgAndRP: func() (models.Messageable, *backup.ExchangeInfo) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
msg := models.NewMessage()
|
msg := models.NewMessage()
|
||||||
msg.SetReceivedDateTime(&now)
|
msg.SetReceivedDateTime(&now)
|
||||||
return msg, &restorepoint.ExchangeInfo{Received: now}
|
return msg, &backup.ExchangeInfo{Received: now}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "All fields",
|
name: "All fields",
|
||||||
msgAndRP: func() (models.Messageable, *restorepoint.ExchangeInfo) {
|
msgAndRP: func() (models.Messageable, *backup.ExchangeInfo) {
|
||||||
sender := "foo@bar.com"
|
sender := "foo@bar.com"
|
||||||
subject := "Hello world"
|
subject := "Hello world"
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
@ -73,7 +73,7 @@ func (suite *MessageSuite) TestMessageInfo() {
|
|||||||
msg.SetSender(sr)
|
msg.SetSender(sr)
|
||||||
msg.SetSubject(&subject)
|
msg.SetSubject(&subject)
|
||||||
msg.SetReceivedDateTime(&now)
|
msg.SetReceivedDateTime(&now)
|
||||||
return msg, &restorepoint.ExchangeInfo{Sender: sender, Subject: subject, Received: now}
|
return msg, &backup.ExchangeInfo{Sender: sender, Subject: subject, Received: now}
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/alcionai/corso/pkg/restorepoint"
|
"github.com/alcionai/corso/pkg/backup"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -40,7 +40,7 @@ type DataStream interface {
|
|||||||
// DataStreamInfo is used to provide service specific
|
// DataStreamInfo is used to provide service specific
|
||||||
// information about the DataStream
|
// information about the DataStream
|
||||||
type DataStreamInfo interface {
|
type DataStreamInfo interface {
|
||||||
Info() restorepoint.ItemInfo
|
Info() backup.ItemInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ DataCollection = &ExchangeDataCollection{}
|
var _ DataCollection = &ExchangeDataCollection{}
|
||||||
@ -101,7 +101,7 @@ type ExchangeData struct {
|
|||||||
// going forward. Using []byte for now but I assume we'll have
|
// going forward. Using []byte for now but I assume we'll have
|
||||||
// some structured type in here (serialization to []byte can be done in `Read`)
|
// some structured type in here (serialization to []byte can be done in `Read`)
|
||||||
message []byte
|
message []byte
|
||||||
info *restorepoint.ExchangeInfo
|
info *backup.ExchangeInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ed *ExchangeData) UUID() string {
|
func (ed *ExchangeData) UUID() string {
|
||||||
@ -112,6 +112,6 @@ func (ed *ExchangeData) ToReader() io.ReadCloser {
|
|||||||
return io.NopCloser(bytes.NewReader(ed.message))
|
return io.NopCloser(bytes.NewReader(ed.message))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ed *ExchangeData) Info() restorepoint.ItemInfo {
|
func (ed *ExchangeData) Info() backup.ItemInfo {
|
||||||
return restorepoint.ItemInfo{Exchange: ed.info}
|
return backup.ItemInfo{Exchange: ed.info}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
|
||||||
"github.com/alcionai/corso/internal/connector"
|
"github.com/alcionai/corso/internal/connector"
|
||||||
"github.com/alcionai/corso/pkg/restorepoint"
|
"github.com/alcionai/corso/pkg/backup"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockExchangeDataCollection represents a mock exchange mailbox
|
// MockExchangeDataCollection represents a mock exchange mailbox
|
||||||
@ -69,6 +69,6 @@ func (med *MockExchangeData) ToReader() io.ReadCloser {
|
|||||||
return med.Reader
|
return med.Reader
|
||||||
}
|
}
|
||||||
|
|
||||||
func (med *MockExchangeData) Info() restorepoint.ItemInfo {
|
func (med *MockExchangeData) Info() backup.ItemInfo {
|
||||||
return restorepoint.ItemInfo{Exchange: &restorepoint.ExchangeInfo{Sender: "foo@bar.com", Subject: "Hello world!", Received: time.Now()}}
|
return backup.ItemInfo{Exchange: &backup.ExchangeInfo{Sender: "foo@bar.com", Subject: "Hello world!", Received: time.Now()}}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,8 +27,8 @@ const (
|
|||||||
UnknownModel = modelType(iota)
|
UnknownModel = modelType(iota)
|
||||||
BackupOpModel
|
BackupOpModel
|
||||||
RestoreOpModel
|
RestoreOpModel
|
||||||
RestorePointModel
|
BackupModel
|
||||||
RestorePointDetailsModel
|
BackupDetailsModel
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewModelStore(c *conn) (*ModelStore, error) {
|
func NewModelStore(c *conn) (*ModelStore, error) {
|
||||||
|
|||||||
@ -184,7 +184,7 @@ func (suite *ModelStoreIntegrationSuite) TestPutGet() {
|
|||||||
hasErr: false,
|
hasErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
t: RestorePointModel,
|
t: BackupModel,
|
||||||
check: require.NoError,
|
check: require.NoError,
|
||||||
hasErr: false,
|
hasErr: false,
|
||||||
},
|
},
|
||||||
@ -272,7 +272,7 @@ func (suite *ModelStoreIntegrationSuite) TestPutGetOfType() {
|
|||||||
hasErr: false,
|
hasErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
t: RestorePointModel,
|
t: BackupModel,
|
||||||
check: require.NoError,
|
check: require.NoError,
|
||||||
hasErr: false,
|
hasErr: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -11,13 +11,13 @@ func _() {
|
|||||||
_ = x[UnknownModel-0]
|
_ = x[UnknownModel-0]
|
||||||
_ = x[BackupOpModel-1]
|
_ = x[BackupOpModel-1]
|
||||||
_ = x[RestoreOpModel-2]
|
_ = x[RestoreOpModel-2]
|
||||||
_ = x[RestorePointModel-3]
|
_ = x[BackupModel-3]
|
||||||
_ = x[RestorePointDetailsModel-4]
|
_ = x[BackupDetailsModel-4]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _modelType_name = "UnknownModelBackupOpModelRestoreOpModelRestorePointModelRestorePointDetailsModel"
|
const _modelType_name = "UnknownModelBackupOpModelRestoreOpModelBackupModelBackupDetailsModel"
|
||||||
|
|
||||||
var _modelType_index = [...]uint8{0, 12, 25, 39, 56, 80}
|
var _modelType_index = [...]uint8{0, 12, 25, 39, 50, 68}
|
||||||
|
|
||||||
func (i modelType) String() string {
|
func (i modelType) String() string {
|
||||||
if i < 0 || i >= modelType(len(_modelType_index)-1) {
|
if i < 0 || i >= modelType(len(_modelType_index)-1) {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/alcionai/corso/internal/connector"
|
"github.com/alcionai/corso/internal/connector"
|
||||||
"github.com/alcionai/corso/pkg/restorepoint"
|
"github.com/alcionai/corso/pkg/backup"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -79,7 +79,7 @@ func (w *Wrapper) Close(ctx context.Context) error {
|
|||||||
// DataCollection.
|
// DataCollection.
|
||||||
func getStreamItemFunc(
|
func getStreamItemFunc(
|
||||||
collection connector.DataCollection,
|
collection connector.DataCollection,
|
||||||
details *restorepoint.Details,
|
details *backup.Details,
|
||||||
) func(context.Context, func(context.Context, fs.Entry) error) error {
|
) func(context.Context, func(context.Context, fs.Entry) error) error {
|
||||||
return func(ctx context.Context, cb func(context.Context, fs.Entry) error) error {
|
return func(ctx context.Context, cb func(context.Context, fs.Entry) error) error {
|
||||||
items := collection.Items()
|
items := collection.Items()
|
||||||
@ -101,7 +101,7 @@ func getStreamItemFunc(
|
|||||||
return errors.Wrap(err, "executing callback")
|
return errors.Wrap(err, "executing callback")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate RestorePointDetails
|
// Populate BackupDetails
|
||||||
ep := append(collection.FullPath(), e.UUID())
|
ep := append(collection.FullPath(), e.UUID())
|
||||||
details.Add(path.Join(ep...), ei.Info())
|
details.Add(path.Join(ep...), ei.Info())
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ func getStreamItemFunc(
|
|||||||
// buildKopiaDirs recursively builds a directory hierarchy from the roots up.
|
// buildKopiaDirs recursively builds a directory hierarchy from the roots up.
|
||||||
// Returned directories are either virtualfs.StreamingDirectory or
|
// Returned directories are either virtualfs.StreamingDirectory or
|
||||||
// virtualfs.staticDirectory.
|
// virtualfs.staticDirectory.
|
||||||
func buildKopiaDirs(dirName string, dir *treeMap, details *restorepoint.Details) (fs.Directory, error) {
|
func buildKopiaDirs(dirName string, dir *treeMap, details *backup.Details) (fs.Directory, error) {
|
||||||
// Don't support directories that have both a DataCollection and a set of
|
// Don't support directories that have both a DataCollection and a set of
|
||||||
// static child directories.
|
// static child directories.
|
||||||
if dir.collection != nil && len(dir.childDirs) > 0 {
|
if dir.collection != nil && len(dir.childDirs) > 0 {
|
||||||
@ -154,7 +154,7 @@ func newTreeMap() *treeMap {
|
|||||||
// ancestor of the streams and uses virtualfs.StaticDirectory for internal nodes
|
// ancestor of the streams and uses virtualfs.StaticDirectory for internal nodes
|
||||||
// in the hierarchy. Leaf nodes are virtualfs.StreamingDirectory with the given
|
// in the hierarchy. Leaf nodes are virtualfs.StreamingDirectory with the given
|
||||||
// DataCollections.
|
// DataCollections.
|
||||||
func inflateDirTree(ctx context.Context, collections []connector.DataCollection, details *restorepoint.Details) (fs.Directory, error) {
|
func inflateDirTree(ctx context.Context, collections []connector.DataCollection, details *backup.Details) (fs.Directory, error) {
|
||||||
roots := make(map[string]*treeMap)
|
roots := make(map[string]*treeMap)
|
||||||
|
|
||||||
for _, s := range collections {
|
for _, s := range collections {
|
||||||
@ -227,12 +227,12 @@ func inflateDirTree(ctx context.Context, collections []connector.DataCollection,
|
|||||||
func (w Wrapper) BackupCollections(
|
func (w Wrapper) BackupCollections(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
collections []connector.DataCollection,
|
collections []connector.DataCollection,
|
||||||
) (*BackupStats, *restorepoint.Details, error) {
|
) (*BackupStats, *backup.Details, error) {
|
||||||
if w.c == nil {
|
if w.c == nil {
|
||||||
return nil, nil, errNotConnected
|
return nil, nil, errNotConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
details := &restorepoint.Details{}
|
details := &backup.Details{}
|
||||||
|
|
||||||
dirTree, err := inflateDirTree(ctx, collections, details)
|
dirTree, err := inflateDirTree(ctx, collections, details)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -250,7 +250,7 @@ func (w Wrapper) BackupCollections(
|
|||||||
func (w Wrapper) makeSnapshotWithRoot(
|
func (w Wrapper) makeSnapshotWithRoot(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
root fs.Directory,
|
root fs.Directory,
|
||||||
details *restorepoint.Details,
|
details *backup.Details,
|
||||||
) (*BackupStats, error) {
|
) (*BackupStats, error) {
|
||||||
si := snapshot.SourceInfo{
|
si := snapshot.SourceInfo{
|
||||||
Host: kTestHost,
|
Host: kTestHost,
|
||||||
@ -275,9 +275,6 @@ func (w Wrapper) makeSnapshotWithRoot(
|
|||||||
return nil, errors.Wrap(err, "uploading data")
|
return nil, errors.Wrap(err, "uploading data")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Persist RestorePointDetails here
|
|
||||||
// Create and store RestorePoint
|
|
||||||
|
|
||||||
if _, err := snapshot.SaveSnapshot(ctx, rw, man); err != nil {
|
if _, err := snapshot.SaveSnapshot(ctx, rw, man); err != nil {
|
||||||
return nil, errors.Wrap(err, "saving snapshot")
|
return nil, errors.Wrap(err, "saving snapshot")
|
||||||
}
|
}
|
||||||
@ -286,8 +283,6 @@ func (w Wrapper) makeSnapshotWithRoot(
|
|||||||
return nil, errors.Wrap(err, "flushing writer")
|
return nil, errors.Wrap(err, "flushing writer")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Return RestorePoint ID in stats
|
|
||||||
|
|
||||||
res := manifestToStats(man)
|
res := manifestToStats(man)
|
||||||
return &res, nil
|
return &res, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/alcionai/corso/internal/connector"
|
"github.com/alcionai/corso/internal/connector"
|
||||||
"github.com/alcionai/corso/internal/connector/mockconnector"
|
"github.com/alcionai/corso/internal/connector/mockconnector"
|
||||||
ctesting "github.com/alcionai/corso/internal/testing"
|
ctesting "github.com/alcionai/corso/internal/testing"
|
||||||
"github.com/alcionai/corso/pkg/restorepoint"
|
"github.com/alcionai/corso/pkg/backup"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -73,7 +73,7 @@ func (suite *KopiaUnitSuite) TestBuildDirectoryTree() {
|
|||||||
user2: 42,
|
user2: 42,
|
||||||
}
|
}
|
||||||
|
|
||||||
details := &restorepoint.Details{}
|
details := &backup.Details{}
|
||||||
|
|
||||||
collections := []connector.DataCollection{
|
collections := []connector.DataCollection{
|
||||||
mockconnector.NewMockExchangeDataCollection(
|
mockconnector.NewMockExchangeDataCollection(
|
||||||
@ -136,7 +136,7 @@ func (suite *KopiaUnitSuite) TestBuildDirectoryTree_NoAncestorDirs() {
|
|||||||
|
|
||||||
expectedFileCount := 42
|
expectedFileCount := 42
|
||||||
|
|
||||||
details := &restorepoint.Details{}
|
details := &backup.Details{}
|
||||||
collections := []connector.DataCollection{
|
collections := []connector.DataCollection{
|
||||||
mockconnector.NewMockExchangeDataCollection(
|
mockconnector.NewMockExchangeDataCollection(
|
||||||
[]string{emails},
|
[]string{emails},
|
||||||
@ -215,7 +215,7 @@ func (suite *KopiaUnitSuite) TestBuildDirectoryTree_Fails() {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
suite.T().Run(test.name, func(t *testing.T) {
|
suite.T().Run(test.name, func(t *testing.T) {
|
||||||
details := &restorepoint.Details{}
|
details := &backup.Details{}
|
||||||
_, err := inflateDirTree(ctx, test.layout, details)
|
_, err := inflateDirTree(ctx, test.layout, details)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/alcionai/corso/internal/connector/support"
|
"github.com/alcionai/corso/internal/connector/support"
|
||||||
"github.com/alcionai/corso/internal/kopia"
|
"github.com/alcionai/corso/internal/kopia"
|
||||||
"github.com/alcionai/corso/pkg/account"
|
"github.com/alcionai/corso/pkg/account"
|
||||||
"github.com/alcionai/corso/pkg/restorepoint"
|
"github.com/alcionai/corso/pkg/backup"
|
||||||
"github.com/alcionai/corso/pkg/selectors"
|
"github.com/alcionai/corso/pkg/selectors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ type BackupOperation struct {
|
|||||||
type BackupResults struct {
|
type BackupResults struct {
|
||||||
summary
|
summary
|
||||||
metrics
|
metrics
|
||||||
// todo: RestorePoint RestorePoint
|
// todo: Backup ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBackupOperation constructs and validates a backup operation.
|
// NewBackupOperation constructs and validates a backup operation.
|
||||||
@ -92,14 +92,14 @@ func (op *BackupOperation) Run(ctx context.Context) error {
|
|||||||
stats.gc = gc.Status()
|
stats.gc = gc.Status()
|
||||||
|
|
||||||
// hand the results to the consumer
|
// hand the results to the consumer
|
||||||
var details *restorepoint.Details
|
var details *backup.Details
|
||||||
stats.k, details, err = op.kopia.BackupCollections(ctx, cs)
|
stats.k, details, err = op.kopia.BackupCollections(ctx, cs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.writeErr = err
|
stats.writeErr = err
|
||||||
return errors.Wrap(err, "backing up service data")
|
return errors.Wrap(err, "backing up service data")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = op.createRestorePoint(ctx, stats.k.SnapshotID, details)
|
err = op.createBackupModels(ctx, stats.k.SnapshotID, details)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.writeErr = err
|
stats.writeErr = err
|
||||||
return err
|
return err
|
||||||
@ -107,16 +107,16 @@ func (op *BackupOperation) Run(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (op *BackupOperation) createRestorePoint(ctx context.Context, snapID string, details *restorepoint.Details) error {
|
func (op *BackupOperation) createBackupModels(ctx context.Context, snapID string, details *backup.Details) error {
|
||||||
err := op.modelStore.Put(ctx, kopia.RestorePointDetailsModel, details)
|
err := op.modelStore.Put(ctx, kopia.BackupDetailsModel, details)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "creating restorepointdetails model")
|
return errors.Wrap(err, "creating backupdetails model")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = op.modelStore.Put(ctx, kopia.RestorePointModel,
|
err = op.modelStore.Put(ctx, kopia.BackupModel,
|
||||||
restorepoint.New(snapID, string(details.ModelStoreID)))
|
backup.New(snapID, string(details.ModelStoreID)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "creating restorepoint model")
|
return errors.Wrap(err, "creating backup model")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,10 +16,10 @@ import (
|
|||||||
type RestoreOperation struct {
|
type RestoreOperation struct {
|
||||||
operation
|
operation
|
||||||
|
|
||||||
RestorePointID string `json:"restorePointID"`
|
BackupID string `json:"backupID"`
|
||||||
Results RestoreResults `json:"results"`
|
Results RestoreResults `json:"results"`
|
||||||
Targets []string `json:"selectors"` // todo: replace with Selectors
|
Targets []string `json:"selectors"` // todo: replace with Selectors
|
||||||
Version string `json:"bersion"`
|
Version string `json:"bersion"`
|
||||||
|
|
||||||
account account.Account
|
account account.Account
|
||||||
}
|
}
|
||||||
@ -37,15 +37,15 @@ func NewRestoreOperation(
|
|||||||
kw *kopia.Wrapper,
|
kw *kopia.Wrapper,
|
||||||
ms *kopia.ModelStore,
|
ms *kopia.ModelStore,
|
||||||
acct account.Account,
|
acct account.Account,
|
||||||
restorePointID string,
|
backupID string,
|
||||||
targets []string,
|
targets []string,
|
||||||
) (RestoreOperation, error) {
|
) (RestoreOperation, error) {
|
||||||
op := RestoreOperation{
|
op := RestoreOperation{
|
||||||
operation: newOperation(opts, kw, ms),
|
operation: newOperation(opts, kw, ms),
|
||||||
RestorePointID: restorePointID,
|
BackupID: backupID,
|
||||||
Targets: targets,
|
Targets: targets,
|
||||||
Version: "v0",
|
Version: "v0",
|
||||||
account: acct,
|
account: acct,
|
||||||
}
|
}
|
||||||
if err := op.validate(); err != nil {
|
if err := op.validate(); err != nil {
|
||||||
return RestoreOperation{}, err
|
return RestoreOperation{}, err
|
||||||
@ -77,7 +77,7 @@ func (op *RestoreOperation) Run(ctx context.Context) error {
|
|||||||
stats := restoreStats{}
|
stats := restoreStats{}
|
||||||
defer op.persistResults(time.Now(), &stats)
|
defer op.persistResults(time.Now(), &stats)
|
||||||
|
|
||||||
dc, err := op.kopia.RestoreSingleItem(ctx, op.RestorePointID, op.Targets)
|
dc, err := op.kopia.RestoreSingleItem(ctx, op.BackupID, op.Targets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.readErr = err
|
stats.readErr = err
|
||||||
return errors.Wrap(err, "retrieving service data")
|
return errors.Wrap(err, "retrieving service data")
|
||||||
|
|||||||
@ -111,7 +111,7 @@ func (suite *RestoreOpIntegrationSuite) TestNewRestoreOperation() {
|
|||||||
test.kw,
|
test.kw,
|
||||||
test.ms,
|
test.ms,
|
||||||
test.acct,
|
test.acct,
|
||||||
"restore-point-id",
|
"backup-id",
|
||||||
nil)
|
nil)
|
||||||
test.errCheck(t, err)
|
test.errCheck(t, err)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package restorepoint
|
package backup
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
@ -7,9 +7,8 @@ import (
|
|||||||
"github.com/alcionai/corso/internal/model"
|
"github.com/alcionai/corso/internal/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RestorePoint represents the result of a backup operation
|
// Backup represents the result of a backup operation
|
||||||
// that can be restored
|
type Backup struct {
|
||||||
type RestorePoint struct {
|
|
||||||
model.BaseModel
|
model.BaseModel
|
||||||
CreationTime time.Time `json:"creationTime"`
|
CreationTime time.Time `json:"creationTime"`
|
||||||
|
|
||||||
@ -24,15 +23,15 @@ type RestorePoint struct {
|
|||||||
// - Backup "Specification"
|
// - Backup "Specification"
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(snapshotID, detailsID string) *RestorePoint {
|
func New(snapshotID, detailsID string) *Backup {
|
||||||
return &RestorePoint{
|
return &Backup{
|
||||||
CreationTime: time.Now(),
|
CreationTime: time.Now(),
|
||||||
SnapshotID: snapshotID,
|
SnapshotID: snapshotID,
|
||||||
DetailsID: detailsID,
|
DetailsID: detailsID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Details describes what was stored in a RestorePoint
|
// Details describes what was stored in a Backup
|
||||||
type Details struct {
|
type Details struct {
|
||||||
model.BaseModel
|
model.BaseModel
|
||||||
Entries []DetailsEntry `json:"entries"`
|
Entries []DetailsEntry `json:"entries"`
|
||||||
@ -41,7 +40,7 @@ type Details struct {
|
|||||||
mu sync.Mutex `json:"-"`
|
mu sync.Mutex `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DetailsEntry describes a single item stored in a RestorePoint
|
// DetailsEntry describes a single item stored in a Backup
|
||||||
type DetailsEntry struct {
|
type DetailsEntry struct {
|
||||||
// TODO: `RepoRef` is currently the full path to the item in Kopia
|
// TODO: `RepoRef` is currently the full path to the item in Kopia
|
||||||
// This can be optimized.
|
// This can be optimized.
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/alcionai/corso/internal/kopia"
|
"github.com/alcionai/corso/internal/kopia"
|
||||||
"github.com/alcionai/corso/internal/operations"
|
"github.com/alcionai/corso/internal/operations"
|
||||||
"github.com/alcionai/corso/pkg/account"
|
"github.com/alcionai/corso/pkg/account"
|
||||||
"github.com/alcionai/corso/pkg/restorepoint"
|
"github.com/alcionai/corso/pkg/backup"
|
||||||
"github.com/alcionai/corso/pkg/selectors"
|
"github.com/alcionai/corso/pkg/selectors"
|
||||||
"github.com/alcionai/corso/pkg/storage"
|
"github.com/alcionai/corso/pkg/storage"
|
||||||
)
|
)
|
||||||
@ -126,7 +126,7 @@ func (r *Repository) Close(ctx context.Context) error {
|
|||||||
return errors.Wrap(err, "closing corso ModelStore")
|
return errors.Wrap(err, "closing corso ModelStore")
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBackup generates a backupOperation runner.
|
// NewBackup generates a BackupOperation runner.
|
||||||
func (r Repository) NewBackup(ctx context.Context, selector selectors.Selector) (operations.BackupOperation, error) {
|
func (r Repository) NewBackup(ctx context.Context, selector selectors.Selector) (operations.BackupOperation, error) {
|
||||||
return operations.NewBackupOperation(
|
return operations.NewBackupOperation(
|
||||||
ctx,
|
ctx,
|
||||||
@ -138,27 +138,27 @@ func (r Repository) NewBackup(ctx context.Context, selector selectors.Selector)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRestore generates a restoreOperation runner.
|
// NewRestore generates a restoreOperation runner.
|
||||||
func (r Repository) NewRestore(ctx context.Context, restorePointID string, targets []string) (operations.RestoreOperation, error) {
|
func (r Repository) NewRestore(ctx context.Context, backupID string, targets []string) (operations.RestoreOperation, error) {
|
||||||
return operations.NewRestoreOperation(
|
return operations.NewRestoreOperation(
|
||||||
ctx,
|
ctx,
|
||||||
operations.Options{},
|
operations.Options{},
|
||||||
r.dataLayer,
|
r.dataLayer,
|
||||||
r.modelStore,
|
r.modelStore,
|
||||||
r.Account,
|
r.Account,
|
||||||
restorePointID,
|
backupID,
|
||||||
targets)
|
targets)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestorePoints lists restorepoints in a respository
|
// backups lists backups in a respository
|
||||||
func (r Repository) RestorePoints(ctx context.Context) ([]*restorepoint.RestorePoint, error) {
|
func (r Repository) Backups(ctx context.Context) ([]*backup.Backup, error) {
|
||||||
bms, err := r.modelStore.GetIDsForType(ctx, kopia.RestorePointModel, nil)
|
bms, err := r.modelStore.GetIDsForType(ctx, kopia.BackupModel, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
rps := make([]*restorepoint.RestorePoint, 0, len(bms))
|
rps := make([]*backup.Backup, 0, len(bms))
|
||||||
for _, bm := range bms {
|
for _, bm := range bms {
|
||||||
rp := restorepoint.RestorePoint{}
|
rp := backup.Backup{}
|
||||||
err := r.modelStore.GetWithModelStoreID(ctx, kopia.RestorePointModel, bm.ModelStoreID, &rp)
|
err := r.modelStore.GetWithModelStoreID(ctx, kopia.BackupModel, bm.ModelStoreID, &rp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -167,10 +167,10 @@ func (r Repository) RestorePoints(ctx context.Context) ([]*restorepoint.RestoreP
|
|||||||
return rps, nil
|
return rps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestorePoints lists restorepoints in a respository
|
// BackupDetails returns the specified backup details object
|
||||||
func (r Repository) RestorePointDetails(ctx context.Context, rpDetailsID string) (*restorepoint.Details, error) {
|
func (r Repository) BackupDetails(ctx context.Context, rpDetailsID string) (*backup.Details, error) {
|
||||||
rpd := restorepoint.Details{}
|
rpd := backup.Details{}
|
||||||
err := r.modelStore.GetWithModelStoreID(ctx, kopia.RestorePointDetailsModel, manifest.ID(rpDetailsID), &rpd)
|
err := r.modelStore.GetWithModelStoreID(ctx, kopia.BackupDetailsModel, manifest.ID(rpDetailsID), &rpd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -190,7 +190,7 @@ func (suite *RepositoryIntegrationSuite) TestNewRestore() {
|
|||||||
r, err := repository.Initialize(ctx, acct, st)
|
r, err := repository.Initialize(ctx, acct, st)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
ro, err := r.NewRestore(ctx, "restore-point-id", []string{})
|
ro, err := r.NewRestore(ctx, "backup-id", []string{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, ro)
|
require.NotNil(t, ro)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,10 +47,10 @@ func (s Selector) ToExchangeBackup() (*ExchangeBackup, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewExchangeRestore produces a new Selector with the service set to ServiceExchange.
|
// NewExchangeRestore produces a new Selector with the service set to ServiceExchange.
|
||||||
func NewExchangeRestore(restorePointID string) *ExchangeRestore {
|
func NewExchangeRestore(backupID string) *ExchangeRestore {
|
||||||
src := ExchangeRestore{
|
src := ExchangeRestore{
|
||||||
exchange{
|
exchange{
|
||||||
newSelector(ServiceExchange, restorePointID),
|
newSelector(ServiceExchange, backupID),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return &src
|
return &src
|
||||||
|
|||||||
@ -20,7 +20,7 @@ func (suite *ExchangeSourceSuite) TestNewExchangeBackup() {
|
|||||||
t := suite.T()
|
t := suite.T()
|
||||||
eb := NewExchangeBackup()
|
eb := NewExchangeBackup()
|
||||||
assert.Equal(t, eb.Service, ServiceExchange)
|
assert.Equal(t, eb.Service, ServiceExchange)
|
||||||
assert.Zero(t, eb.RestorePointID)
|
assert.Zero(t, eb.BackupID)
|
||||||
assert.NotZero(t, eb.Scopes())
|
assert.NotZero(t, eb.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,15 +31,15 @@ func (suite *ExchangeSourceSuite) TestToExchangeBackup() {
|
|||||||
eb, err := s.ToExchangeBackup()
|
eb, err := s.ToExchangeBackup()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, eb.Service, ServiceExchange)
|
assert.Equal(t, eb.Service, ServiceExchange)
|
||||||
assert.Zero(t, eb.RestorePointID)
|
assert.Zero(t, eb.BackupID)
|
||||||
assert.NotZero(t, eb.Scopes())
|
assert.NotZero(t, eb.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *ExchangeSourceSuite) TestNewExchangeRestore() {
|
func (suite *ExchangeSourceSuite) TestNewExchangeRestore() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
er := NewExchangeRestore("rpid")
|
er := NewExchangeRestore("backupID")
|
||||||
assert.Equal(t, er.Service, ServiceExchange)
|
assert.Equal(t, er.Service, ServiceExchange)
|
||||||
assert.Equal(t, er.RestorePointID, "rpid")
|
assert.Equal(t, er.BackupID, "backupID")
|
||||||
assert.NotZero(t, er.Scopes())
|
assert.NotZero(t, er.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ func (suite *ExchangeSourceSuite) TestToExchangeRestore() {
|
|||||||
eb, err := s.ToExchangeRestore()
|
eb, err := s.ToExchangeRestore()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, eb.Service, ServiceExchange)
|
assert.Equal(t, eb.Service, ServiceExchange)
|
||||||
assert.Equal(t, eb.RestorePointID, "rpid")
|
assert.Equal(t, eb.BackupID, "rpid")
|
||||||
assert.NotZero(t, eb.Scopes())
|
assert.NotZero(t, eb.Scopes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,19 +44,19 @@ const (
|
|||||||
// The core selector. Has no api for setting or retrieving data.
|
// The core selector. Has no api for setting or retrieving data.
|
||||||
// Is only used to pass along more specific selector instances.
|
// Is only used to pass along more specific selector instances.
|
||||||
type Selector struct {
|
type Selector struct {
|
||||||
RestorePointID string `json:"restorePointID,omitempty"` // A restore point id, used only by restore operations.
|
BackupID string `json:"backupID,omitempty"` // A backup id, used only by restore operations.
|
||||||
Service service `json:"service,omitempty"` // The service scope of the data. Exchange, Teams, Sharepoint, etc.
|
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 exclusions. Each exclusion applies to all inclusions.
|
Excludes []map[string]string `json:"exclusions,omitempty"` // A slice of exclusions. Each exclusion applies to all inclusions.
|
||||||
Includes []map[string]string `json:"scopes,omitempty"` // A slice of inclusions. Expected to get cast to a service wrapper within each service handler.
|
Includes []map[string]string `json:"scopes,omitempty"` // A slice of inclusions. Expected to get cast to a service wrapper within each service handler.
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper for specific selector instance constructors.
|
// helper for specific selector instance constructors.
|
||||||
func newSelector(s service, restorePointID string) Selector {
|
func newSelector(s service, backupID string) Selector {
|
||||||
return Selector{
|
return Selector{
|
||||||
RestorePointID: restorePointID,
|
BackupID: backupID,
|
||||||
Service: s,
|
Service: s,
|
||||||
Excludes: []map[string]string{},
|
Excludes: []map[string]string{},
|
||||||
Includes: []map[string]string{},
|
Includes: []map[string]string{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,10 +17,10 @@ func TestSelectorSuite(t *testing.T) {
|
|||||||
|
|
||||||
func (suite *SelectorSuite) TestNewSelector() {
|
func (suite *SelectorSuite) TestNewSelector() {
|
||||||
t := suite.T()
|
t := suite.T()
|
||||||
s := newSelector(ServiceUnknown, "rpid")
|
s := newSelector(ServiceUnknown, "backupID")
|
||||||
assert.NotNil(t, s)
|
assert.NotNil(t, s)
|
||||||
assert.Equal(t, s.Service, ServiceUnknown)
|
assert.Equal(t, s.Service, ServiceUnknown)
|
||||||
assert.Equal(t, s.RestorePointID, "rpid")
|
assert.Equal(t, s.BackupID, "backupID")
|
||||||
assert.NotNil(t, s.Includes)
|
assert.NotNil(t, s.Includes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user