lfs

package
v0.0.0-...-1054e26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 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 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 Lock

type Lock struct {
	Id       string    `json:"id"`
	Path     string    `json:"path"`
	Owner    User      `json:"owner"`
	LockedAt time.Time `json:"locked_at"`
}

type LockList

type LockList struct {
	Locks      []Lock `json:"locks"`
	NextCursor string `json:"next_cursor,omitempty"`
	Message    string `json:"message,omitempty"`
}

type LockRequest

type LockRequest struct {
	Path string `json:"path"`
}

type LockResponse

type LockResponse struct {
	Lock    *Lock  `json:"lock"`
	Message string `json:"message,omitempty"`
}

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

type MetaObject struct {
	Oid      string `json:"oid"`
	Size     int64  `json:"size"`
	Existing bool
}

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(dbFile string) (*MetaStore, error)

NewMetaStore creates a new MetaStore using the boltdb database at dbFile.

func (*MetaStore) AddLocks

func (s *MetaStore) AddLocks(repo string, l ...Lock) error

AddLocks write locks to the store for the repo.

func (*MetaStore) AllLocks

func (s *MetaStore) AllLocks() ([]Lock, error)

AllLocks return all locks in the store, lock path is prepended with repo

func (*MetaStore) Close

func (s *MetaStore) Close()

Close closes the underlying boltdb.

func (*MetaStore) Delete

func (s *MetaStore) Delete(v *RequestVars) error

Delete removes the meta information from RequestVars to the store.

func (*MetaStore) DeleteLock

func (s *MetaStore) DeleteLock(repo, user, id string, force bool) (*Lock, error)

DeleteLock removes lock for the repo by id from the 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) Locks

func (s *MetaStore) Locks(repo string) ([]Lock, error)

Locks retrieves locks for the repo from the store

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 ObjectError

type ObjectError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

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
	Authorization string
}

RequestVars contain variables from the HTTP request. Variables from routing, json body decoding, and some headers are stored.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server links ContentStore, and MetaStore to provide the LFS server.

func NewServer

func NewServer(content *ContentStore, meta *MetaStore) *Server

NewServer creates a new App using the ContentStore and MetaStore provided

func (*Server) BatchHandler

func (s *Server) BatchHandler(w http.ResponseWriter, r *http.Request)

func (*Server) CreateLockHandler

func (s *Server) CreateLockHandler(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteLockHandler

func (s *Server) DeleteLockHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GetContentHandler

func (s *Server) GetContentHandler(w http.ResponseWriter, r *http.Request)

func (*Server) GetMetaHandler

func (s *Server) GetMetaHandler(w http.ResponseWriter, r *http.Request)

func (*Server) LocksHandler

func (s *Server) LocksHandler(w http.ResponseWriter, r *http.Request)

func (*Server) LocksVerifyHandler

func (s *Server) LocksVerifyHandler(w http.ResponseWriter, r *http.Request)

func (*Server) PostHandler

func (s *Server) PostHandler(w http.ResponseWriter, r *http.Request)

func (*Server) PutHandler

func (s *Server) PutHandler(w http.ResponseWriter, r *http.Request)

func (*Server) Represent

func (s *Server) Represent(rv *RequestVars, meta *MetaObject, url string, download, upload bool) *Representation

func (*Server) VerifyHandler

func (s *Server) VerifyHandler(w http.ResponseWriter, r *http.Request)

type UnlockRequest

type UnlockRequest struct {
	Force bool `json:"force"`
}

type UnlockResponse

type UnlockResponse struct {
	Lock    *Lock  `json:"lock"`
	Message string `json:"message,omitempty"`
}

type User

type User struct {
	Name string `json:"name"`
}

type VerifiableLockList

type VerifiableLockList struct {
	Ours       []Lock `json:"ours"`
	Theirs     []Lock `json:"theirs"`
	NextCursor string `json:"next_cursor,omitempty"`
	Message    string `json:"message,omitempty"`
}

type VerifiableLockRequest

type VerifiableLockRequest struct {
	Cursor string `json:"cursor,omitempty"`
	Limit  int    `json:"limit,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL