Documentation ¶
Index ¶
- Constants
- Variables
- func Batch(objects []*ObjectResource) ([]*ObjectResource, *WrappedError)
- func CopyWithCallback(writer io.Writer, reader io.Reader, totalSize int64, cb CopyCallback) (int64, error)
- func DoHTTP(c *Configuration, req *http.Request) (*http.Response, error)
- func DownloadCheck(oid string) (*ObjectResource, *WrappedError)
- func EmbedStructInJsonRawMessage(in interface{}) (*json.RawMessage, error)
- func EncodePointer(writer io.Writer, pointer *Pointer) (int, error)
- func Environ() []string
- func ExtractStructFromJsonRawMessage(raw *json.RawMessage, out interface{}) error
- func InRepo() bool
- func InstallFilters() error
- func InstallHooks(force bool) error
- func LimitReadCloser(r io.Reader, sz int64) io.ReadCloser
- func LocalMediaPath(sha string) (string, error)
- func NewUploadable(oid, filename string, index, totalFiles int) (*Uploadable, *WrappedError)
- func ObjectUrl(endpoint Endpoint, oid string) (*url.URL, error)
- func PointerClean(reader io.Reader, size int64, cb CopyCallback) (*cleanedAsset, error)
- func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, cb CopyCallback) error
- func PointerSmudgeObject(ptr *Pointer, obj *ObjectResource, cb CopyCallback) error
- func ReleaseApiContext(ctx ApiContext)
- func ResetTempDir() error
- func Shutdown()
- func ShutdownApiContexts()
- func Stack() []byte
- func TempFile(prefix string) (*os.File, error)
- func UploadCheck(oidPath string) (*ObjectResource, *WrappedError)
- type AltConfig
- type ApiContext
- type ApiContextReadCloser
- type BatchRequest
- type BatchRequestObject
- type BatchResponse
- type BatchResponseObject
- type CallbackReader
- type CleanedPointerError
- type ClientError
- type Configuration
- func (c *Configuration) BatchTransfer() bool
- func (c *Configuration) ConcurrentTransfers() int
- func (c *Configuration) Endpoint() Endpoint
- func (c *Configuration) GitConfig(key string) (string, bool)
- func (c *Configuration) HttpClient() *http.Client
- func (c *Configuration) ObjectUrl(oid string) (*url.URL, error)
- func (c *Configuration) RemoteEndpoint(remote string) Endpoint
- func (c *Configuration) Remotes() []string
- func (c *Configuration) SetConfig(key, value string)
- type CopyCallback
- type CredentialCmd
- type Creds
- type DownloadCheckRequest
- type DownloadCheckResponse
- type DownloadRequest
- type Downloadable
- type Endpoint
- type ExitRequest
- type ExitResponse
- type HookExists
- type HttpApiContext
- func (self *HttpApiContext) Batch(objects []*ObjectResource) ([]*ObjectResource, *WrappedError)
- func (*HttpApiContext) Close() error
- func (self *HttpApiContext) Download(oid string) (io.ReadCloser, int64, *WrappedError)
- func (self *HttpApiContext) DownloadCheck(oid string) (*ObjectResource, *WrappedError)
- func (self *HttpApiContext) DownloadObject(obj *ObjectResource) (io.ReadCloser, int64, *WrappedError)
- func (self *HttpApiContext) Endpoint() Endpoint
- func (self *HttpApiContext) UploadCheck(oid string, sz int64) (*ObjectResource, *WrappedError)
- func (self *HttpApiContext) UploadObject(o *ObjectResource, reader io.Reader) *WrappedError
- type JsonRequest
- type JsonResponse
- type LimitedReadCloser
- type ObjectResource
- type Pointer
- type ServerVersionRequest
- type ServerVersionResponse
- type SmudgeError
- type SshApiContext
- func (self *SshApiContext) Batch(objects []*ObjectResource) ([]*ObjectResource, *WrappedError)
- func (self *SshApiContext) Close() error
- func (self *SshApiContext) Download(oid string) (io.ReadCloser, int64, *WrappedError)
- func (self *SshApiContext) DownloadCheck(oid string) (*ObjectResource, *WrappedError)
- func (self *SshApiContext) DownloadObject(obj *ObjectResource) (io.ReadCloser, int64, *WrappedError)
- func (self *SshApiContext) Endpoint() Endpoint
- func (self *SshApiContext) ServerVersion() (major, minor, patch int, e error)
- func (self *SshApiContext) UploadCheck(oid string, sz int64) (*ObjectResource, *WrappedError)
- func (self *SshApiContext) UploadObject(o *ObjectResource, content io.Reader) *WrappedError
- type StatefulApiContextHolder
- type TransferQueue
- type Transferable
- type UploadCompleteResponse
- type UploadRequest
- type UploadResponse
- type Uploadable
- type WrappedError
- func Download(oid string) (io.ReadCloser, int64, *WrappedError)
- func DownloadObject(obj *ObjectResource) (io.ReadCloser, int64, *WrappedError)
- func Error(err error) *WrappedError
- func Errorf(err error, format string, args ...interface{}) *WrappedError
- func UploadObject(o *ObjectResource, cb CopyCallback) *WrappedError
- func (e *WrappedError) Context() map[string]string
- func (e *WrappedError) Del(key string)
- func (e *WrappedError) Error() string
- func (e *WrappedError) Errorf(format string, args ...interface{})
- func (e *WrappedError) Get(key string) string
- func (e *WrappedError) InnerError() string
- func (e *WrappedError) Set(key, value string)
- func (e *WrappedError) Stack() []byte
- type WrappedPointer
Constants ¶
const Version = "0.5.1"
Variables ¶
var ( LargeSizeThreshold = 5 * 1024 * 1024 TempDir = filepath.Join(os.TempDir(), "git-lfs") UserAgent string LocalWorkingDir string LocalGitDir string LocalMediaDir string LocalLogDir string )
var (
Config = NewConfig()
)
var (
NotInARepositoryError = errors.New("Not in a repository")
)
Functions ¶
func Batch ¶
func Batch(objects []*ObjectResource) ([]*ObjectResource, *WrappedError)
func CopyWithCallback ¶
func DownloadCheck ¶
func DownloadCheck(oid string) (*ObjectResource, *WrappedError)
func EmbedStructInJsonRawMessage ¶
func EmbedStructInJsonRawMessage(in interface{}) (*json.RawMessage, error)
func ExtractStructFromJsonRawMessage ¶
func ExtractStructFromJsonRawMessage(raw *json.RawMessage, out interface{}) error
Late-bind a method-specific structure from the raw message
func InstallFilters ¶
func InstallFilters() error
func InstallHooks ¶
func LimitReadCloser ¶
func LimitReadCloser(r io.Reader, sz int64) io.ReadCloser
Return an initialised LimitedReadCloser
func LocalMediaPath ¶
func NewUploadable ¶
func NewUploadable(oid, filename string, index, totalFiles int) (*Uploadable, *WrappedError)
NewUploadable builds the Uploadable from the given information.
func PointerClean ¶
func PointerClean(reader io.Reader, size int64, cb CopyCallback) (*cleanedAsset, error)
func PointerSmudge ¶
func PointerSmudgeObject ¶
func PointerSmudgeObject(ptr *Pointer, obj *ObjectResource, cb CopyCallback) error
PointerSmudgeObject uses a Pointer and ObjectResource to download the object to the media directory. It does not write the file to the working directory.
func ReleaseApiContext ¶
func ReleaseApiContext(ctx ApiContext)
Release an API context for use by other callers later. You should call this sometime after GetApiContext once you are done with the context. It allows stateful contexts to re-use resources such as connections between subsequent operations.
func ResetTempDir ¶
func ResetTempDir() error
func UploadCheck ¶
func UploadCheck(oidPath string) (*ObjectResource, *WrappedError)
Types ¶
type ApiContext ¶
type ApiContext interface { // Get the endpoint this context was constructed from Endpoint() Endpoint // Close the context & any resources it's using Close() error // Download a single object, return reader for data, size and any error // Essentially the same as calling DownloadCheck() then DownloadObject() Download(oid string) (io.ReadCloser, int64, *WrappedError) // Check whether an object is available for download and return an object resource if so DownloadCheck(oid string) (*ObjectResource, *WrappedError) // Download a single object from an already identified resource from DownloadCheck(), return reader for data, size and any error DownloadObject(obj *ObjectResource) (io.ReadCloser, int64, *WrappedError) // Check whether an upload would be accepted for an object and return the resource to use if so UploadCheck(oid string, sz int64) (*ObjectResource, *WrappedError) // Perform the actual upload of an object having identified it will be accepted and the resource to use UploadObject(o *ObjectResource, reader io.Reader) *WrappedError // Perform a batch request for a number of objects to determine what can be uploaded/downloaded Batch(objects []*ObjectResource) ([]*ObjectResource, *WrappedError) }
An abstract interface providing state & resource management for a specific Endpoint across potentially multiple requests
func GetApiContext ¶
func GetApiContext(endpoint Endpoint) ApiContext
Return an API context appropriate for a given Endpoint Once this context is returned it may be made *unavailable* to subsequent callers, until ReleaseApiContext is called. This is to ensure that contexts which maintain state are only available to be used by one goroutine at a time.
func NewHttpApiContext ¶
func NewHttpApiContext(endpoint Endpoint) ApiContext
func NewSshApiContext ¶
func NewSshApiContext(endpoint Endpoint) ApiContext
Below here is the pure-SSH API interface The API is basically the same except there's no need for hypermedia links
type ApiContextReadCloser ¶
type ApiContextReadCloser struct {
// contains filtered or unexported fields
}
ReadCloser which will release an ApiContext when reading is finished
func (*ApiContextReadCloser) Close ¶
func (self *ApiContextReadCloser) Close() error
type BatchRequest ¶
type BatchRequest struct {
Objects []BatchRequestObject `json:"objects"`
}
type BatchRequestObject ¶
type BatchResponse ¶
type BatchResponse struct {
Results []BatchResponseObject `json:"results"`
}
type BatchResponseObject ¶
type CallbackReader ¶
type CallbackReader struct { C CopyCallback TotalSize int64 ReadSize int64 io.Reader }
type CleanedPointerError ¶
type CleanedPointerError struct {
Bytes []byte
}
func (*CleanedPointerError) Error ¶
func (e *CleanedPointerError) Error() string
type ClientError ¶
type ClientError struct { Message string `json:"message"` DocumentationUrl string `json:"documentation_url,omitempty"` RequestId string `json:"request_id,omitempty"` }
func (*ClientError) Error ¶
func (e *ClientError) Error() string
type Configuration ¶
type Configuration struct { CurrentRemote string // contains filtered or unexported fields }
func NewConfig ¶
func NewConfig() *Configuration
func (*Configuration) BatchTransfer ¶
func (c *Configuration) BatchTransfer() bool
func (*Configuration) ConcurrentTransfers ¶
func (c *Configuration) ConcurrentTransfers() int
func (*Configuration) Endpoint ¶
func (c *Configuration) Endpoint() Endpoint
func (*Configuration) HttpClient ¶
func (c *Configuration) HttpClient() *http.Client
func (*Configuration) RemoteEndpoint ¶
func (c *Configuration) RemoteEndpoint(remote string) Endpoint
func (*Configuration) Remotes ¶
func (c *Configuration) Remotes() []string
func (*Configuration) SetConfig ¶
func (c *Configuration) SetConfig(key, value string)
type CopyCallback ¶
func CopyCallbackFile ¶
type CredentialCmd ¶
func NewCommand ¶
func NewCommand(input Creds, subCommand string) *CredentialCmd
func (*CredentialCmd) Credentials ¶
func (c *CredentialCmd) Credentials() Creds
func (*CredentialCmd) StdoutString ¶
func (c *CredentialCmd) StdoutString() string
type DownloadCheckRequest ¶
type DownloadCheckRequest struct {
Oid string `json:"oid"`
}
type DownloadCheckResponse ¶
type DownloadCheckResponse struct {
Size int64 `json:"size"`
}
type DownloadRequest ¶
type Downloadable ¶
type Downloadable struct { Pointer *WrappedPointer // contains filtered or unexported fields }
func NewDownloadable ¶
func NewDownloadable(p *WrappedPointer) *Downloadable
func (*Downloadable) Check ¶
func (d *Downloadable) Check() (*ObjectResource, *WrappedError)
func (*Downloadable) Object ¶
func (d *Downloadable) Object() *ObjectResource
func (*Downloadable) Oid ¶
func (d *Downloadable) Oid() string
func (*Downloadable) SetObject ¶
func (d *Downloadable) SetObject(o *ObjectResource)
func (*Downloadable) Size ¶
func (d *Downloadable) Size() int64
func (*Downloadable) Transfer ¶
func (d *Downloadable) Transfer(cb CopyCallback) *WrappedError
type Endpoint ¶
func NewEndpoint ¶
type ExitRequest ¶
type ExitRequest struct { }
type ExitResponse ¶
type ExitResponse struct { }
type HookExists ¶
func (*HookExists) Error ¶
func (e *HookExists) Error() string
type HttpApiContext ¶
type HttpApiContext struct {
// contains filtered or unexported fields
}
HTTP specific API contect implementation HTTP implementation of ApiContext
func (*HttpApiContext) Batch ¶
func (self *HttpApiContext) Batch(objects []*ObjectResource) ([]*ObjectResource, *WrappedError)
func (*HttpApiContext) Close ¶
func (*HttpApiContext) Close() error
func (*HttpApiContext) Download ¶
func (self *HttpApiContext) Download(oid string) (io.ReadCloser, int64, *WrappedError)
func (*HttpApiContext) DownloadCheck ¶
func (self *HttpApiContext) DownloadCheck(oid string) (*ObjectResource, *WrappedError)
func (*HttpApiContext) DownloadObject ¶
func (self *HttpApiContext) DownloadObject(obj *ObjectResource) (io.ReadCloser, int64, *WrappedError)
func (*HttpApiContext) Endpoint ¶
func (self *HttpApiContext) Endpoint() Endpoint
func (*HttpApiContext) UploadCheck ¶
func (self *HttpApiContext) UploadCheck(oid string, sz int64) (*ObjectResource, *WrappedError)
func (*HttpApiContext) UploadObject ¶
func (self *HttpApiContext) UploadObject(o *ObjectResource, reader io.Reader) *WrappedError
type JsonRequest ¶
type JsonRequest struct { Id int `json:"id"` Method string `json:"method"` // RawMessage allows us to store late-resolved, message-specific nested types // requires an extra couple of steps though; even though RawMessage is a []byte, it's not // JSON itself. You need to convert JSON to/from RawMessage as well as JSON to/from the structure // - see RawMessage's own UnmarshalJSON/MarshalJSON for this extra step Params *json.RawMessage `json:"params"` }
Utility methods for JSON-RPC style request/response over SSH This works for any persistent connection and could be used elsewhere too but for now, localised Note *not* using net/rpc and net/rpc/jsonrpc because we want more control golang's rpc requires a certain method format (Object.Method) and also doesn't easily support interleaving with raw byte streams like we need to. as per http://www.jsonrpc.org/specification
func NewJsonRequest ¶
func NewJsonRequest(method string, params interface{}) (*JsonRequest, error)
type JsonResponse ¶
type JsonResponse struct { Id int `json:"id"` Error interface{} `json:"error"` // RawMessage allows us to store late-resolved, message-specific nested types // requires an extra couple of steps though; even though RawMessage is a []byte, it's not // JSON itself. You need to convert JSON to/from RawMessage as well as JSON to/from the structure // - see RawMessage's own UnmarshalJSON/MarshalJSON for this extra step Result *json.RawMessage `json:"result"` }
func NewJsonErrorResponse ¶
func NewJsonErrorResponse(id int, err interface{}) *JsonResponse
func NewJsonResponse ¶
func NewJsonResponse(id int, result interface{}) (*JsonResponse, error)
type LimitedReadCloser ¶
type LimitedReadCloser struct {
// contains filtered or unexported fields
}
A wrapper around a reader for a multi-purpose stream which reads exactly a number of bytes before returning EOF, so that 'read to end' and 'close' just read the fixed number of bytes and leaves the stream available for subsequent use by others This is just like io.LimitedReader but responds to Close() too
func (*LimitedReadCloser) Close ¶
func (self *LimitedReadCloser) Close() error
type ObjectResource ¶
type ObjectResource struct { Oid string `json:"oid,omitempty"` Size int64 `json:"size"` Links map[string]*linkRelation `json:"_links,omitempty"` }
func (*ObjectResource) CanDownload ¶
func (o *ObjectResource) CanDownload() bool
func (*ObjectResource) CanUpload ¶
func (o *ObjectResource) CanUpload() bool
func (*ObjectResource) NewRequest ¶
func (o *ObjectResource) NewRequest(ctx *HttpApiContext, relation, method string) (*http.Request, Creds, error)
func (*ObjectResource) Rel ¶
func (o *ObjectResource) Rel(name string) (*linkRelation, bool)
type Pointer ¶
func NewPointer ¶
type ServerVersionRequest ¶
type ServerVersionRequest struct { }
type ServerVersionResponse ¶
type SmudgeError ¶
type SmudgeError struct { Oid string Filename string *WrappedError }
type SshApiContext ¶
type SshApiContext struct {
// contains filtered or unexported fields
}
func NewManualSSHApiContext ¶
func NewManualSSHApiContext(in io.WriteCloser, out io.ReadCloser) *SshApiContext
Create a manually initialised API context where I/O is already running
func (*SshApiContext) Batch ¶
func (self *SshApiContext) Batch(objects []*ObjectResource) ([]*ObjectResource, *WrappedError)
func (*SshApiContext) Close ¶
func (self *SshApiContext) Close() error
func (*SshApiContext) Download ¶
func (self *SshApiContext) Download(oid string) (io.ReadCloser, int64, *WrappedError)
func (*SshApiContext) DownloadCheck ¶
func (self *SshApiContext) DownloadCheck(oid string) (*ObjectResource, *WrappedError)
func (*SshApiContext) DownloadObject ¶
func (self *SshApiContext) DownloadObject(obj *ObjectResource) (io.ReadCloser, int64, *WrappedError)
func (*SshApiContext) Endpoint ¶
func (self *SshApiContext) Endpoint() Endpoint
func (*SshApiContext) ServerVersion ¶
func (self *SshApiContext) ServerVersion() (major, minor, patch int, e error)
Get the version of the SSH server
func (*SshApiContext) UploadCheck ¶
func (self *SshApiContext) UploadCheck(oid string, sz int64) (*ObjectResource, *WrappedError)
func (*SshApiContext) UploadObject ¶
func (self *SshApiContext) UploadObject(o *ObjectResource, content io.Reader) *WrappedError
type StatefulApiContextHolder ¶
type StatefulApiContextHolder struct {
// contains filtered or unexported fields
}
Holds limited number of stateful ApiContext instances & parcels them out via queues
type TransferQueue ¶
type TransferQueue struct {
// contains filtered or unexported fields
}
TransferQueue provides a queue that will allow concurrent transfers.
func NewDownloadQueue ¶
func NewDownloadQueue(workers, files int) *TransferQueue
NewDownloadQueue builds a DownloadQueue, allowing `workers` concurrent downloads.
func NewUploadQueue ¶
func NewUploadQueue(workers, files int) *TransferQueue
NewUploadQueue builds an UploadQueue, allowing `workers` concurrent uploads.
func (*TransferQueue) Add ¶
func (q *TransferQueue) Add(t Transferable)
Add adds a Transferable to the transfer queue.
func (*TransferQueue) Errors ¶
func (q *TransferQueue) Errors() []*WrappedError
Errors returns any errors encountered during transfer.
func (*TransferQueue) Process ¶
func (q *TransferQueue) Process()
Process starts the transfer queue and displays a progress bar. Process will do individual or batch transfers depending on the Config.BatchTransfer() value. Process will transfer files sequentially or concurrently depending on the Concig.ConcurrentTransfers() value.
func (*TransferQueue) Watch ¶
func (q *TransferQueue) Watch() chan string
Watch returns a channel where the queue will write the OID of each transfer as it completes. The channel will be closed when the queue finishes processing.
type Transferable ¶
type Transferable interface { Check() (*ObjectResource, *WrappedError) Transfer(CopyCallback) *WrappedError Object() *ObjectResource Oid() string Size() int64 SetObject(*ObjectResource) }
type UploadCompleteResponse ¶
type UploadCompleteResponse struct {
ReceivedOk bool `json:"receivedOk"`
}
type UploadRequest ¶
type UploadResponse ¶
type UploadResponse struct {
OkToSend bool `json:"okToSend"`
}
type Uploadable ¶
type Uploadable struct { OidPath string Filename string CB CopyCallback // contains filtered or unexported fields }
Uploadable describes a file that can be uploaded.
func (*Uploadable) Check ¶
func (u *Uploadable) Check() (*ObjectResource, *WrappedError)
func (*Uploadable) Object ¶
func (u *Uploadable) Object() *ObjectResource
func (*Uploadable) Oid ¶
func (u *Uploadable) Oid() string
func (*Uploadable) SetObject ¶
func (u *Uploadable) SetObject(o *ObjectResource)
func (*Uploadable) Size ¶
func (u *Uploadable) Size() int64
func (*Uploadable) Transfer ¶
func (u *Uploadable) Transfer(cb CopyCallback) *WrappedError
type WrappedError ¶
type WrappedError struct { Err error Message string Panic bool // contains filtered or unexported fields }
func Download ¶
func Download(oid string) (io.ReadCloser, int64, *WrappedError)
func DownloadObject ¶
func DownloadObject(obj *ObjectResource) (io.ReadCloser, int64, *WrappedError)
func Error ¶
func Error(err error) *WrappedError
func Errorf ¶
func Errorf(err error, format string, args ...interface{}) *WrappedError
func UploadObject ¶
func UploadObject(o *ObjectResource, cb CopyCallback) *WrappedError
func (*WrappedError) Context ¶
func (e *WrappedError) Context() map[string]string
func (*WrappedError) Del ¶
func (e *WrappedError) Del(key string)
func (*WrappedError) Error ¶
func (e *WrappedError) Error() string
func (*WrappedError) Errorf ¶
func (e *WrappedError) Errorf(format string, args ...interface{})
func (*WrappedError) Get ¶
func (e *WrappedError) Get(key string) string
func (*WrappedError) InnerError ¶
func (e *WrappedError) InnerError() string
func (*WrappedError) Set ¶
func (e *WrappedError) Set(key, value string)
func (*WrappedError) Stack ¶
func (e *WrappedError) Stack() []byte
type WrappedPointer ¶
type WrappedPointer struct { Sha1 string Name string SrcName string Size int64 Status string *Pointer }
WrappedPointer wraps a pointer.Pointer and provides the git sha1 and the file name associated with the object, taken from the rev-list output.
func ScanIndex ¶
func ScanIndex() ([]*WrappedPointer, error)
ScanIndex returns a slice of WrappedPointer objects for all Git LFS pointers it finds in the index.
func ScanRefs ¶
func ScanRefs(refLeft, refRight string) ([]*WrappedPointer, error)
ScanRefs takes a ref and returns a slice of WrappedPointer objects for all Git LFS pointers it finds for that ref.