Documentation ¶
Overview ¶
Package git contains routines for interacting with git over the CLI. Unlike go-git, this is not a pure go library for interacting with git, and relies on the git command line being available locally. This is meant to provide high level interfaces used throughout various Gruntwork CLIs.
NOTE: The tests for these packages are intentionally stored in a separate test folder, rather than the go converntional style of source_test.go files. This is done to ensure that the tests for the packages are run in a separate docker container, as many functions in this package pollute the global git configuration.
Index ¶
- func Checkout(logger *logrus.Entry, ref string, targetDir string) error
- func Clone(logger *logrus.Entry, repo string, targetDir string) error
- func ConfigureCacheCredentialsHelper(logger *logrus.Entry, options CacheCredentialOptions) error
- func ConfigureForceHTTPS(logger *logrus.Entry) error
- func ConfigureHTTPSAuth(logger *logrus.Entry, gitUsername string, gitOauthToken string, vcsHost string) error
- func StoreCacheCredentials(logger *logrus.Entry, gitUsername string, gitOauthToken string, vcsHost string, ...) error
- type CacheCredentialOptions
- type TargetDirectoryNotExistsErr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
Clone runs git clone to clone the specified repository into the given target directory.
func ConfigureCacheCredentialsHelper ¶ added in v0.12.3
func ConfigureCacheCredentialsHelper(logger *logrus.Entry, options CacheCredentialOptions) error
ConfigureCacheCredentialsHelper configures git globally to use the cache credentials helper for authentication based on the provided options configuration.
func ConfigureForceHTTPS ¶
ConfigureForceHTTPS configures git to force usage of https endpoints instead of SSH based endpoints for the three primary VCS platforms (GitHub, GitLab, BitBucket).
func ConfigureHTTPSAuth ¶
func ConfigureHTTPSAuth( logger *logrus.Entry, gitUsername string, gitOauthToken string, vcsHost string, ) error
ConfigureHTTPSAuth configures git with username and password to authenticate with the given VCS host when interacting with git over HTTPS. This uses the cache credentials store to configure the credentials. Refer to the git documentation on credentials storage for more information: https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage NOTE: this configures the cache credential helper globally, with a default timeout of 1 hour. If you want more control over the configuration, use the ConfigureCacheCredentialsHelper and StoreCacheCredentials functions directly.
func StoreCacheCredentials ¶ added in v0.12.3
func StoreCacheCredentials( logger *logrus.Entry, gitUsername string, gitOauthToken string, vcsHost string, vcsPath string, socketPath string, ) error
StoreCacheCredentials stores the given git credentials for the vcs host and path pair to the git credential-cache helper.
Types ¶
type CacheCredentialOptions ¶ added in v0.12.3
type CacheCredentialOptions struct { // Host is the VCS host where the cache credential helper should be triggered. // Set to "" if you want to apply the credential cache helper to all hosts. Host string // DefaultUsername is the default username to use when authenticating to the VCS host. DefaultUsername string // IncludeHTTPPath indicates whether to path through the git http path to the credential helper, enabling matching // with the path (e.g., the org/repo.git component of https://github.com/org/repo.git. IncludeHTTPPath bool // SocketPath configures the path to the Unix socket file to use to interact with the cache credential daemon. When // blank, uses the default path baked into the command: // https://git-scm.com/docs/git-credential-cache#_options // This is useful when you are configuring the cache for the same host across multiple paths, as the cache // credential helper is known to break when you have an entry for a specific path and the generic all hosts. SocketPath string // Timeout is the timeout in seconds for credentials in the cache. Timeout int }
CredentialOptions are the possible configurations options for configuring the git credential-cache helper.
type TargetDirectoryNotExistsErr ¶
type TargetDirectoryNotExistsErr struct {
// contains filtered or unexported fields
}
TargetDirectoryNotExistsErr is returned when the target directory of the git commands does not exist or is not a directory.
func (TargetDirectoryNotExistsErr) Error ¶
func (err TargetDirectoryNotExistsErr) Error() string