Documentation ¶
Index ¶
- Variables
- func AutogitTLFListDir(tlfType tlf.Type) string
- func CleanOldDeletedRepos(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle) (err error)
- func CleanOldDeletedReposTimeLimited(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle) error
- func DeleteRepo(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, ...) error
- func GCRepo(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, ...) (err error)
- func Init(ctx context.Context, gitKBFSParams libkbfs.InitParams, kbCtx libkbfs.Context, ...) (context.Context, libkbfs.Config, error)
- func LastGCTime(ctx context.Context, fs billy.Filesystem) (time.Time, error)
- func NeedsGC(storage storage.Storer, options GCOptions) (doPackRefs bool, numLooseRefs int, doPruneLoose, doObjectRepack bool, ...)
- func Params(kbCtx libkbfs.Context, storageRoot string, paramsBase *libkbfs.InitParams) (params libkbfs.InitParams, tempDir string, err error)
- func RenameRepo(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, ...) (err error)
- func Reset(ctx context.Context, repoFS billy.Filesystem, worktreeFS billy.Filesystem, ...) error
- func StartAutogit(kbCtx libkbfs.Context, config libkbfs.Config, ...) func()
- func UpdateRepoMD(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, ...) error
- type AutogitManager
- func (am *AutogitManager) BatchChanges(ctx context.Context, _ []libkbfs.NodeChange, affectedNodeIDs []libkbfs.NodeID)
- func (am *AutogitManager) Clone(ctx context.Context, srcTLF *libkbfs.TlfHandle, srcRepo, branchName string, ...) (doneCh <-chan struct{}, err error)
- func (am *AutogitManager) Delete(ctx context.Context, dstTLF *libkbfs.TlfHandle, dstDir string, ...) (doneCh <-chan struct{}, err error)
- func (am *AutogitManager) LocalChange(ctx context.Context, node libkbfs.Node, wr libkbfs.WriteRange)
- func (am *AutogitManager) Pull(ctx context.Context, srcTLF *libkbfs.TlfHandle, srcRepo, branchName string, ...) (doneCh <-chan struct{}, err error)
- func (am *AutogitManager) Shutdown()
- func (am *AutogitManager) TlfHandleChange(ctx context.Context, newHandle *libkbfs.TlfHandle)
- type Config
- type GCOptions
- type GitConfigWithoutRemotesStorer
- type ID
- func CreateRepoAndID(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, ...) (ID, error)
- func GetOrCreateRepoAndID(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, ...) (*libfs.FS, ID, error)
- func GetRepoAndID(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, ...) (*libfs.FS, ID, error)
- type InvalidIDError
- type OnDemandStorer
- type RPCHandler
- func (rh *RPCHandler) CreateRepo(ctx context.Context, arg keybase1.CreateRepoArg) (id keybase1.RepoID, err error)
- func (rh *RPCHandler) DeleteRepo(ctx context.Context, arg keybase1.DeleteRepoArg) (err error)
- func (rh *RPCHandler) Gc(ctx context.Context, arg keybase1.GcArg) (err error)
- func (rh *RPCHandler) RenameRepo(ctx context.Context, folder keybase1.Folder, oldName, newName string) (err error)
- type RefData
- type RefDataByName
Constants ¶
This section is empty.
Variables ¶
var CommitSentinelValue *object.Commit
CommitSentinelValue marks the end of a list of commits, where there are still commits that haven't been read. Use the zero-value `nil`.
var NullID = ID{}
NullID is an empty ID
Functions ¶
func AutogitTLFListDir ¶ added in v1.0.40
AutogitTLFListDir returns `.kbfs_autogit/<tlf_type>` where <tlf_type> is "private", "public", or "team" depending on tlfType.
func CleanOldDeletedRepos ¶
func CleanOldDeletedRepos( ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle) (err error)
CleanOldDeletedRepos completely removes any "deleted" repos that have been deleted for longer than `minDeletedAgeForCleaning`. The caller is responsible for syncing any data to disk, if desired.
func CleanOldDeletedReposTimeLimited ¶
func CleanOldDeletedReposTimeLimited( ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle) error
CleanOldDeletedReposTimeLimited is the same as `CleanOldDeletedRepos`, except it limits the time spent on cleaning, deleting as much data as possible within the given time limit (without returning an error).
func DeleteRepo ¶
func DeleteRepo( ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, repoName string) error
DeleteRepo "deletes" the given repo in the given TLF. Right now it simply moves the repo out of the way to a special directory, to allow any concurrent writers to finish their pushes without triggering conflict resolution. The caller is responsible for syncing the FS and flushing the journal, if desired. It expects the `config` object to be unique during the lifetime of this call.
func GCRepo ¶
func GCRepo( ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, repoName string, options GCOptions) (err error)
GCRepo runs garbage collection on the specified repo, if it exceeds any of the thresholds provided in `options`.
func Init ¶
func Init(ctx context.Context, gitKBFSParams libkbfs.InitParams, kbCtx libkbfs.Context, keybaseServiceCn libkbfs.KeybaseServiceCn, defaultLogPath string) (context.Context, libkbfs.Config, error)
Init initializes a context and a libkbfs.Config for git operations. The config should be shutdown when it is done being used.
func LastGCTime ¶
LastGCTime returns the last time the repo was successfully garbage-collected.
func NeedsGC ¶
func NeedsGC(storage storage.Storer, options GCOptions) ( doPackRefs bool, numLooseRefs int, doPruneLoose, doObjectRepack bool, numObjectPacks int, err error)
NeedsGC checks the given repo storage layer against the given options to see what kinds of GC are needed on the repo.
func Params ¶
func Params(kbCtx libkbfs.Context, storageRoot string, paramsBase *libkbfs.InitParams) ( params libkbfs.InitParams, tempDir string, err error)
Params returns a set of default parameters for git-related operations, along with a temp directory that should be cleaned after the git work is complete.
func RenameRepo ¶
func RenameRepo( ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, oldRepoName, newRepoName string) (err error)
RenameRepo renames the repo from an old name to a new name. It leaves a symlink behind so that old remotes will continue to work. The caller is responsible for syncing the FS and flushing the journal, if desired.
func Reset ¶ added in v1.0.40
func Reset( ctx context.Context, repoFS billy.Filesystem, worktreeFS billy.Filesystem, branch plumbing.ReferenceName) error
Reset checks out a repo from a billy filesystem, into another billy filesystem. However, it doesn't make a true git clone, for two reasons.
- This will be used to clone KBFS repos, and go-git doesn't natively understand the keybase:// protocol. There might be a way around this with the `InstallProtocol` go-git method, but I haven't investigated that yet and it would be some extra work.
- These clones are intended for autogit, which will display them as read-only directories. They do not need to be real git repos, and so there's no need to copy object files or much else in the .git repo. All we really need is an index, to compute the differences. Making a full git clone, or even a "shallow" git clone, would be wasteful in that it would read and write way more data than we really need.
The resulting checkout in `worktreeFS` is therefore not a functional git repo. The caller should only interact with `worktreeFS` in a read-only way, and should not attempt any git operations on it.
func StartAutogit ¶ added in v1.0.40
func StartAutogit(kbCtx libkbfs.Context, config libkbfs.Config, kbfsInitParams *libkbfs.InitParams, numWorkers int) func()
StartAutogit launches autogit, and returns a function that should be called on shutdown.
func UpdateRepoMD ¶
func UpdateRepoMD(ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, fs billy.Filesystem, pushType keybase1.GitPushType, oldRepoName string, refDataByName RefDataByName) error
UpdateRepoMD lets the Keybase service know that a repo's MD has been updated.
Types ¶
type AutogitManager ¶ added in v1.0.40
type AutogitManager struct {
// contains filtered or unexported fields
}
AutogitManager can clone and pull source git repos into a destination folder, potentially across different TLFs. New requests for an operation in a destination repo are blocked by any ongoing requests for the same folder, and multiple outstanding requests for the same destination folder get rolled up into one.
func NewAutogitManager ¶ added in v1.0.40
func NewAutogitManager( config libkbfs.Config, kbCtx libkbfs.Context, kbfsInitParams *libkbfs.InitParams, numWorkers int) *AutogitManager
NewAutogitManager constructs a new AutogitManager instance, and launches `numWorkers` processing goroutines in the background.
func (*AutogitManager) BatchChanges ¶ added in v1.0.40
func (am *AutogitManager) BatchChanges( ctx context.Context, _ []libkbfs.NodeChange, affectedNodeIDs []libkbfs.NodeID)
BatchChanges implements the libkbfs.Observer interface for AutogitManager.
func (*AutogitManager) Clone ¶ added in v1.0.40
func (am *AutogitManager) Clone( ctx context.Context, srcTLF *libkbfs.TlfHandle, srcRepo, branchName string, dstTLF *libkbfs.TlfHandle, dstDir string) ( doneCh <-chan struct{}, err error)
Clone queues a request to clone the `branchName` branch of the `srcRepo` repo from the TLF `srcTLF`, into a subdirectory named `dstDir/srcRepo` in the TLF `dstTLF`. `dstDir` must already exist in `dstTLF`.
It returns a channel that, when closed, indicates the clone request has finished (though not necessarily successfully). The caller may have to sync from the server to ensure they are see the changes, however.
If the cloned directory doesn't exist yet, this function creates a placeholder "CLONING" file to let users know the clone is happening in the background.
Note that if there's already data in `dstDir/srcRepo`, this tramples it, so the caller must ensure that they are requesting a clone from the same repo/branch as the existing repo that might have already been there.
If the caller specifies a non-master `branchName`, they should make sure `dstDir` is unique for that branch; i.e., the branch name should appear in the path somewhere.
func (*AutogitManager) Delete ¶ added in v1.0.40
func (am *AutogitManager) Delete( ctx context.Context, dstTLF *libkbfs.TlfHandle, dstDir string, repo, branchName string) (doneCh <-chan struct{}, err error)
Delete queues a request to delete an autogit destination subdir named `dstDir/srcRepo` in the TLF `dstTLF`.
It returns a channel that, when closed, indicates the pull request has finished (though not necessarily successfully). The caller may have to sync from the server to ensure they are see the changes, however.
func (*AutogitManager) LocalChange ¶ added in v1.0.40
func (am *AutogitManager) LocalChange( ctx context.Context, node libkbfs.Node, wr libkbfs.WriteRange)
LocalChange implements the libkbfs.Observer interface for AutogitManager.
func (*AutogitManager) Pull ¶ added in v1.0.40
func (am *AutogitManager) Pull( ctx context.Context, srcTLF *libkbfs.TlfHandle, srcRepo, branchName string, dstTLF *libkbfs.TlfHandle, dstDir string) ( doneCh <-chan struct{}, err error)
Pull queues a request to pull the `branchName` branch of the `srcRepo` repo from the TLF `srcTLF`, into a subdirectory named `dstDir/srcRepo` in the TLF `dstTLF`. `dstDir/srcRepo` must already exist in `dstTLF`.
It returns a channel that, when closed, indicates the pull request has finished (though not necessarily successfully). The caller may have to sync from the server to ensure they are see the changes, however.
Note that this tramples any data that was previously in `dstDir/srcRepo`, so the caller must ensure that they are requesting a pull from the correct repo/branch as the existing repo that was already there.
If the caller specifies a non-master `branchName`, they should make sure `dstDir` is unique for that branch; i.e., the branch name should appear in the path somewhere.
func (*AutogitManager) Shutdown ¶ added in v1.0.40
func (am *AutogitManager) Shutdown()
Shutdown shuts down this manager.
func (*AutogitManager) TlfHandleChange ¶ added in v1.0.40
func (am *AutogitManager) TlfHandleChange( ctx context.Context, newHandle *libkbfs.TlfHandle)
TlfHandleChange implements the libkbfs.Observer interface for AutogitManager.
type Config ¶
type Config struct { ID ID Name string // the original user-supplied format of the name CreatorUID string Ctime int64 // create time in unix nanoseconds, by creator's clock }
Config is a KBFS git repo config file.
type GCOptions ¶
type GCOptions struct { // The most loose refs we will tolerate; if there are more loose // refs, we should pack them. MaxLooseRefs int // The minimum number of potentially-expired loose objects we need // to start the pruning process. If < 0, pruning will not be done. PruneMinLooseObjects int // Any unreachable objects older than this time are subject to // pruning. PruneExpireTime time.Time // The most object packs we will tolerate; if there are more // object packs, we should re-pack all the objects. If < 0, // re-packing will not be done. MaxObjectPacks int }
GCOptions describe options foe garbage collection.
type GitConfigWithoutRemotesStorer ¶
type GitConfigWithoutRemotesStorer struct { *filesystem.Storage // contains filtered or unexported fields }
GitConfigWithoutRemotesStorer strips remotes from the config before writing them to disk, to work around a gcfg bug (used by go-git when reading configs from disk) that causes a freakout when it sees backslashes in git file URLs.
func NewGitConfigWithoutRemotesStorer ¶
func NewGitConfigWithoutRemotesStorer(fs *libfs.FS) ( *GitConfigWithoutRemotesStorer, error)
NewGitConfigWithoutRemotesStorer creates a new git config implementation that strips remotes from the config before writing them to disk.
func (*GitConfigWithoutRemotesStorer) Config ¶
func (cwrs *GitConfigWithoutRemotesStorer) Config() (*gogitcfg.Config, error)
Config implements the `storer.Storer` interface.
func (*GitConfigWithoutRemotesStorer) Init ¶
func (cwrs *GitConfigWithoutRemotesStorer) Init() error
Init implements the `storer.Initializer` interface.
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID encapsulates a repo ID.
func CreateRepoAndID ¶
func CreateRepoAndID( ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, repoName string) (ID, error)
CreateRepoAndID returns a new stable repo ID for the provided repoName in the given TLF. If the repo has already been created, it returns a `RepoAlreadyExistsError`. If `repoName` already exists, but is a symlink to another renamed directory, the symlink will be removed in favor of the new repo. The caller is responsible for syncing the FS and flushing the journal, if desired. It expects the `config` object to be unique during the lifetime of this call.
func GetOrCreateRepoAndID ¶
func GetOrCreateRepoAndID( ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, repoName string, uniqID string) (*libfs.FS, ID, error)
GetOrCreateRepoAndID returns a filesystem object rooted at the specified repo, along with the stable repo ID. If the repo hasn't been created yet, it generates a new ID and creates the repo. The caller is responsible for syncing the FS and flushing the journal, if desired.
func GetRepoAndID ¶
func GetRepoAndID( ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle, repoName string, uniqID string) (*libfs.FS, ID, error)
GetRepoAndID returns a filesystem object rooted at the specified repo, along with the stable repo ID, if it already exists.
func (ID) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface for ID.
func (ID) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for ID.
func (*ID) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for ID.
func (*ID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for ID.
type InvalidIDError ¶
type InvalidIDError struct {
// contains filtered or unexported fields
}
InvalidIDError indicates that a repo ID string is not parseable or invalid.
func (InvalidIDError) Error ¶
func (e InvalidIDError) Error() string
type OnDemandStorer ¶ added in v1.0.40
OnDemandStorer is a wrapper around a storage.Storer that reads encoded objects from disk only when the data is needed, to avoid pulling too much data into memory.
func NewOnDemandStorer ¶ added in v1.0.40
func NewOnDemandStorer(s storage.Storer) (*OnDemandStorer, error)
NewOnDemandStorer constructs an on-demand storage layer on top of an existing `Storer`.
func (*OnDemandStorer) DeltaObject ¶ added in v1.0.40
func (ods *OnDemandStorer) DeltaObject( ot plumbing.ObjectType, hash plumbing.Hash) ( plumbing.EncodedObject, error)
DeltaObject implements the storer.DeltaObjectStorer interface for OnDemandStorer.
func (*OnDemandStorer) EncodedObject ¶ added in v1.0.40
func (ods *OnDemandStorer) EncodedObject( ot plumbing.ObjectType, hash plumbing.Hash) ( plumbing.EncodedObject, error)
EncodedObject implements the storage.Storer interface for OnDemandStorer.
type RPCHandler ¶
type RPCHandler struct {
// contains filtered or unexported fields
}
RPCHandler handles service->KBFS git RPC calls.
func NewRPCHandlerWithCtx ¶
func NewRPCHandlerWithCtx(kbCtx libkbfs.Context, config libkbfs.Config, kbfsInitParams *libkbfs.InitParams) (*RPCHandler, func())
NewRPCHandlerWithCtx returns a new instance of a Git RPC handler.
func (*RPCHandler) CreateRepo ¶
func (rh *RPCHandler) CreateRepo( ctx context.Context, arg keybase1.CreateRepoArg) ( id keybase1.RepoID, err error)
CreateRepo implements keybase1.KBFSGitInterface for KeybaseServiceBase.
func (*RPCHandler) DeleteRepo ¶
func (rh *RPCHandler) DeleteRepo( ctx context.Context, arg keybase1.DeleteRepoArg) (err error)
DeleteRepo implements keybase1.KBFSGitInterface for KeybaseServiceBase.
func (*RPCHandler) RenameRepo ¶ added in v1.0.40
func (rh *RPCHandler) RenameRepo(ctx context.Context, folder keybase1.Folder, oldName, newName string) (err error)
RenameRepo renames an existing git repository.
TODO: Hook this up to an RPC.
type RefDataByName ¶ added in v1.0.40
type RefDataByName map[plumbing.ReferenceName]*RefData
RefDataByName represents a map of reference names to data about that ref.