Documentation ¶
Index ¶
- func CloneRepo(ctx context.Context, logf func(string, ...any), opts CloneRepoOptions) (bool, 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 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.
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 Depth int CABundle []byte ProxyOptions transport.ProxyOptions }