Documentation
¶
Index ¶
- Constants
- Variables
- func IsCommitSHA(str string) bool
- func IsGitTransport(remote string) bool
- type GitCLI
- type GitURL
- type GitURLOpts
- type Option
- func WithArgs(args ...string) Option
- func WithDir(dir string) Option
- func WithExec(exec func(context.Context, *exec.Cmd) error) Option
- func WithGitBinary(path string) Option
- func WithGitDir(gitDir string) Option
- func WithSSHAuthSock(sshAuthSock string) Option
- func WithSSHKnownHosts(sshKnownHosts string) Option
- func WithStreams(streams StreamFunc) Option
- func WithWorkTree(workTree string) Option
- type StreamFunc
Constants ¶
const ( HTTPProtocol string = "http" HTTPSProtocol string = "https" SSHProtocol string = "ssh" GitProtocol string = "git" )
Variables ¶
var ( ErrUnknownProtocol = errors.New("unknown protocol") ErrInvalidProtocol = errors.New("invalid protocol") )
Functions ¶
func IsCommitSHA ¶ added in v0.17.0
func IsGitTransport ¶ added in v0.13.0
Types ¶
type GitCLI ¶ added in v0.13.0
type GitCLI struct {
// contains filtered or unexported fields
}
GitCLI carries config to pass to the git cli to make running multiple commands less repetitive.
func (*GitCLI) New ¶ added in v0.13.0
New returns a new git client with the same config as the current one, but with the given options applied on top.
type GitURL ¶ added in v0.13.0
type GitURL struct { // Scheme is the protocol over which the git repo can be accessed Scheme string // Host is the remote host that hosts the git repo Host string // Path is the path on the host to access the repo Path string // User is the username/password to access the host User *url.Userinfo // Query is the query parameters for the URL Query url.Values // Opts can contain additional metadata Opts *GitURLOpts // Remote is a valid URL remote to pass into the Git CLI tooling (i.e. // without the fragment metadata) Remote string }
URL is a custom URL type that points to a remote Git repository.
URLs can be parsed from both standard URLs (e.g. "https://github.com/moby/buildkit.git"), as well as SCP-like URLs (e.g. "git@github.com:moby/buildkit.git").
See https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols
type GitURLOpts ¶ added in v0.23.0
type GitURLOpts struct { // Ref is the git reference Ref string // Subdir is the sub-directory inside the git repository to use Subdir string }
GitURLOpts is the buildkit-specific metadata extracted from the fragment or the query of a remote URL.
type Option ¶ added in v0.13.0
type Option func(b *GitCLI)
Option provides a variadic option for configuring the git client.
func WithDir ¶ added in v0.13.0
WithDir sets working directory.
This should be a path to any directory within a standard git repository.
func WithGitBinary ¶ added in v0.13.0
WithGitBinary sets the git binary path.
func WithGitDir ¶ added in v0.13.0
WithGitDir sets the --git-dir arg.
This should be the path to the .git directory. When setting this, you may also need to set WithWorkTree, unless you are working with a bare repository.
func WithSSHAuthSock ¶ added in v0.13.0
WithSSHAuthSock sets the ssh auth sock.
func WithSSHKnownHosts ¶ added in v0.13.0
WithSSHKnownHosts sets the known hosts file.
func WithStreams ¶ added in v0.13.0
func WithStreams(streams StreamFunc) Option
WithStreams configures a callback for getting the streams for a command. The stream callback will be called once for each command, and both writers will be closed after the command has finished.
func WithWorkTree ¶ added in v0.13.0
WithWorkTree sets the --work-tree arg.
This should be the path to the top-level directory of the checkout. When setting this, you also likely need to set WithGitDir.
type StreamFunc ¶ added in v0.13.0
type StreamFunc func(context.Context) (io.WriteCloser, io.WriteCloser, func())