Documentation
¶
Index ¶
- func CloneRepo(ctx context.Context, logf func(string, ...any), opts CloneRepoOptions) (bool, error)
- func DecodeBase64PrivateKey(key string) (gossh.Signer, error)
- func LogHostKeyCallback(logger func(string, ...any)) gossh.HostKeyCallback
- func ProgressWriter(write func(line string, args ...any)) io.WriteCloser
- func ReadPrivateKey(path string) (gossh.Signer, error)
- func SetupRepoAuth(logf func(string, ...any), options *options.Options) transport.AuthMethod
- func ShallowCloneRepo(ctx context.Context, logf func(string, ...any), opts CloneRepoOptions) error
- type CloneRepoOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneRepo ¶
CloneRepo will clone the repository at the given URL into the given path. If a repository is already initialized at the given path, it will not be cloned again.
The bool returned states whether the repository was cloned or not.
func DecodeBase64PrivateKey ¶ added in v1.0.4
DecodeBase64PrivateKey attempts to decode a base64 encoded private key and returns an ssh.Signer
func LogHostKeyCallback ¶
func LogHostKeyCallback(logger func(string, ...any)) gossh.HostKeyCallback
LogHostKeyCallback is a HostKeyCallback that just logs host keys and does nothing else.
func ProgressWriter ¶
func ProgressWriter(write func(line string, args ...any)) io.WriteCloser
func ReadPrivateKey ¶
ReadPrivateKey attempts to read an SSH private key from path and returns an ssh.Signer.
func SetupRepoAuth ¶
SetupRepoAuth determines the desired AuthMethod based on options.GitURL:
| Git URL format | GIT_USERNAME | GIT_PASSWORD | Auth Method | | ------------------------|--------------|--------------|-------------| | https?://host.tld/repo | Not Set | Not Set | None | | https?://host.tld/repo | Not Set | Set | HTTP Basic | | https?://host.tld/repo | Set | Not Set | HTTP Basic | | https?://host.tld/repo | Set | Set | HTTP Basic | | file://path/to/repo | - | - | None | | path/to/repo | - | - | None | | All other formats | - | - | SSH |
For SSH authentication, the default username is "git" but will honour GIT_USERNAME if set.
If SSH_PRIVATE_KEY_PATH is set, an SSH private key will be read from that path and the SSH auth method will be configured with that key.
If SSH_KNOWN_HOSTS is not set, the SSH auth method will be configured to accept and log all host keys. Otherwise, host key checking will be performed as usual.
Git URL formats may only consist of the following:
- A valid URL with a scheme
- An SCP-like URL (e.g. git@host.tld:path/to/repo.git)
- Local filesystem paths (require `git` executable)
func ShallowCloneRepo ¶
ShallowCloneRepo will clone the repository at the given URL into the given path with a depth of 1. If the destination folder exists and is not empty, the clone will not be performed.
The bool returned states whether the repository was cloned or not.
Types ¶
type CloneRepoOptions ¶
type CloneRepoOptions struct {
Path string
Storage billy.Filesystem
RepoURL string
RepoAuth transport.AuthMethod
Progress sideband.Progress
Insecure bool
SingleBranch bool
ThinPack bool
Depth int
CABundle []byte
ProxyOptions transport.ProxyOptions
}