m365

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResourceLookup = clues.New("missing resource lookup client")

Functions

This section is empty.

Types

type Controller

type Controller struct {
	AC api.Client

	// IDNameLookup's one write (inside PopulateProtectedResourceIDAndName)
	// is guarded by mu too, but it has no concurrent production reader to
	// race against: ProduceBackupCollections (internal/m365/backup.go),
	// the one call site that used to read this field, now builds its own
	// value from BackupProducerConfig.ProtectedResource instead - the
	// same resource this field is populated from for a single backup
	// operation, but without touching shared state. A -race run
	// (TestControllerConcurrency_ProduceBackupCollectionsAndPopulate,
	// controller_race_test.go) found exactly this read racing against
	// PopulateProtectedResourceIDAndName's write before that change.
	//
	// That test is kept as a permanent regression guard for the read
	// side, not the write side: with no concurrent reader of
	// IDNameLookup left in this fork, -race cannot detect an unguarded
	// write to it alone, so removing mu's protection from
	// PopulateProtectedResourceIDAndName's write would not be caught by
	// this test today. What it does catch is ProduceBackupCollections
	// (or anything else) reintroducing a direct, unguarded read of
	// IDNameLookup - the exact regression it was written to prevent.
	//
	// Maps of resource owner ids to names, and names to ids. Not
	// guaranteed to be populated, only here as a post-population
	// reference for processes that choose to populate the values.
	IDNameLookup idname.Cacher
	// contains filtered or unexported fields
}

Controller is a struct used to wrap the GraphServiceClient and GraphRequestAdapter from the msgraph-sdk-go. Additional fields are for bookkeeping and interfacing with other component.

func NewController

func NewController(
	ctx context.Context,
	acct account.Account,
	pst path.ServiceType,
	co control.Options,
	counter *count.Bus,
) (*Controller, error)

func (*Controller) CacheItemInfo

func (ctrl *Controller) CacheItemInfo(dii details.ItemInfo)

func (*Controller) DeserializeMetadataFiles

func (ctrl *Controller) DeserializeMetadataFiles(
	ctx context.Context,
	colls []data.RestoreCollection,
) ([]store.MetadataFile, error)

func (*Controller) EnsureResourceHandler

func (ctrl *Controller) EnsureResourceHandler(serviceInOperation path.ServiceType)

EnsureResourceHandler re-derives this controller's resource lookup handler for serviceInOperation, overwriting whatever it was set to before. Safe to call concurrently with itself and with PopulateProtectedResourceIDAndName/NewServiceHandler on the same Controller - see mu's doc comment on the struct.

A Controller is created once per repository connection and, in pkg/repository's connectToM365, reused across every later call to ConnectDataProvider on that same repository - which happens once per backup, restore or export, each potentially naming a different service, and, in k3ep's long-lived-worker shape, potentially concurrently with another such call on the same connection. Without this, a Controller first created for one service (or for path.UnknownService, which chunk 0.6's pkg/engine passes while opening a repository before any backup has chosen a service yet) keeps that service's resource handler forever, and PopulateProtectedResourceIDAndName panics on a nil handler the first time a later call asks for a different service. Confirmed live against the test tenant: pkg/engine opens a repository (which connects a provider for path.UnknownService, since no service is known yet) and then calls Backup with an Exchange selector, which panicked on exactly this before this fix.

func (*Controller) GetMetadataPaths

func (ctrl *Controller) GetMetadataPaths(
	ctx context.Context,
	r kinject.RestoreProducer,
	base inject.ReasonAndSnapshotIDer,
	errs *fault.Bus,
) ([]path.RestorePaths, error)

func (*Controller) IsServiceEnabled

func (ctrl *Controller) IsServiceEnabled(
	ctx context.Context,
	service path.ServiceType,
	resourceOwner string,
) (bool, error)

func (*Controller) NewServiceHandler

func (ctrl *Controller) NewServiceHandler(
	service path.ServiceType,
) (inject.ServiceHandler, error)

NewServiceHandler returns an instance of a struct capable of running various operations for a given service.

func (*Controller) PopulateProtectedResourceIDAndName

func (ctrl *Controller) PopulateProtectedResourceIDAndName(
	ctx context.Context,
	resourceID string,
	ins idname.Cacher,
) (idname.Provider, error)

PopulateProtectedResourceIDAndName takes the provided owner identifier and produces the owner's name and ID from that value. Returns an error if the owner is not recognized by the current tenant.

The id-name cacher is optional. Some processes will look up all owners in the tenant before reaching this step. In that case, the data gets handed down for this func to consume instead of performing further queries. The data gets stored inside the controller instance for later re-use.

func (*Controller) PrintableStatus

func (ctrl *Controller) PrintableStatus() string

PrintableStatus returns a string formatted version of the status.

func (*Controller) ProduceBackupCollections

func (ctrl *Controller) ProduceBackupCollections(
	ctx context.Context,
	bpc inject.BackupProducerConfig,
	counter *count.Bus,
	errs *fault.Bus,
) ([]data.BackupCollection, prefixmatcher.StringSetReader, bool, error)

ProduceBackupCollections generates a slice of data.BackupCollections for the service specified in the selectors. The metadata field can include things like delta tokens or the previous backup's folder hierarchy. The absence of metadata causes the collection creation to ignore prior history (ie, incrementals) and run a full backup.

func (*Controller) SetRateLimiter

func (ctrl *Controller) SetRateLimiter(
	ctx context.Context,
	service path.ServiceType,
	options control.Options,
) context.Context

func (*Controller) Status

Status returns the current status of the controller process.

func (*Controller) UpdateStatus

func (ctrl *Controller) UpdateStatus(status *support.ControllerOperationStatus)

UpdateStatus is used by initiated tasks to indicate completion

func (*Controller) VerifyAccess

func (ctrl *Controller) VerifyAccess(ctx context.Context) error

func (*Controller) Wait

func (ctrl *Controller) Wait() *data.CollectionStats

AwaitStatus waits for all tasks to complete and then returns status

Directories

Path Synopsis
collection
exchange
Package exchange provides support for retrieving M365 Exchange objects from M365 servers using the Graph API.
Package exchange provides support for retrieving M365 Exchange objects from M365 servers using the Graph API.
service

Jump to

Keyboard shortcuts

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