transport

package
Version: v5.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package transport includes the implementation for different transport protocols.

`Client` can be used to fetch and send packfiles to a git server. The `client` package provides higher level functions to instantiate the appropriate `Client` based on the repository URL.

go-git supports HTTP and SSH (see `Protocols`), but you can also install your own protocols (see the `client` package).

Each protocol has its own implementation of `Client`, but you should generally not use them directly, use `client.NewClient` instead.

Index

Constants

View Source
const (
	UploadPackServiceName  = "git-upload-pack"
	ReceivePackServiceName = "git-receive-pack"
)

Variables

View Source
var (
	ErrRepositoryNotFound     = errors.New("repository not found")
	ErrEmptyRemoteRepository  = errors.New("remote repository is empty")
	ErrAuthenticationRequired = errors.New("authentication required")
	ErrAuthorizationFailed    = errors.New("authorization failed")
	ErrEmptyUploadPackRequest = errors.New("empty git-upload-pack given")
	ErrInvalidAuthMethod      = errors.New("invalid auth method")
	ErrAlreadyConnected       = errors.New("session already established")
)

UnsupportedCapabilities are the capabilities not supported by any client implementation

Functions

func FilterUnsupportedCapabilities

func FilterUnsupportedCapabilities(list *capability.List)

FilterUnsupportedCapabilities it filter out all the UnsupportedCapabilities from a capability.List, the intended usage is on the client implementation to filter the capabilities from an AdvRefs message.

Types

type AuthMethod

type AuthMethod interface {
	fmt.Stringer
	Name() string
}

type Endpoint

type Endpoint struct {
	// Protocol is the protocol of the endpoint (e.g. git, https, file).
	Protocol string
	// User is the user.
	User string
	// Password is the password.
	Password string
	// Host is the host.
	Host string
	// Port is the port to connect, if 0 the default port for the given protocol
	// wil be used.
	Port int
	// Path is the repository path.
	Path string
	// InsecureSkipTLS skips ssl verify if protocal is https
	InsecureSkipTLS bool
	// CaBundle specify additional ca bundle with system cert pool
	CaBundle []byte
}

Endpoint represents a Git URL in any supported protocol.

func NewEndpoint

func NewEndpoint(endpoint string) (*Endpoint, error)

func (*Endpoint) String

func (u *Endpoint) String() string

String returns a string representation of the Git URL.

type ReceivePackSession

type ReceivePackSession interface {
	Session
	// ReceivePack sends an update references request and a packfile
	// reader and returns a ReportStatus and error. Don't be confused by
	// terminology, the client side of a git-receive-pack is called
	// git-send-pack, although here the same interface is used to make it
	// RPC-like.
	ReceivePack(context.Context, *packp.ReferenceUpdateRequest) (*packp.ReportStatus, error)
}

ReceivePackSession represents a git-receive-pack session. A git-receive-pack session has two steps: reference discovery (AdvertisedReferences) and receiving pack (ReceivePack). In that order.

type Session

type Session interface {
	// AdvertisedReferences retrieves the advertised references for a
	// repository.
	// If the repository does not exist, returns ErrRepositoryNotFound.
	// If the repository exists, but is empty, returns ErrEmptyRemoteRepository.
	AdvertisedReferences() (*packp.AdvRefs, error)
	// AdvertisedReferencesContext retrieves the advertised references for a
	// repository.
	// If the repository does not exist, returns ErrRepositoryNotFound.
	// If the repository exists, but is empty, returns ErrEmptyRemoteRepository.
	AdvertisedReferencesContext(context.Context) (*packp.AdvRefs, error)
	io.Closer
}

type Transport

type Transport interface {
	// NewUploadPackSession starts a git-upload-pack session for an endpoint.
	NewUploadPackSession(*Endpoint, AuthMethod) (UploadPackSession, error)
	// NewReceivePackSession starts a git-receive-pack session for an endpoint.
	NewReceivePackSession(*Endpoint, AuthMethod) (ReceivePackSession, error)
}

Transport can initiate git-upload-pack and git-receive-pack processes. It is implemented both by the client and the server, making this a RPC.

type UploadPackSession

type UploadPackSession interface {
	Session
	// UploadPack takes a git-upload-pack request and returns a response,
	// including a packfile. Don't be confused by terminology, the client
	// side of a git-upload-pack is called git-fetch-pack, although here
	// the same interface is used to make it RPC-like.
	UploadPack(context.Context, *packp.UploadPackRequest) (*packp.UploadPackResponse, error)
}

UploadPackSession represents a git-upload-pack session. A git-upload-pack session has two steps: reference discovery (AdvertisedReferences) and uploading pack (UploadPack).

Source Files

Directories

Path Synopsis
Package client contains helper function to deal with the different client protocols.
Package client contains helper function to deal with the different client protocols.
Package file implements the file transport protocol.
Package file implements the file transport protocol.
Package git implements the git transport protocol.
Package git implements the git transport protocol.
Package http implements the HTTP transport protocol.
Package http implements the HTTP transport protocol.
Package server implements the git server protocol.
Package server implements the git server protocol.
Package ssh implements the SSH transport protocol.
Package ssh implements the SSH transport protocol.
Package test implements common test suite for different transport implementations.
Package test implements common test suite for different transport implementations.
internal
common
Package common implements the git pack protocol with a pluggable transport.
Package common implements the git pack protocol with a pluggable transport.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL