protocol

package
v0.16.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PROTOCOL_Z1             = "Z1"
	PROTOCOL_VERSION uint32 = 1
	// references prefix
	REF_PREFIX    = "refs/"
	BRANCH_PREFIX = "refs/heads/" // branch prefix
	TAG_PREFIX    = "refs/tags/"  // tag prefix
	HEAD          = "HEAD"
	// MIME
	ZETA_MIME_MD          = "application/x-zeta-metadata"
	ZETA_MIME_COMPRESS_MD = "application/x-zeta-compress-metadata"
	// other
	MAX_BATCH_BLOB_SIZE = math.MaxUint32 - 64
)

Variables

View Source
var (
	// ErrNoOverlap is returned by ParseRange if first-byte-pos of
	// all of the byte-range-spec values is greater than the content size.
	ErrNoOverlap = errors.New("invalid range: failed to overlap")

	// ErrInvalid is returned by ParseRange on invalid input.
	ErrInvalid = errors.New("invalid range")
)

Functions

func ReadInputOIDs

func ReadInputOIDs(r io.Reader) ([]plumbing.Hash, error)

func ReadInputPaths

func ReadInputPaths(r io.Reader) ([]string, error)

func WriteBatchObjectsHeader

func WriteBatchObjectsHeader(w io.Writer) error

func WriteObjectsItem

func WriteObjectsItem(w io.Writer, r io.Reader, oid string, size int64) error

func WriteSingleObjectsHeader

func WriteSingleObjectsHeader(w io.Writer, contentLength, compressedSize int64) error

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 Branch

type Branch struct {
	Remote          string   `json:"remote"`
	Branch          string   `json:"branch"`
	Hash            string   `json:"hash"`
	Version         int      `json:"version"`
	Agent           string   `json:"agent"`
	HashAlgo        string   `json:"hash-algo"`
	DefaultBranch   string   `json:"default-branch"`
	CompressionAlgo string   `json:"compression-algo"`
	Capabilities    []string `json:"capabilities"`
}

type ErrorCode

type ErrorCode struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

func (*ErrorCode) Error

func (e *ErrorCode) Error() string

type HaveObject

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

type Operation

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

type Packer

type Packer struct {
	odb.DB
	crc.Finisher
	// contains filtered or unexported fields
}

func NewHttpPacker

func NewHttpPacker(o odb.DB, w http.ResponseWriter, r *http.Request, treeMaxDepth int) (*Packer, error)

func NewPipePacker

func NewPipePacker(o odb.DB, w io.Writer, treeMaxDepth int) (*Packer, error)

NewPipePacker: SSH protocol

func (*Packer) Close

func (p *Packer) Close() error

func (*Packer) Done

func (p *Packer) Done() (err error)

func (*Packer) WriteAny

func (p *Packer) WriteAny(ctx context.Context, e object.Encoder, oid string) error

func (*Packer) WriteDeduplication

func (p *Packer) WriteDeduplication(ctx context.Context, e object.Encoder, oid plumbing.Hash) error

func (*Packer) WriteDeepenMetadata

func (p *Packer) WriteDeepenMetadata(ctx context.Context, current *object.Commit, deepenFrom, have plumbing.Hash, deepen int) error

func (*Packer) WriteDeepenSparseMetadata

func (p *Packer) WriteDeepenSparseMetadata(ctx context.Context, current *object.Commit, deepenFrom, have plumbing.Hash, deepen int, paths []string) error

func (*Packer) WriteSparseTree

func (p *Packer) WriteSparseTree(ctx context.Context, oid plumbing.Hash, m SparseMatcher, depth int) error

func (*Packer) WriteTree

func (p *Packer) WriteTree(ctx context.Context, oid plumbing.Hash, depth int) error

type PayloadHeader

type PayloadHeader struct {
	Authorization string `json:"authorization"`
}

type Range

type Range struct {
	Start  int64
	Length int64
}

Range specifies the byte range to be sent to the client.

func ParseRange

func ParseRange(s string, size int64) ([]Range, error)

ParseRange parses a Range header string as per RFC 7233. ErrNoOverlap is returned if none of the ranges overlap. ErrInvalid is returned if s is invalid range.

func ParseRangeEx

func ParseRangeEx(r *http.Request) (*Range, error)

func (Range) ContentRange

func (r Range) ContentRange(size int64) string

ContentRange returns Content-Range header value.

type Reference

type Reference struct {
	Remote          string   `json:"remote"`
	Name            string   `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"`
}

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"`
}

type SASHandeshake

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

type SASPayload

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

type SparseMatcher

type SparseMatcher interface {
	Len() int
	Match(name string) (SparseMatcher, bool)
}

func NewSparseTreeMatcher

func NewSparseTreeMatcher(dirs []string) SparseMatcher

type Tag

type Tag struct {
	Remote          string   `json:"remote"`
	Tag             string   `json:"tag"`
	Hash            string   `json:"hash"`
	Version         int      `json:"version"`
	Agent           string   `json:"agent"`
	HashAlgo        string   `json:"hash-algo"`
	CompressionAlgo string   `json:"compression-algo"`
	Capabilities    []string `json:"capabilities"`
}

type WantObject

type WantObject struct {
	OID  string `json:"oid"`
	Path string `json:"path,omitempty"`
}

Jump to

Keyboard shortcuts

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