Documentation ¶
Index ¶
- func CommitFiles(repo *GitRepository, files []string, msg string, opts CommitOptions) (bool, error)
- func MemCloneGitRepo(url string, ref string, depth int, sshCred *SshCredentials) (*GitRepository, *MemoryStore, error)
- func PushChanges(hook PushPreHook, ref string, sshCred *SshCredentials, retries int64, ...) error
- func VerifyTopCommit(repo *GitRepository, armoredKeyrings []string) error
- type CommitOptions
- type CommitSignatureKey
- type GitRepository
- type MemoryStore
- type PushPreHook
- type SshCredentials
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommitFiles ¶
func CommitFiles(repo *GitRepository, files []string, msg string, opts CommitOptions) (bool, error)
Commits the given list of files in the git repository. If not changes are detected in the files provided, a commit will not be attempted.
func MemCloneGitRepo ¶ added in v0.5.0
func MemCloneGitRepo(url string, ref string, depth int, sshCred *SshCredentials) (*GitRepository, *MemoryStore, error)
Clone the given reference of a given repo in a memory filesystem. A reference to the generated filesystem as well as the repository is returned.
func PushChanges ¶
func PushChanges(hook PushPreHook, ref string, sshCred *SshCredentials, retries int64, retryInterval time.Duration) error
Takes a function argument that should return a git repository with changes to push if there are (and nil otherwise). From there, it will try to push the new commits in the repository to the given reference on origin. If there are conflicts during the push, it will keep retrying by re-invoking its function argument and push on the returned repository.
func VerifyTopCommit ¶
func VerifyTopCommit(repo *GitRepository, armoredKeyrings []string) error
Verifies that the top commit of a given git repository was signed by one of the keys that are passed in the argument. Returns an error if it isn't.
Types ¶
type CommitOptions ¶ added in v0.2.0
type CommitOptions struct { //Name of the commiter Name string //Email of the commiter Email string //Optional key used to signed the git commit SignatureKey *CommitSignatureKey }
Optional parameters to pass to the CommitFiles command
type CommitSignatureKey ¶ added in v0.4.0
Structure abstracting away openpgp.Entity structure needed by go-git to sign keys
func GetSignatureKey ¶ added in v0.4.0
func GetSignatureKey(signKeyPath string, passphrasePath string) (*CommitSignatureKey, error)
Produces a commit signature needed to sign a commit. Arguments are file paths to an armored private pgp key and optionally a passphrase to decrypt it if it is encrypted
type GitRepository ¶ added in v0.4.0
type GitRepository struct {
Repo *gogit.Repository
}
Structure abstracting away gogit.Repository structure needed by go-git to manipulate a git repository
func SyncGitRepo ¶
func SyncGitRepo(dir string, url string, ref string, sshCred *SshCredentials) (*GitRepository, bool, error)
Clone or pull the given reference of a given repo at a given path on the filesystem. If the repo was previously cloned at the path, a pull will be done, else a clone.
type MemoryStore ¶ added in v0.5.0
type MemoryStore struct { Fs *billy.Filesystem // contains filtered or unexported fields }
Container for a memory store. It used to keep a reference to the store and clear it as needed. The Fs property is a pointer to a billy.Filesystem that can be used to intereract with the filesystem in memory
func (*MemoryStore) Clear ¶ added in v0.5.0
func (mem *MemoryStore) Clear()
Frees the references to the memory store, allowing the garbage collector to collect it.
func (*MemoryStore) GetKeyVals ¶ added in v0.5.0
func (mem *MemoryStore) GetKeyVals(sourcePath string) (map[string]string, error)
Returns all the files in the memory filesystem thet fall under a given source path as a map where the keys are the relative path of each file (relative to the specified source path) and the value is their content. You can pass the empty string as a source path if you wish to return the entire content of the memory filesystem.
type PushPreHook ¶
type PushPreHook func() (*GitRepository, error)
Function signature meant to be passed as an argument to the PushChanges function. It should return a git repository with changes to push if there are changes to push otherwise it should return nil. The function should be idempotent as it might be called repeatedly if there is a conflict during the push
type SshCredentials ¶ added in v0.4.0
type SshCredentials struct {
Keys *ssh.PublicKeys
}
Structure abstracting away ssh.PublicKeys structure needed by go-git to authenticate with git server
func GetSshCredentials ¶ added in v0.4.0
func GetSshCredentials(sshKeyPath string, knownHostsPath string) (*SshCredentials, error)
Produces ssh credentials needed by go-git to clone/pull a remote repository and push to it. Arguments are file paths to the private ssh key of the user and ssh host key fingerprint of the git server.