From ee5e1c4a88f2f075587bfbc39438b6d6b1c3044e Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Sun, 6 Jun 2021 01:59:27 +0200 Subject: Rewrite of the LFS server (#15523) * Restructured code. Moved static checks out of loop. * Restructured batch api. Add support for individual errors. * Let router decide if LFS is enabled. * Renamed methods. * Return correct status from verify handler. * Unified media type check in router. * Changed error code according to spec. * Moved checks into router. * Removed invalid v1 api methods. * Unified methods. * Display better error messages. * Added size parameter. Create meta object on upload. * Use object error on invalid size. * Skip upload if object exists. * Moved methods. * Suppress fields in response. * Changed error on accept. * Added tests. * Use ErrorResponse object. * Test against message property. * Add support for the old invalid lfs client. * Fixed the check because MinIO wraps the error. * Use individual repositories. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH --- modules/lfs/shared.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'modules/lfs/shared.go') diff --git a/modules/lfs/shared.go b/modules/lfs/shared.go index 70b76d7512..9abbf85fbd 100644 --- a/modules/lfs/shared.go +++ b/modules/lfs/shared.go @@ -45,7 +45,7 @@ type BatchResponse struct { // ObjectResponse is object metadata as seen by clients of the LFS server. type ObjectResponse struct { Pointer - Actions map[string]*Link `json:"actions"` + Actions map[string]*Link `json:"actions,omitempty"` Error *ObjectError `json:"error,omitempty"` } @@ -53,7 +53,7 @@ type ObjectResponse struct { type Link struct { Href string `json:"href"` Header map[string]string `json:"header,omitempty"` - ExpiresAt time.Time `json:"expires_at,omitempty"` + ExpiresAt *time.Time `json:"expires_at,omitempty"` } // ObjectError defines the JSON structure returned to the client in case of an error @@ -67,3 +67,10 @@ type PointerBlob struct { Hash string Pointer } + +// ErrorResponse describes the error to the client. +type ErrorResponse struct { + Message string + DocumentationURL string `json:"documentation_url,omitempty"` + RequestID string `json:"request_id,omitempty"` +} -- cgit v1.2.3