Documentation ¶
Index ¶
- Constants
- Variables
- func ArgsToList(args map[string]string) []string
- func Log(v ...interface{})
- func Logf(format string, v ...interface{})
- func ParseArgs(lines []string) (map[string]string, error)
- func StatusText(code uint32) string
- type Backend
- type BatchItem
- type HashingReader
- type Lock
- type LockBackend
- type Oid
- type OidWithSize
- type Operation
- type Pktline
- func (p *Pktline) ReadPacketListToDelim() ([]string, error)
- func (p *Pktline) ReadPacketListToFlush() ([]string, error)
- func (p *Pktline) Reader() *pktline.PktlineReader
- func (p *Pktline) ReaderWithSize(size int) *pktline.PktlineReader
- func (p *Pktline) SendError(status uint32, message string) error
- func (p *Pktline) SendStatus(status Status) error
- func (p *Pktline) Writer() *pktline.PktlineWriter
- func (p *Pktline) WriterWithSize(size int) *pktline.PktlineWriter
- type Processor
- func (p *Processor) BatchData(op Operation, presentAction string, missingAction string) (Status, error)
- func (p *Processor) DownloadBatch() (Status, error)
- func (p *Processor) Error(code uint32, message string) (Status, error)
- func (p *Processor) GetObject(oid Oid) (Status, error)
- func (p *Processor) ListLocks(useOwnerID bool) (Status, error)
- func (p *Processor) ListLocksForPath(path string, cursor string, useOwnerID bool) (Status, error)
- func (p *Processor) Lock() (Status, error)
- func (p *Processor) ProcessCommands(op Operation) error
- func (p *Processor) PutObject(oid Oid) (Status, error)
- func (p *Processor) ReadBatch(op Operation) ([]BatchItem, error)
- func (Processor) SizeFromArgs(args map[string]string) (int64, error)
- func (p *Processor) Unlock(id string) (Status, error)
- func (p *Processor) UploadBatch() (Status, error)
- func (p *Processor) VerifyObject(oid Oid) (Status, error)
- func (p *Processor) Version() (Status, error)
- type Status
- func NewFailureStatus(code uint32, message string) Status
- func NewFailureStatusWithArgs(code uint32, message string, args ...string) Status
- func NewSuccessStatus(messages []string) Status
- func NewSuccessStatusWithCode(code uint32, args ...string) Status
- func NewSuccessStatusWithData(code uint32, messages []string, args ...string) Status
- func NewSuccessStatusWithReader(reader io.Reader, args ...string) Status
- func SuccessStatus() Status
Constants ¶
const ( HashAlgoKey = "hash-algo" TransferKey = "transfer" RefnameKey = "refname" ExpiresInKey = "expires-in" ExpiresAtKey = "expires-at" SizeKey = "size" PathKey = "path" LimitKey = "limit" CursorKey = "cursor" )
batch request argument keys.
const ( // Flush is the flush packet. Flush = '\x00' // Delim is the delimiter packet. Delim = '\x01' )
const ( StatusContinue uint32 = http.StatusContinue StatusOK uint32 = http.StatusOK StatusCreated uint32 = http.StatusCreated StatusAccepted uint32 = http.StatusAccepted StatusBadRequest uint32 = http.StatusBadRequest StatusForbidden uint32 = http.StatusForbidden StatusNotFound uint32 = http.StatusNotFound StatusConflict uint32 = http.StatusConflict StatusInternalServerError uint32 = http.StatusInternalServerError )
Status codes.
Variables ¶
var ( // ErrConflict is the conflict error. ErrConflict = errors.New("conflict") // ErrParseError is the parse error. ErrParseError = errors.New("parse error") // ErrMissingData is the missing data error. ErrMissingData = errors.New("missing data") // ErrExtraData is the extra data error. ErrExtraData = errors.New("extra data") // ErrCorruptData is the corrupt data error. ErrCorruptData = errors.New("corrupt data") // ErrNotAllowed is the not allowed error. ErrNotAllowed = errors.New("not allowed") // ErrInvalidPacket is the invalid packet error. ErrInvalidPacket = errors.New("invalid packet") )
var ( // Debug is the debug flag. Debug = false )
var ( // ErrInvalidOid is returned when an invalid Oid is encountered. ErrInvalidOid = errors.New("invalid oid") )
Functions ¶
func ArgsToList ¶
ArgsToList converts the given args to a list.
func Logf ¶
func Logf(format string, v ...interface{})
Logf logs the given arguments if Debug is true.
func StatusText ¶
StatusString returns the status string lowercased for a status code.
Types ¶
type Backend ¶
type Backend interface { Batch(op Operation, oids []OidWithSize) ([]BatchItem, error) StartUpload(oid Oid, r io.Reader, args ...string) (interface{}, error) FinishUpload(state interface{}, args ...string) error Verify(oid Oid, args map[string]string) (Status, error) Download(oid Oid, args ...string) (fs.File, error) LockBackend() LockBackend }
Backend is a Git LFS backend.
type HashingReader ¶
type HashingReader struct {
// contains filtered or unexported fields
}
HashingReader is a reader that hashes the data it reads.
func NewHashingReader ¶
func NewHashingReader(r io.Reader, hash hash.Hash) *HashingReader
NewHashingReader creates a new hashing reader.
func (*HashingReader) Oid ¶
func (h *HashingReader) Oid() (Oid, error)
Oid returns the hash of the data read.
func (*HashingReader) Read ¶
func (h *HashingReader) Read(p []byte) (int, error)
Read reads data from the underlying reader and hashes it.
func (*HashingReader) Size ¶
func (h *HashingReader) Size() int64
Size returns the number of bytes read.
type Lock ¶
type Lock interface { Unlock() error ID() string Path() string FormattedTimestamp() string OwnerName() string AsLockSpec(ownerID bool) ([]string, error) AsArguments() []string }
Lock is a Git LFS lock.
type LockBackend ¶
type LockBackend interface { Create(path string) (Lock, error) Unlock(lock Lock) error FromPath(path string) (Lock, error) FromID(id string) (Lock, error) Range(func(Lock) error) error }
LockBackend is a Git LFS lock backend.
type Oid ¶
type Oid string
Oid is a Git LFS object ID.
func (Oid) ExpectedPath ¶
ExpectedPath returns the expected path of the Oid. The path argument should be a `.git/lfs` directory.
func (Oid) Stat ¶
Stat returns the file info of the Oid. The path argument should be a `.git/lfs` directory.
type OidWithSize ¶
OidWithSize is a Git LFS object ID with size.
type Pktline ¶
PktLine is a Git packet line handler.
func NewPktline ¶
NewPktline creates a new Git packet line handler.
func (*Pktline) ReadPacketListToDelim ¶
ReadPacketListToDelim reads as many packets as possible using the `readPacketText` function before encountering a delim packet. It returns a slice of all the packets it read, or an error if one was encountered.
func (*Pktline) ReadPacketListToFlush ¶
ReadPacketListToFlush reads as many packets as possible using the `readPacketText` function before encountering a flush packet. It returns a slice of all the packets it read, or an error if one was encountered.
func (*Pktline) Reader ¶
func (p *Pktline) Reader() *pktline.PktlineReader
Reader returns a reader for the packet line.
func (*Pktline) ReaderWithSize ¶
func (p *Pktline) ReaderWithSize(size int) *pktline.PktlineReader
ReaderWithSize returns a reader for the packet line with the given size.
func (*Pktline) SendStatus ¶
SendStatus sends a status message.
func (*Pktline) Writer ¶
func (p *Pktline) Writer() *pktline.PktlineWriter
Writer returns a writer for the packet line.
func (*Pktline) WriterWithSize ¶
func (p *Pktline) WriterWithSize(size int) *pktline.PktlineWriter
WriterWithSize returns a writer for the packet line with the given size.
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor is a transfer processor.
func NewProcessor ¶
NewProcessor creates a new transfer processor.
func (*Processor) BatchData ¶
func (p *Processor) BatchData(op Operation, presentAction string, missingAction string) (Status, error)
BatchData writes batch data to the transfer protocol.
func (*Processor) DownloadBatch ¶
DownloadBatch writes download data to the transfer protocol.
func (*Processor) ListLocksForPath ¶
ListLocksForPath lists locks for a path. cursor can be empty.
func (*Processor) ProcessCommands ¶
ProcessCommands processes commands from the transfer protocol.
func (Processor) SizeFromArgs ¶
SizeFromArgs returns the size from the given args.
func (*Processor) UploadBatch ¶
UploadBatch writes upload data to the transfer protocol.
func (*Processor) VerifyObject ¶
VerifyObject verifies an object ID.
type Status ¶
Status is a Git LFS status.
func NewFailureStatus ¶
NewFailureStatus returns a new failure status.
func NewFailureStatusWithArgs ¶
NewFailureStatusWithArgs returns a new failure status with args.
func NewSuccessStatus ¶
NewSuccessStatus returns a new successful status.
func NewSuccessStatusWithCode ¶
NewSuccessStatusWithCode returns a new successful status with a code.
func NewSuccessStatusWithData ¶
NewSuccessStatusWithData returns a new successful status with data.
func NewSuccessStatusWithReader ¶
NewSuccessStatusWithReader returns a new status with a reader.