Documentation ¶
Index ¶
- Variables
- func AuthFromConfig(authCfg *config.GitRepoAuth) (transport.AuthMethod, error)
- func AuthViaUsernamePassword(username, password string) transport.AuthMethod
- func FSWrap(fs vfs.FileSystem) billy.Filesystem
- func FWrap(fs vfs.File) billy.File
- func K8SyncerAuthor() *object.Signature
- type DummyRemote
- type FSWrapper
- func (fsw *FSWrapper) Chroot(path string) (billy.Filesystem, error)
- func (fsw *FSWrapper) Create(filename string) (billy.File, error)
- func (fsw *FSWrapper) Join(elem ...string) string
- func (fsw *FSWrapper) Lstat(filename string) (os.FileInfo, error)
- func (fsw *FSWrapper) Open(filename string) (billy.File, error)
- func (fsw *FSWrapper) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)
- func (fsw *FSWrapper) ReadDir(path string) ([]os.FileInfo, error)
- func (fsw *FSWrapper) Rename(oldpath, newpath string) error
- func (fsw *FSWrapper) Root() string
- func (fsw *FSWrapper) Stat(filename string) (os.FileInfo, error)
- func (fsw *FSWrapper) TempFile(dir string, prefix string) (billy.File, error)
- type FWrapper
- type GitRepo
- func (r *GitRepo) Commit(log logging.Logger, msg string, paths ...string) (bool, error)
- func (r *GitRepo) CommitAndPush(log logging.Logger, pullBefore bool, msg string, paths ...string) error
- func (r *GitRepo) Initialize(log logging.Logger) error
- func (r *GitRepo) IsInitialized() bool
- func (r *GitRepo) Pull(log logging.Logger) error
- func (r *GitRepo) Push(log logging.Logger, pullBefore bool) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotInitialized = fmt.Errorf("git repo is not initialized, call repo.Initialize first")
Functions ¶
func AuthFromConfig ¶
func AuthFromConfig(authCfg *config.GitRepoAuth) (transport.AuthMethod, error)
func AuthViaUsernamePassword ¶
func AuthViaUsernamePassword(username, password string) transport.AuthMethod
func FSWrap ¶
func FSWrap(fs vfs.FileSystem) billy.Filesystem
func K8SyncerAuthor ¶
K8SyncerAuthor returns a dummy signature object which is used for commits.
Types ¶
type DummyRemote ¶
type DummyRemote struct { RootPath string Branch string Fs vfs.FileSystem GitFs vfs.FileSystem Repo *git.Repository // contains filtered or unexported fields }
DummyRemote is a helper struct to spin up a local git repository which can be used as remote for integration testing.
func NewDummyRemote ¶
func NewDummyRemote(fs vfs.FileSystem, branch string) (*DummyRemote, error)
func (*DummyRemote) Close ¶
func (dr *DummyRemote) Close() error
Close deletes the directory containing the remote.
func (*DummyRemote) NewRepo ¶
func (dr *DummyRemote) NewRepo() (*GitRepo, error)
NewRepo returns a new GitRepo configured for the dummy remote. The repository uses a temporary directory on the remote's filesystem and is already initialized.
type FSWrapper ¶
type FSWrapper struct {
vfs.FileSystem
}
FSWrapper is a helper struct to map the billy.Filesystem interface to an underlying vfs.FileSystem
type FWrapper ¶
FWrapper is a helper struct to map the billy.File interface to an underlying vfs.File
type GitRepo ¶
type GitRepo struct { // URL is the git repo URL. URL string // Branch is the branch of the repo which should be used. Branch string // LocalPath is the filesystem path where the repo should be checked out to. LocalPath string // Auth is the authentification information for the git repository. Auth transport.AuthMethod // SecondaryAuth is the secondary authentification information for the git repository. It is used if the first one failed and may be nil. SecondaryAuth transport.AuthMethod // Fs is the filesystem used for the repository. Fs vfs.FileSystem // contains filtered or unexported fields }
GitRepo is a helper struct which abstracts from the git commands. Use NewRepo to instantiate this struct.
func NewRepo ¶
func NewRepo(baseFs vfs.FileSystem, url, branch, localPath string, auth, secondaryAuth transport.AuthMethod) (*GitRepo, error)
NewRepo creates a new GitRepo instance, which can be used to interact with a git repository. Note that this only initializes the struct, in order to perform any git actions on the repository, Initialize has to be called first. The GitRepo uses a projection filesystem projecting to the given localPath. This means that all operations on the returned GitRepo's filesystem have to treat the repository directory as root.
func (*GitRepo) Commit ¶
Commit builds a commit containing the specified paths or all changes, if empty. It does not push. If the commit message is empty, a generic one is generated. If there are no changes staged after adding the specified paths, commit aborts early. The first return value determines whether a commit has actually been made (true = there is an unpushed commit).
func (*GitRepo) CommitAndPush ¶
func (r *GitRepo) CommitAndPush(log logging.Logger, pullBefore bool, msg string, paths ...string) error
CommitAndPush is the same as Commit + Push, but it keeps the lock for both commands, preventing other git commands from being executed in between both commands. It pushes only if Commit returns (true, nil).
func (*GitRepo) Initialize ¶
Initialize opens the repository if it exists and clones it otherwise.