{"modulePath":"github.com/coder/envbuilder","version":"v1.3.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package git\n\n## Functions\n\n```go\nfunc CloneRepo(ctx context.Context, logf func(string, ...any), opts CloneRepoOptions) (bool, error)\n```\nCloneRepo 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.\n\nThe bool returned states whether the repository was cloned or not.\n\n```go\nfunc DecodeBase64PrivateKey(key string) (gossh.Signer, error)\n```\nDecodeBase64PrivateKey attempts to decode a base64 encoded private key and returns an ssh.Signer\n\n```go\nfunc LogHostKeyCallback(logger func(string, ...any)) gossh.HostKeyCallback\n```\nLogHostKeyCallback is a HostKeyCallback that just logs host keys and does nothing else.\n\n```go\nfunc ProgressWriter(write func(line string, args ...any)) io.WriteCloser\n```\n\n```go\nfunc ReadPrivateKey(path string) (gossh.Signer, error)\n```\nReadPrivateKey attempts to read an SSH private key from path and returns an ssh.Signer.\n\n```go\nfunc SetupRepoAuth(logf func(string, ...any), options *options.Options) transport.AuthMethod\n```\nSetupRepoAuth determines the desired AuthMethod based on options.GitURL:\n\n| 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](file://path/to/repo)     | -            | -            | None        | | path/to/repo            | -            | -            | None        | | All other formats       | -            | -            | SSH         |\n\nFor SSH authentication, the default username is \"git\" but will honour GIT\\_USERNAME if set.\n\nIf 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.\n\nIf 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.\n\nGit URL formats may only consist of the following:\n\n 1. A valid URL with a scheme\n 2. An SCP-like URL (e.g. git@host.tld:path/to/repo.git)\n 3. Local filesystem paths (require \\`git\\` executable)\n\n```go\nfunc ShallowCloneRepo(ctx context.Context, logf func(string, ...any), opts CloneRepoOptions) error\n```\nShallowCloneRepo 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.\n\nThe bool returned states whether the repository was cloned or not.\n\n## Types\n\n```go\ntype CloneRepoOptions struct {\n\tPath    string\n\tStorage billy.Filesystem\n\n\tRepoURL      string\n\tRepoAuth     transport.AuthMethod\n\tProgress     sideband.Progress\n\tInsecure     bool\n\tSingleBranch bool\n\tThinPack     bool\n\tDepth        int\n\tCABundle     []byte\n\tProxyOptions transport.ProxyOptions\n}\n```\n\n```go\nfunc CloneOptionsFromOptions(logf func(string, ...any), options options.Options) (CloneRepoOptions, error)\n```\n\n","path":"github.com/coder/envbuilder/git","name":"git","synopsis":"","isRedistributable":true}
