transport

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRepositoryNotFound = errors.New("repository not found")
	ErrReferenceNotExist  = errors.New("reference not exist")
)

Functions

func FindScpLikeComponents

func FindScpLikeComponents(url string) (user, host, port, path string)

FindScpLikeComponents returns the user, host, port and path of the given SCP-like URL.

func IsLocalEndpoint

func IsLocalEndpoint(url string) bool

IsLocalEndpoint returns true if the given URL string specifies a local file endpoint. For example, on a Linux machine, `/home/user/src/go-git` would match as a local endpoint, but `https://github.com/src-d/go-git` would not.

func IsRemoteEndpoint

func IsRemoteEndpoint(url string) bool

func MatchesScheme

func MatchesScheme(url string) bool

MatchesScheme returns true if the given string matches a URL-like format scheme.

func MatchesScpLike

func MatchesScpLike(url string) bool

MatchesScpLike returns true if the given string matches an SCP-like format scheme.

Types

type BatchRequest

type BatchRequest struct {
	Objects []*HaveObject `json:"objects"`
}

type BatchResponse

type BatchResponse struct {
	Objects []*HaveObject `json:"objects"`
}

type BatchSharedsRequest

type BatchSharedsRequest struct {
	Objects []*WantObject `json:"objects"`
}

type BatchSharedsResponse

type BatchSharedsResponse struct {
	Objects []*Representation `json:"objects"`
}

type Command

type Command struct {
	Refname     plumbing.ReferenceName `json:"refname"`
	OldRev      string                 `json:"old_rev"`
	NewRev      string                 `json:"new_rev"`
	Metadata    int                    `json:"metadata"`
	Objects     int                    `json:"objects"`
	PushOptions []string               `json:"push_options,omitempty"`
}

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
	// Base URL only http/https
	Base *url.URL
	// InsecureSkipTLS skips ssl verify if protocol is https
	InsecureSkipTLS bool
	// ExtraHeader extra header
	ExtraHeader map[string]string
}

Endpoint represents a Git URL in any supported protocol.

func NewEndpoint

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

func (*Endpoint) String

func (u *Endpoint) String() string

String returns a string representation of the Git URL.

type HaveObject

type HaveObject struct {
	OID            string    `json:"oid"`
	CompressedSize int64     `json:"compressed_size"`
	Action         Operation `json:"action,omitempty"`
}

type MetadataOptions

type MetadataOptions struct {
	Sparses    []string
	DeepenFrom plumbing.Hash
	Have       plumbing.Hash
	Deepen     int
	Depth      int
}

type Operation

type Operation string
const (
	DOWNLOAD Operation = "download"
	UPLOAD   Operation = "upload"
	SUDO     Operation = "sudo"
)

type Options

type Options struct {
	InsecureSkipTLS bool
	ExtraHeader     []string
}

type Reference

type Reference struct {
	Remote          string                 `json:"remote"`
	Name            plumbing.ReferenceName `json:"name"`
	Hash            string                 `json:"hash"`
	Peeled          string                 `json:"peeled,omitempty"`
	HEAD            string                 `json:"head"`
	Version         int                    `json:"version"`
	Agent           string                 `json:"agent"`
	HashAlgo        string                 `json:"hash-algo"`
	CompressionALGO string                 `json:"compression-algo"`
	Capabilities    []string               `json:"capabilities"`
}

func (*Reference) Target

func (r *Reference) Target() plumbing.Hash

type Representation

type Representation struct {
	OID            string            `json:"oid"`
	CompressedSize int64             `json:"compressed_size"`
	Href           string            `json:"href"`
	Header         map[string]string `json:"header,omitempty"`
	ExpiresAt      time.Time         `json:"expires_at,omitempty"`
}

func (*Representation) Copy

func (r *Representation) Copy() *Representation

func (*Representation) IsExpired

func (r *Representation) IsExpired() bool

type SASHandeshake

type SASHandeshake struct {
	Operation Operation `json:"operation"`
	Version   string    `json:"version"`
}

type SASPayload

type SASPayload struct {
	Header    map[string]string `json:"header,omitempty"`
	Notice    string            `json:"notice,omitempty"`
	ExpiresAt time.Time         `json:"expires_at,omitempty"`
}

func (*SASPayload) IsExpired

func (p *SASPayload) IsExpired() bool

type SessionReader

type SessionReader interface {
	io.Reader
	io.Closer
	LastError() error
}

type SizeReader

type SizeReader interface {
	io.Reader
	io.Closer
	Offset() int64
	Size() int64
	LastError() error
}

type Transport

type Transport interface {
	// FetchReference: discover reference and remote repo info and caps
	FetchReference(ctx context.Context, refname plumbing.ReferenceName) (*Reference, error)
	// FetchMetadata: support base metadata and sparses metadata.
	//  target: commit or tag
	FetchMetadata(ctx context.Context, target plumbing.Hash, opts *MetadataOptions) (SessionReader, error)
	// BatchObjects: batch download objects AKA blobs
	BatchObjects(ctx context.Context, oids []plumbing.Hash) (SessionReader, error)
	// GetObject: get large object, support Range feature
	GetObject(ctx context.Context, oid plumbing.Hash, fromByte int64) (SizeReader, error)
	// Shared: get large objects shared links
	Shared(ctx context.Context, wantObjects []*WantObject) ([]*Representation, error)
	// Push: push metadata and blobs to remote and update reference
	Push(ctx context.Context, r io.Reader, cmd *Command) (rc SessionReader, err error)
	// BatchCheck: check large objects exists in remote
	BatchCheck(ctx context.Context, refname plumbing.ReferenceName, haveObjects []*HaveObject) ([]*HaveObject, error)
	// PutObject: upload large object to remote
	PutObject(ctx context.Context, refname plumbing.ReferenceName, oid plumbing.Hash, r io.Reader, size int64) error
}

type WantObject

type WantObject struct {
	OID string `json:"oid"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL