Documentation
¶
Overview ¶
Package gitlfs is the grammar of the Git LFS server protocol (https://github.com/git-lfs/git-lfs/blob/main/docs/api): object ids, the batch request and response documents and the error bodies. It holds no policy; the handler (internal/format/gitlfs) and the RBAC middleware, which must agree on what a batch request asks for, both read requests through it.
Index ¶
Constants ¶
const ( OperationDownload = "download" OperationUpload = "upload" )
Operations of a batch request.
const ( ActionDownload = "download" ActionUpload = "upload" ActionVerify = "verify" )
Actions of a batch response object.
const HashSHA256 = "sha256"
HashSHA256 is the only hash algorithm of an object id.
const MaxBatchBytes = 1 << 20
MaxBatchBytes bounds a batch request body. Clients send 100 objects per batch by default (about 11 KB); the cap leaves room for ten thousand.
const MediaType = "application/vnd.git-lfs+json"
MediaType is the Content-Type and Accept value of every JSON document of the protocol.
const TransferBasic = "basic"
TransferBasic is the only transfer adapter the server speaks: one HTTP PUT or GET of the whole object.
Variables ¶
var ErrInvalidBatch = errors.New("invalid batch request")
ErrInvalidBatch is returned for a batch request that is not a batch document.
Functions ¶
func ObjectPath ¶
ObjectPath is the repository-wide path an object is stored under: objects/ab/cd/<oid>, the layout of every LFS server's store.
func PeekOperation ¶
PeekOperation returns the operation of a batch request body, or "" when the body is not a batch document. It decodes the one key ParseBatch decodes into BatchRequest.Operation with the same rules (case-insensitive key match, the last duplicate wins), so authorization and the handler never disagree on what a request asks for.
Types ¶
type Action ¶
type Action struct {
Href string `json:"href"`
Header map[string]string `json:"header,omitempty"`
ExpiresIn int `json:"expires_in,omitempty"`
}
Action is one thing the client may do with an object.
type BatchRequest ¶
type BatchRequest struct {
Operation string `json:"operation"`
Transfers []string `json:"transfers,omitempty"`
Ref *Ref `json:"ref,omitempty"`
Objects []Pointer `json:"objects"`
HashAlgo string `json:"hash_algo,omitempty"`
}
BatchRequest is the body of POST objects/batch.
func ParseBatch ¶
func ParseBatch(body []byte) (*BatchRequest, error)
ParseBatch decodes a batch request. It checks the document, not its meaning: object ids and sizes are validated per object by the handler, so one bad pointer does not fail the others.
type BatchResponse ¶
type BatchResponse struct {
Transfer string `json:"transfer"`
Objects []ObjectResult `json:"objects"`
HashAlgo string `json:"hash_algo,omitempty"`
}
BatchResponse is the body of a successful batch.
type Error ¶
type Error struct {
Message string `json:"message"`
DocumentationURL string `json:"documentation_url,omitempty"`
RequestID string `json:"request_id,omitempty"`
}
Error is the body of a failed request.
type ObjectError ¶
ObjectError is a per-object failure inside a batch response.
type ObjectResult ¶
type ObjectResult struct {
OID string `json:"oid"`
Size int64 `json:"size"`
Authenticated bool `json:"authenticated,omitempty"`
Actions map[string]Action `json:"actions,omitempty"`
Error *ObjectError `json:"error,omitempty"`
}
ObjectResult is one object of a batch response: the actions the client takes (none when there is nothing to do) or the error that applies to it.