Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorHandler ¶
type ErrorHandler interface { // InvalidModuleConfig is invoked by Syncer upon encountering a module // with an invalid module config. // // Returning an error will abort sync. InvalidModuleConfig( module Module, commit git.Commit, err error, ) error // BuildFailure is invoked by Syncer upon encountering a module that fails // build. // // Returning an error will abort sync. BuildFailure( module Module, commit git.Commit, err error, ) error // InvalidSyncPoint is invoked by Syncer upon encountering a module's branch // sync point that is invalid. A typical example is either a sync point that // point to a commit that cannot be found anymore, or the commit itself has // been corrupted. // // Returning an error will abort sync. InvalidSyncPoint( module Module, branch string, syncPoint git.Hash, err error, ) error // SyncPointNotEncountered is invoked by Syncer upon syncing a module on a // branch where a sync point was resolved and validated, but was not // encountered during sync. // // Returning an error will abort sync. SyncPointNotEncountered( module Module, branch string, syncPoint git.Hash, ) error }
ErrorHandler handles errors reported by the Syncer. If a non-nil error is returned by the handler, sync will abort in a partially-synced state.
type Module ¶
type Module interface { // Dir is the path to the module relative to the repository root. Dir() string // RemoteIdentity is the identity of the remote module that the // local module is synced to. RemoteIdentity() bufmoduleref.ModuleIdentity // String is the string representation of this module. String() string }
Module is a module that will be synced by Syncer.
func NewModule ¶
func NewModule(dir string, identityOverride bufmoduleref.ModuleIdentity) (Module, error)
NewModule constructs a new module that can be synced with a Syncer.
type ModuleCommit ¶
type ModuleCommit interface { // Identity is the identity of the module, accounting for any configured override. Identity() bufmoduleref.ModuleIdentity // Bucket is the bucket for the module. Bucket() storage.ReadBucket // Commit is the commit that the module is sourced from. Commit() git.Commit // Branch is the git branch that this module is sourced from. Branch() string // Tags are the git tags associated with Commit. Tags() []string }
ModuleCommit is a module at a particular commit.
type SyncFunc ¶
type SyncFunc func(ctx context.Context, commit ModuleCommit) error
SyncFunc is invoked by Syncer to process a sync point. If an error is returned, sync will abort.
type SyncPointResolver ¶ added in v1.22.0
type SyncPointResolver func( ctx context.Context, identity bufmoduleref.ModuleIdentity, branch string, ) (git.Hash, error)
SyncPointResolver is invoked by Syncer to resolve a syncpoint for a particular module at a particular branch. If no syncpoint is found, this function returns nil. If an error is returned, sync will abort.
type Syncer ¶
type Syncer interface { // Sync syncs the repository using the provided SyncFunc. It processes // commits in reverse topological order, loads any configured named // modules, extracts any Git metadata for that commit, and invokes // SyncFunc with a ModuleCommit. // // Only commits/branches belonging to the remote named 'origin' are // processed. All tags are processed. Sync(context.Context, SyncFunc) error }
Syncer syncs a modules in a git.Repository.
func NewSyncer ¶
func NewSyncer( logger *zap.Logger, repo git.Repository, storageGitProvider storagegit.Provider, errorHandler ErrorHandler, options ...SyncerOption, ) (Syncer, error)
NewSyncer creates a new Syncer.
type SyncerOption ¶
type SyncerOption func(*syncer) error
SyncerOption configures the creation of a new Syncer.
func SyncerWithModule ¶
func SyncerWithModule(module Module) SyncerOption
SyncerWithModule configures a Syncer to sync the specified module.
This option can be provided multiple times to sync multiple distinct modules.
func SyncerWithResumption ¶ added in v1.22.0
func SyncerWithResumption(resolver SyncPointResolver) SyncerOption
SyncerWithResumption configures a Syncer with a resumption using a SyncPointResolver.