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.
InvalidModuleConfig(
module string,
commit git.Commit,
err error,
) error
// BuildFailure is invoked by Syncer upon encountering a module that fails
// build.
BuildFailure(
module string,
moduleIdentity bufmoduleref.ModuleIdentity,
commit git.Commit,
err error,
) 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
// IdentityOverride is an optional module identity override. If empty,
// the identity specified in the module config file will be used.
//
// Unnamed modules will not have their identity overridden, as they are
// not pushable.
IdentityOverride() bufmoduleref.ModuleIdentity
}
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.
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.