utils

package
v0.0.0-...-eb3ab3a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotYetImplemented = clues.New("not yet implemented")

Functions

func AccountConnectAndWriteRepoConfig

func AccountConnectAndWriteRepoConfig(
	ctx context.Context,
	cmd *cobra.Command,
	pst path.ServiceType,
) (repository.Repositoryer, *account.Account, error)

func AddCommand

func AddCommand(parent, c *cobra.Command, opts ...cmdOpt) (*cobra.Command, *pflag.FlagSet)

AddCommand adds a clone of the subCommand to the parent, and returns both the clone and its pflags.

func AddExchangeInclude

func AddExchangeInclude(
	sel *selectors.ExchangeRestore,
	folders, items []string,
	eisc selectors.ExchangeItemScopeConstructor,
)

AddExchangeInclude adds the scope of the provided values to the selector's inclusion set. Any unpopulated slice will be replaced with selectors.Any() to act as a wildcard.

func AddExchangeInfo

func AddExchangeInfo(
	sel *selectors.ExchangeRestore,
	v string,
	f func(string) []selectors.ExchangeScope,
)

AddExchangeInfo adds the scope of the provided values to the selector's filter set

func AddGroupsCategories

func AddGroupsCategories(sel *selectors.GroupsBackup, cats []string) *selectors.GroupsBackup

func AddGroupsFilter

func AddGroupsFilter(
	sel *selectors.GroupsRestore,
	v string,
	f func(string) []selectors.GroupsScope,
)

AddGroupsFilter adds the scope of the provided values to the selector's filter set

func AddOneDriveFilter

func AddOneDriveFilter(
	sel *selectors.OneDriveRestore,
	v string,
	f func(string) []selectors.OneDriveScope,
)

AddOneDriveFilter adds the scope of the provided values to the selector's filter set

func AddSharePointInfo

func AddSharePointInfo(
	sel *selectors.SharePointRestore,
	v string,
	f func(string) []selectors.SharePointScope,
)

AddSharePointInfo adds the scope of the provided values to the selector's filter set

func AddTeamsChatsCategories

func AddTeamsChatsCategories(sel *selectors.TeamsChatsBackup, cats []string) *selectors.TeamsChatsBackup

func AddTeamsChatsFilter

func AddTeamsChatsFilter(
	sel *selectors.TeamsChatsRestore,
	v string,
	f func(string) []selectors.TeamsChatsScope,
)

AddTeamsChatsFilter adds the scope of the provided values to the selector's filter set

func CloseRepo

func CloseRepo(ctx context.Context, r repository.Repositoryer)

CloseRepo handles closing a repo.

func Control

func Control() control.Options

Control produces the control options based on the user's flags.

func ControlWithConfig

func ControlWithConfig(cfg config.RepoDetails) control.Options

func FilterExchangeRestoreInfoSelectors

func FilterExchangeRestoreInfoSelectors(
	sel *selectors.ExchangeRestore,
	opts ExchangeOpts,
)

FilterExchangeRestoreInfoSelectors builds the common info-selector filters.

func FilterGroupsRestoreInfoSelectors

func FilterGroupsRestoreInfoSelectors(
	sel *selectors.GroupsRestore,
	opts GroupsOpts,
)

FilterGroupsRestoreInfoSelectors builds the common info-selector filters.

func FilterOneDriveRestoreInfoSelectors

func FilterOneDriveRestoreInfoSelectors(
	sel *selectors.OneDriveRestore,
	opts OneDriveOpts,
)

FilterOneDriveRestoreInfoSelectors builds the common info-selector filters.

func FilterSharePointRestoreInfoSelectors

func FilterSharePointRestoreInfoSelectors(
	sel *selectors.SharePointRestore,
	opts SharePointOpts,
)

FilterSharePointRestoreInfoSelectors builds the common info-selector filters.

func FilterTeamsChatsRestoreInfoSelectors

func FilterTeamsChatsRestoreInfoSelectors(
	sel *selectors.TeamsChatsRestore,
	opts TeamsChatsOpts,
)

FilterTeamsChatsRestoreInfoSelectors builds the common info-selector filters.

func GetStorageProviderAndOverrides

func GetStorageProviderAndOverrides(
	ctx context.Context,
	cmd *cobra.Command,
) (storage.ProviderType, map[string]string, error)

GetStorageProviderAndOverrides returns the storage provider type and any flags specified on the command line which are storage provider specific.

func GroupsAllowedCategories

func GroupsAllowedCategories() map[string]struct{}

func HasNoFlagsAndShownHelp

func HasNoFlagsAndShownHelp(cmd *cobra.Command) bool

HasNoFlagsAndShownHelp shows the Help output if no flags were provided to the command. Returns true if the help was shown. Use for when the non-flagged usage of a command (ex: corso backup restore exchange) is expected to no-op.

func HideCommand

func HideCommand() cmdOpt

func IncludeExchangeRestoreDataSelectors

func IncludeExchangeRestoreDataSelectors(opts ExchangeOpts) *selectors.ExchangeRestore

IncludeExchangeRestoreDataSelectors builds the common data-selector inclusions for exchange commands.

func IncludeGroupsRestoreDataSelectors

func IncludeGroupsRestoreDataSelectors(ctx context.Context, opts GroupsOpts) *selectors.GroupsRestore

IncludeGroupsRestoreDataSelectors builds the common data-selector inclusions for Group commands.

func IncludeOneDriveRestoreDataSelectors

func IncludeOneDriveRestoreDataSelectors(opts OneDriveOpts) *selectors.OneDriveRestore

IncludeOneDriveRestoreDataSelectors builds the common data-selector inclusions for OneDrive commands.

func IncludeSharePointRestoreDataSelectors

func IncludeSharePointRestoreDataSelectors(ctx context.Context, opts SharePointOpts) *selectors.SharePointRestore

IncludeSharePointRestoreDataSelectors builds the common data-selector inclusions for SharePoint commands.

func IncludeTeamsChatsRestoreDataSelectors

func IncludeTeamsChatsRestoreDataSelectors(ctx context.Context, opts TeamsChatsOpts) *selectors.TeamsChatsRestore

IncludeTeamsChatsRestoreDataSelectors builds the common data-selector inclusions for teamschats commands.

func IsValidBool

func IsValidBool(in string) bool

IsValidTimeFormat returns true if the input is recognized as a boolean.

func IsValidTimeFormat

func IsValidTimeFormat(in string) bool

IsValidTimeFormat returns true if the input is recognized as a supported format by the common time parser.

func MakeAbsoluteFilePath

func MakeAbsoluteFilePath(p string) (string, error)

MakeAbsoluteFilePath does directory path expansions & conversions, namely: 1. Expands "~" prefix to the user's home directory, and converts to absolute path. 2. Relative paths are converted to absolute paths. 3. Absolute paths are returned as-is. 4. Empty paths are not allowed, an error is returned.

func MakeExportConfig

func MakeExportConfig(
	ctx context.Context,
	opts ExportCfgOpts,
) control.ExportConfig

func MakeRestoreConfig

func MakeRestoreConfig(
	ctx context.Context,
	opts RestoreCfgOpts,
) control.RestoreConfig

func MakeRetentionOpts

func MakeRetentionOpts(cmd *cobra.Command) (repository.Retention, error)

func MarkDebugCommand

func MarkDebugCommand() cmdOpt

func MarkPreReleaseCommand

func MarkPreReleaseCommand() cmdOpt

func MarkPreviewCommand

func MarkPreviewCommand() cmdOpt

func ParseBackupOptions

func ParseBackupOptions() control.BackupConfig

func SharePointAllowedCategories

func SharePointAllowedCategories() map[string]struct{}

func TeamsChatsAllowedCategories

func TeamsChatsAllowedCategories() map[string]struct{}

func UsersMap

func UsersMap(
	ctx context.Context,
	acct account.Account,
	co control.Options,
	counter *count.Bus,
	errs *fault.Bus,
) (idname.Cacher, error)

UsersMap retrieves all users in the tenant and returns them in an idname.Cacher

func ValidateExchangeRestoreFlags

func ValidateExchangeRestoreFlags(backupID string, opts ExchangeOpts) error

ValidateExchangeRestoreFlags checks common flags for correctness and interdependencies

func ValidateExportConfigFlags

func ValidateExportConfigFlags(opts *ExportCfgOpts, acceptedFormatTypes []string) error

ValidateExportConfigFlags ensures all export config flags that utilize enumerated values match a well-known value.

func ValidateGroupsRestoreFlags

func ValidateGroupsRestoreFlags(backupID string, opts GroupsOpts, isRestore bool) error

ValidateGroupsRestoreFlags checks common flags for correctness and interdependencies

func ValidateOneDriveRestoreFlags

func ValidateOneDriveRestoreFlags(backupID string, opts OneDriveOpts) error

ValidateOneDriveRestoreFlags checks common flags for correctness and interdependencies

func ValidateRestoreConfigFlags

func ValidateRestoreConfigFlags(opts RestoreCfgOpts) error

ValidateRestoreConfigFlags checks common restore flags for correctness and interdependencies.

func ValidateSharePointRestoreFlags

func ValidateSharePointRestoreFlags(backupID string, opts SharePointOpts) error

ValidateSharePointRestoreFlags checks common flags for correctness and interdependencies

func ValidateTeamsChatsRestoreFlags

func ValidateTeamsChatsRestoreFlags(backupID string, opts TeamsChatsOpts, isRestore bool) error

ValidateTeamsChatsRestoreFlags checks common flags for correctness and interdependencies

Types

type ExchangeOpts

type ExchangeOpts struct {
	Users []string

	Contact       []string
	ContactFolder []string
	ContactName   string

	Email               []string
	EmailFolder         []string
	EmailReceivedAfter  string
	EmailReceivedBefore string
	EmailSender         string
	EmailSubject        string

	Event             []string
	EventCalendar     []string
	EventOrganizer    string
	EventRecurs       string
	EventStartsAfter  string
	EventStartsBefore string
	EventSubject      string

	RestoreCfg RestoreCfgOpts
	ExportCfg  ExportCfgOpts

	Populated flags.PopulatedFlags
}

func MakeExchangeOpts

func MakeExchangeOpts(cmd *cobra.Command) ExchangeOpts

populates an ExchangeOpts struct with the command's current flags.

type ExportCfgOpts

type ExportCfgOpts struct {
	Archive bool
	Format  string

	Populated flags.PopulatedFlags
}

type GroupsOpts

type GroupsOpts struct {
	Groups        []string
	Channels      []string
	Messages      []string
	Conversations []string
	Posts         []string

	MessageCreatedAfter    string
	MessageCreatedBefore   string
	MessageLastReplyAfter  string
	MessageLastReplyBefore string

	SiteID             []string
	WebURL             []string
	Library            string
	FileName           []string // for libraries, to duplicate onedrive interface
	FolderPath         []string // for libraries, to duplicate onedrive interface
	FileCreatedAfter   string
	FileCreatedBefore  string
	FileModifiedAfter  string
	FileModifiedBefore string

	Lists []string

	PageFolder []string
	Page       []string

	RestoreCfg RestoreCfgOpts
	ExportCfg  ExportCfgOpts

	Populated flags.PopulatedFlags
}

func MakeGroupsOpts

func MakeGroupsOpts(cmd *cobra.Command) GroupsOpts

func (GroupsOpts) GetFileTimeField

func (g GroupsOpts) GetFileTimeField(flag string) string

type OneDriveOpts

type OneDriveOpts struct {
	Users []string

	FileName           []string
	FolderPath         []string
	FileCreatedAfter   string
	FileCreatedBefore  string
	FileModifiedAfter  string
	FileModifiedBefore string

	RestoreCfg RestoreCfgOpts
	ExportCfg  ExportCfgOpts

	Populated flags.PopulatedFlags
}

func MakeOneDriveOpts

func MakeOneDriveOpts(cmd *cobra.Command) OneDriveOpts

type RepoDetailsAndOpts

type RepoDetailsAndOpts struct {
	Repo config.RepoDetails
	Opts control.Options
}

func GetAccountAndConnect

func GetAccountAndConnect(
	ctx context.Context,
	cmd *cobra.Command,
	pst path.ServiceType,
) (repository.Repositoryer, RepoDetailsAndOpts, error)

GetAccountAndConnect is a wrapper for GetAccountAndConnectWithOverrides that automatically gets the storage provider and any storage provider specific flag overrides from the command line.

func GetAccountAndConnectWithOverrides

func GetAccountAndConnectWithOverrides(
	ctx context.Context,
	pst path.ServiceType,
	provider storage.ProviderType,
	overrides map[string]string,
) (repository.Repositoryer, RepoDetailsAndOpts, error)

type RestoreCfgOpts

type RestoreCfgOpts struct {
	Collisions  string
	Destination string
	// DTTMFormat is the timestamp format appended
	// to the default folder name.  Defaults to
	// dttm.HumanReadable.
	DTTMFormat        dttm.TimeFormat
	ProtectedResource string
	SkipPermissions   bool

	Populated flags.PopulatedFlags
}

type SharePointOpts

type SharePointOpts struct {
	SiteID []string
	WebURL []string

	Library            string
	FileName           []string // for libraries, to duplicate onedrive interface
	FolderPath         []string // for libraries, to duplicate onedrive interface
	FileCreatedAfter   string
	FileCreatedBefore  string
	FileModifiedAfter  string
	FileModifiedBefore string

	Lists              []string
	ListModifiedAfter  string
	ListModifiedBefore string
	ListCreatedBefore  string
	ListCreatedAfter   string

	PageFolder []string
	Page       []string

	RestoreCfg RestoreCfgOpts
	ExportCfg  ExportCfgOpts

	Populated flags.PopulatedFlags
}

func MakeSharePointOpts

func MakeSharePointOpts(cmd *cobra.Command) SharePointOpts

func (SharePointOpts) GetFileTimeField

func (s SharePointOpts) GetFileTimeField(flag string) string

type TeamsChatsOpts

type TeamsChatsOpts struct {
	Users []string

	ExportCfg ExportCfgOpts

	Populated flags.PopulatedFlags
}

func MakeTeamsChatsOpts

func MakeTeamsChatsOpts(cmd *cobra.Command) TeamsChatsOpts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL