Documentation
¶
Index ¶
- Variables
- func ContentMatcher(r *http.Request, m *mux.RouteMatch) bool
- func MetaMatcher(r *http.Request, m *mux.RouteMatch) bool
- type App
- func (a *App) BatchHandler(w http.ResponseWriter, r *http.Request)
- func (a *App) CreateLockHandler(w http.ResponseWriter, r *http.Request)
- func (a *App) DeleteLockHandler(w http.ResponseWriter, r *http.Request)
- func (a *App) GetContentHandler(w http.ResponseWriter, r *http.Request)
- func (a *App) GetMetaHandler(w http.ResponseWriter, r *http.Request)
- func (a *App) LocksHandler(w http.ResponseWriter, r *http.Request)
- func (a *App) LocksVerifyHandler(w http.ResponseWriter, r *http.Request)
- func (a *App) PostHandler(w http.ResponseWriter, r *http.Request)
- func (a *App) PutHandler(w http.ResponseWriter, r *http.Request)
- func (a *App) Represent(rv *RequestVars, meta *MetaObject, download, upload, useTus bool) *Representation
- func (a *App) Serve(l net.Listener) error
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *App) VerifyHandler(w http.ResponseWriter, r *http.Request)
- type BatchResponse
- type BatchVars
- type Configuration
- type ContentStore
- type KVLogger
- type Lock
- type LockList
- type LockRequest
- type LockResponse
- type LocksByCreatedAt
- type MetaObject
- type MetaStore
- func (s *MetaStore) AddLocks(repo string, l ...Lock) error
- func (s *MetaStore) AddUser(user, pass string) error
- func (s *MetaStore) AllLocks() ([]Lock, error)
- func (s *MetaStore) Authenticate(user, password string) (string, bool)
- func (s *MetaStore) Close()
- func (s *MetaStore) Delete(v *RequestVars) error
- func (s *MetaStore) DeleteLock(repo, user, id string, force bool) (*Lock, error)
- func (s *MetaStore) DeleteUser(user string) error
- func (s *MetaStore) FilteredLocks(repo, path, cursor, limit string) (locks []Lock, next string, err error)
- func (s *MetaStore) Get(v *RequestVars) (*MetaObject, error)
- func (s *MetaStore) Locks(repo string) ([]Lock, error)
- func (s *MetaStore) Objects() ([]*MetaObject, error)
- func (s *MetaStore) Put(v *RequestVars) (*MetaObject, error)
- func (s *MetaStore) UnsafeGet(v *RequestVars) (*MetaObject, error)
- func (s *MetaStore) Users() ([]*MetaUser, error)
- type MetaUser
- type ObjectError
- type Representation
- type RequestVars
- type TrackingListener
- type TusServer
- type UnlockRequest
- type UnlockResponse
- type User
- type VerifiableLockList
- type VerifiableLockRequest
Constants ¶
This section is empty.
Variables ¶
var Config = &Configuration{}
Config is the global app configuration
Functions ¶
func ContentMatcher ¶
func ContentMatcher(r *http.Request, m *mux.RouteMatch) bool
ContentMatcher provides a mux.MatcherFunc that only allows requests that contain an Accept header with the contentMediaType
func MetaMatcher ¶
func MetaMatcher(r *http.Request, m *mux.RouteMatch) bool
MetaMatcher provides a mux.MatcherFunc that only allows requests that contain an Accept header with the metaMediaType
Types ¶
type App ¶
type App struct {
Middleware mux.MiddlewareFunc
// contains filtered or unexported fields
}
App links a Router, ContentStore, and MetaStore to provide the LFS server.
func NewApp ¶
func NewApp(config *Configuration, content *ContentStore, meta *MetaStore) *App
NewApp creates a new App using the ContentStore and MetaStore provided
func (*App) BatchHandler ¶
func (a *App) BatchHandler(w http.ResponseWriter, r *http.Request)
BatchHandler provides the batch api
func (*App) CreateLockHandler ¶
func (a *App) CreateLockHandler(w http.ResponseWriter, r *http.Request)
func (*App) DeleteLockHandler ¶
func (a *App) DeleteLockHandler(w http.ResponseWriter, r *http.Request)
func (*App) GetContentHandler ¶
func (a *App) GetContentHandler(w http.ResponseWriter, r *http.Request)
GetContentHandler gets the content from the content store
func (*App) GetMetaHandler ¶
func (a *App) GetMetaHandler(w http.ResponseWriter, r *http.Request)
GetMetaHandler retrieves metadata about the object
func (*App) LocksHandler ¶
func (a *App) LocksHandler(w http.ResponseWriter, r *http.Request)
func (*App) LocksVerifyHandler ¶
func (a *App) LocksVerifyHandler(w http.ResponseWriter, r *http.Request)
func (*App) PostHandler ¶
func (a *App) PostHandler(w http.ResponseWriter, r *http.Request)
PostHandler instructs the client how to upload data
func (*App) PutHandler ¶
func (a *App) PutHandler(w http.ResponseWriter, r *http.Request)
PutHandler receives data from the client and puts it into the content store
func (*App) Represent ¶
func (a *App) Represent(rv *RequestVars, meta *MetaObject, download, upload, useTus bool) *Representation
Represent takes a RequestVars and Meta and turns it into a Representation suitable for json encoding
func (*App) VerifyHandler ¶
func (a *App) VerifyHandler(w http.ResponseWriter, r *http.Request)
type BatchResponse ¶
type BatchResponse struct {
Transfer string `json:"transfer,omitempty"`
Objects []*Representation `json:"objects"`
}
type BatchVars ¶
type BatchVars struct {
Transfers []string `json:"transfers,omitempty"`
Operation string `json:"operation"`
Objects []*RequestVars `json:"objects"`
}
type Configuration ¶
type Configuration struct {
Listen string `config:"tcp://:8080"`
Host string `config:"localhost:8080"`
ExtOrigin string `config:""` // consider lfs-test-server may behind a reverse proxy
MetaDB string `config:"lfs.db"`
ContentPath string `config:"lfs-content"`
AdminUser string `config:""`
AdminPass string `config:""`
Cert string `config:""`
Key string `config:""`
Scheme string `config:"http"`
Public string `config:"public"`
UseTus string `config:"false"`
TusHost string `config:"localhost:1080"`
}
Configuration holds application configuration. Values will be pulled from environment variables, prefixed by keyPrefix. Default values can be added via tags.
func (*Configuration) IsHTTPS ¶
func (c *Configuration) IsHTTPS() bool
func (*Configuration) IsPublic ¶
func (c *Configuration) IsPublic() bool
func (*Configuration) IsUsingTus ¶
func (c *Configuration) IsUsingTus() bool
type ContentStore ¶
type ContentStore struct {
// contains filtered or unexported fields
}
ContentStore provides a simple file system based storage.
func NewContentStore ¶
func NewContentStore(base string) (*ContentStore, error)
NewContentStore creates a ContentStore at the base directory.
func (*ContentStore) Exists ¶
func (s *ContentStore) Exists(meta *MetaObject) bool
Exists returns true if the object exists in the content store.
func (*ContentStore) Get ¶
func (s *ContentStore) Get(meta *MetaObject, fromByte int64) (io.ReadCloser, error)
Get takes a Meta object and retreives the content from the store, returning it as an io.ReaderCloser. If fromByte > 0, the reader starts from that byte
func (*ContentStore) Put ¶
func (s *ContentStore) Put(meta *MetaObject, r io.Reader) error
Put takes a Meta object and an io.Reader and writes the content to the store.
type KVLogger ¶
type KVLogger struct {
// contains filtered or unexported fields
}
KVLogger provides a logger that logs data in key/value pairs.
func NewKVLogger ¶
NewKVLogger creates a KVLogger that writes to `out`.
type LockRequest ¶
type LockRequest struct {
Path string `json:"path"`
}
type LockResponse ¶
type LocksByCreatedAt ¶
type LocksByCreatedAt []Lock
func (LocksByCreatedAt) Len ¶
func (c LocksByCreatedAt) Len() int
func (LocksByCreatedAt) Less ¶
func (c LocksByCreatedAt) Less(i, j int) bool
func (LocksByCreatedAt) Swap ¶
func (c LocksByCreatedAt) Swap(i, j int)
type MetaObject ¶
MetaObject is object metadata as seen by the object and metadata stores.
type MetaStore ¶
type MetaStore struct {
// contains filtered or unexported fields
}
MetaStore implements a metadata storage. It stores user credentials and Meta information for objects. The storage is handled by boltdb.
func NewMetaStore ¶
func NewMetaStore(config *Configuration, dbFile string) (*MetaStore, error)
NewMetaStore creates a new MetaStore using the boltdb database at dbFile.
func (*MetaStore) AllLocks ¶
AllLocks return all locks in the store, lock path is prepended with repo
func (*MetaStore) Authenticate ¶
Authenticate authorizes user with password and returns the user name
func (*MetaStore) Delete ¶
func (s *MetaStore) Delete(v *RequestVars) error
Delete removes the meta information from RequestVars to the store.
func (*MetaStore) DeleteLock ¶
DeleteLock removes lock for the repo by id from the store
func (*MetaStore) DeleteUser ¶
DeleteUser removes user credentials from the meta store.
func (*MetaStore) FilteredLocks ¶
func (s *MetaStore) FilteredLocks(repo, path, cursor, limit string) (locks []Lock, next string, err error)
FilteredLocks return filtered locks for the repo
func (*MetaStore) Get ¶
func (s *MetaStore) Get(v *RequestVars) (*MetaObject, error)
Get retrieves the Meta information for an object given information in RequestVars
func (*MetaStore) Objects ¶
func (s *MetaStore) Objects() ([]*MetaObject, error)
Objects returns all MetaObjects in the meta store
func (*MetaStore) Put ¶
func (s *MetaStore) Put(v *RequestVars) (*MetaObject, error)
Put writes meta information from RequestVars to the store.
func (*MetaStore) UnsafeGet ¶
func (s *MetaStore) UnsafeGet(v *RequestVars) (*MetaObject, error)
Get retrieves the Meta information for an object given information in RequestVars DO NOT CHECK authentication, as it is supposed to have been done before
type MetaUser ¶
type MetaUser struct {
Name string
}
MetaUser encapsulates information about a meta store user
type ObjectError ¶
type Representation ¶
type Representation struct {
Oid string `json:"oid"`
Size int64 `json:"size"`
Actions map[string]*link `json:"actions"`
Error *ObjectError `json:"error,omitempty"`
}
Representation is object medata as seen by clients of the lfs server.
type RequestVars ¶
type RequestVars struct {
Oid string
Size int64
User string
Password string
Repo string
Authorization string
// contains filtered or unexported fields
}
RequestVars contain variables from the HTTP request. Variables from routing, json body decoding, and some headers are stored.
func (*RequestVars) DownloadLink ¶
func (v *RequestVars) DownloadLink() string
DownloadLink builds a URL to download the object.
func (*RequestVars) UploadLink ¶
func (v *RequestVars) UploadLink(useTus bool) string
UploadLink builds a URL to upload the object.
func (*RequestVars) VerifyLink ¶
func (v *RequestVars) VerifyLink() string
type TrackingListener ¶
TrackingListener tracks incoming connections so that application shutdown can wait until all in progress connections are finished before exiting.
func NewTrackingListener ¶
func NewTrackingListener(addr string) (*TrackingListener, error)
NewTrackingListener creates a new TrackingListener, listening on the supplied address.
func (*TrackingListener) Accept ¶
func (l *TrackingListener) Accept() (net.Conn, error)
Accept wraps the underlying net.Listener's Accept(), keeping track of all connections accepted.
func (*TrackingListener) WaitForChildren ¶
func (l *TrackingListener) WaitForChildren()
WaitForChildren is called during shutdown. It will return once all the existing connections have finished.
type TusServer ¶
type TusServer struct {
// contains filtered or unexported fields
}
func (*TusServer) Create ¶
Create a new upload URL for the given object Required to call CREATE on the tus API before uploading but not part of LFS API
func (*TusServer) Finish ¶
func (t *TusServer) Finish(oid string, store *ContentStore) error
Move the finished uploaded data from TUS to the content store (called by verify)
type UnlockRequest ¶
type UnlockRequest struct {
Force bool `json:"force"`
}