Documentation ¶
Index ¶
- Constants
- Variables
- func DetermineEndpoint(cloneurl, lfsurl string) *url.URL
- func IsErrRangeNotSatisfiable(err error) bool
- func ReadMetaObject(pointer Pointer) (io.ReadCloser, error)
- func SearchPointerBlobs(ctx context.Context, repo *git.Repository, pointerChan chan<- PointerBlob, ...)
- type BasicTransferAdapter
- func (a *BasicTransferAdapter) Download(ctx context.Context, l *Link) (io.ReadCloser, error)
- func (a *BasicTransferAdapter) Name() string
- func (a *BasicTransferAdapter) Upload(ctx context.Context, l *Link, p Pointer, r io.Reader) error
- func (a *BasicTransferAdapter) Verify(ctx context.Context, l *Link, p Pointer) error
- type BatchRequest
- type BatchResponse
- type Client
- type ContentStore
- type DownloadCallback
- type ErrRangeNotSatisfiable
- type ErrorResponse
- type FilesystemClient
- type HTTPClient
- type Link
- type ObjectError
- type ObjectResponse
- type Pointer
- type PointerBlob
- type Reference
- type TransferAdapter
- type UploadCallback
Constants ¶
const ( // MetaFileIdentifier is the string appearing at the first line of LFS pointer files. // https://github.com/git-lfs/git-lfs/blob/master/docs/spec.md MetaFileIdentifier = "version https://git-lfs.github.com/spec/v1" // MetaFileOidPrefix appears in LFS pointer files on a line before the sha256 hash. MetaFileOidPrefix = "oid sha256:" )
const (
// MediaType contains the media type for LFS server requests
MediaType = "application/vnd.git-lfs+json"
)
Variables ¶
var ( // ErrHashMismatch occurs if the content has does not match OID ErrHashMismatch = errors.New("Content hash does not match OID") // ErrSizeMismatch occurs if the content size does not match ErrSizeMismatch = errors.New("Content size does not match") )
var ( // ErrMissingPrefix occurs if the content lacks the LFS prefix ErrMissingPrefix = errors.New("Content lacks the LFS prefix") // ErrInvalidStructure occurs if the content has an invalid structure ErrInvalidStructure = errors.New("Content has an invalid structure") // ErrInvalidOIDFormat occurs if the oid has an invalid format ErrInvalidOIDFormat = errors.New("OID has an invalid format") )
Functions ¶
func DetermineEndpoint ¶ added in v1.15.0
DetermineEndpoint determines an endpoint from the clone url or uses the specified LFS url.
func IsErrRangeNotSatisfiable ¶ added in v1.13.0
IsErrRangeNotSatisfiable returns true if the error is an ErrRangeNotSatisfiable
func ReadMetaObject ¶ added in v1.8.0
func ReadMetaObject(pointer Pointer) (io.ReadCloser, error)
ReadMetaObject will read a git_model.LFSMetaObject and return a reader
func SearchPointerBlobs ¶ added in v1.15.0
func SearchPointerBlobs(ctx context.Context, repo *git.Repository, pointerChan chan<- PointerBlob, errChan chan<- error)
SearchPointerBlobs scans the whole repository for LFS pointer files
Types ¶
type BasicTransferAdapter ¶ added in v1.15.0
type BasicTransferAdapter struct {
// contains filtered or unexported fields
}
BasicTransferAdapter implements the "basic" adapter
func (*BasicTransferAdapter) Download ¶ added in v1.15.0
func (a *BasicTransferAdapter) Download(ctx context.Context, l *Link) (io.ReadCloser, error)
Download reads the download location and downloads the data
func (*BasicTransferAdapter) Name ¶ added in v1.15.0
func (a *BasicTransferAdapter) Name() string
Name returns the name of the adapter
type BatchRequest ¶ added in v1.15.0
type BatchRequest struct { Operation string `json:"operation"` Transfers []string `json:"transfers,omitempty"` Ref *Reference `json:"ref,omitempty"` Objects []Pointer `json:"objects"` }
BatchRequest contains multiple requests processed in one batch operation. https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#requests
type BatchResponse ¶
type BatchResponse struct { Transfer string `json:"transfer,omitempty"` Objects []*ObjectResponse `json:"objects"` }
BatchResponse contains multiple object metadata Representation structures for use with the batch API. https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#successful-responses
type Client ¶ added in v1.15.0
type Client interface { BatchSize() int Download(ctx context.Context, objects []Pointer, callback DownloadCallback) error Upload(ctx context.Context, objects []Pointer, callback UploadCallback) error }
Client is used to communicate with a LFS source
type ContentStore ¶
type ContentStore struct {
storage.ObjectStorage
}
ContentStore provides a simple file system based storage.
func NewContentStore ¶ added in v1.15.0
func NewContentStore() *ContentStore
NewContentStore creates the default ContentStore
func (*ContentStore) Exists ¶
func (s *ContentStore) Exists(pointer Pointer) (bool, error)
Exists returns true if the object exists in the content store.
func (*ContentStore) Get ¶
func (s *ContentStore) Get(pointer Pointer) (storage.Object, error)
Get takes a Meta object and retrieves the content from the store, returning it as an io.ReadSeekCloser.
type DownloadCallback ¶ added in v1.15.0
type DownloadCallback func(p Pointer, content io.ReadCloser, objectError error) error
DownloadCallback gets called for every requested LFS object to process its content
type ErrRangeNotSatisfiable ¶ added in v1.13.0
type ErrRangeNotSatisfiable struct {
FromByte int64
}
ErrRangeNotSatisfiable represents an error which request range is not satisfiable.
func (ErrRangeNotSatisfiable) Error ¶ added in v1.13.0
func (err ErrRangeNotSatisfiable) Error() string
type ErrorResponse ¶ added in v1.15.0
type ErrorResponse struct { Message string DocumentationURL string `json:"documentation_url,omitempty"` RequestID string `json:"request_id,omitempty"` }
ErrorResponse describes the error to the client.
type FilesystemClient ¶ added in v1.15.0
type FilesystemClient struct {
// contains filtered or unexported fields
}
FilesystemClient is used to read LFS data from a filesystem path
func (*FilesystemClient) BatchSize ¶ added in v1.15.0
func (c *FilesystemClient) BatchSize() int
BatchSize returns the preferred size of batchs to process
func (*FilesystemClient) Download ¶ added in v1.15.0
func (c *FilesystemClient) Download(ctx context.Context, objects []Pointer, callback DownloadCallback) error
Download reads the specific LFS object from the target path
func (*FilesystemClient) Upload ¶ added in v1.15.0
func (c *FilesystemClient) Upload(ctx context.Context, objects []Pointer, callback UploadCallback) error
Upload writes the specific LFS object to the target path
type HTTPClient ¶ added in v1.15.0
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient is used to communicate with the LFS server https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md
func (*HTTPClient) BatchSize ¶ added in v1.15.0
func (c *HTTPClient) BatchSize() int
BatchSize returns the preferred size of batchs to process
func (*HTTPClient) Download ¶ added in v1.15.0
func (c *HTTPClient) Download(ctx context.Context, objects []Pointer, callback DownloadCallback) error
Download reads the specific LFS object from the LFS server
func (*HTTPClient) Upload ¶ added in v1.15.0
func (c *HTTPClient) Upload(ctx context.Context, objects []Pointer, callback UploadCallback) error
Upload sends the specific LFS object to the LFS server
type Link ¶ added in v1.15.0
type Link struct { Href string `json:"href"` Header map[string]string `json:"header,omitempty"` ExpiresAt *time.Time `json:"expires_at,omitempty"` }
Link provides a structure with information about how to access a object.
type ObjectError ¶
ObjectError defines the JSON structure returned to the client in case of an error.
type ObjectResponse ¶ added in v1.15.0
type ObjectResponse struct { Pointer Actions map[string]*Link `json:"actions,omitempty"` Error *ObjectError `json:"error,omitempty"` }
ObjectResponse is object metadata as seen by clients of the LFS server.
type Pointer ¶ added in v1.15.0
type Pointer struct { Oid string `json:"oid" xorm:"UNIQUE(s) INDEX NOT NULL"` Size int64 `json:"size" xorm:"NOT NULL"` }
Pointer contains LFS pointer data
func GeneratePointer ¶ added in v1.15.0
GeneratePointer generates a pointer for arbitrary content
func ReadPointer ¶ added in v1.15.0
ReadPointer tries to read LFS pointer data from the reader
func ReadPointerFromBuffer ¶ added in v1.15.0
ReadPointerFromBuffer will return a pointer if the provided byte slice is a pointer file or an error otherwise.
func (Pointer) ColorFormat ¶ added in v1.16.4
ColorFormat provides a basic color format for a Team
func (Pointer) IsValid ¶ added in v1.15.0
IsValid checks if the pointer has a valid structure. It doesn't check if the pointed-to-content exists.
func (Pointer) RelativePath ¶ added in v1.15.0
RelativePath returns the relative storage path of the pointer
func (Pointer) StringContent ¶ added in v1.15.0
StringContent returns the string representation of the pointer https://github.com/git-lfs/git-lfs/blob/main/docs/spec.md#the-pointer
type PointerBlob ¶ added in v1.15.0
PointerBlob associates a Git blob with a Pointer.
type Reference ¶ added in v1.15.0
type Reference struct {
Name string `json:"name"`
}
Reference contains a git reference. https://github.com/git-lfs/git-lfs/blob/main/docs/api/batch.md#ref-property
type TransferAdapter ¶ added in v1.15.0
type TransferAdapter interface { Name() string Download(ctx context.Context, l *Link) (io.ReadCloser, error) Upload(ctx context.Context, l *Link, p Pointer, r io.Reader) error Verify(ctx context.Context, l *Link, p Pointer) error }
TransferAdapter represents an adapter for downloading/uploading LFS objects
type UploadCallback ¶ added in v1.15.0
type UploadCallback func(p Pointer, objectError error) (io.ReadCloser, error)
UploadCallback gets called for every requested LFS object to provide its content