diff --git a/api/errors.go b/api/errors.go index a0e6e39b..6fb52b4e 100644 --- a/api/errors.go +++ b/api/errors.go @@ -118,7 +118,7 @@ const ( ErrInvalidTagDirective // Add new error codes here. - // SSE-S3 related API errors + // SSE-S3 related API errors. ErrInvalidEncryptionMethod // Server-Side-Encryption (with Customer provided key) related API errors. @@ -157,8 +157,8 @@ const ( // Add new extended error codes here. // MinIO extended errors. - // ErrReadQuorum - // ErrWriteQuorum + // ErrReadQuorum + // ErrWriteQuorum ErrParentIsObject ErrStorageFull ErrRequestBodyParse @@ -170,7 +170,7 @@ const ( ErrOperationTimedOut ErrOperationMaxedOut ErrInvalidRequest - // MinIO storage class error codes + // MinIO storage class error codes. ErrInvalidStorageClass ErrBackendDown // Add new extended error codes here. @@ -192,7 +192,7 @@ const ( ErrAdminCredentialsMismatch ErrInsecureClientRequest ErrObjectTampered - // Bucket Quota error codes + // Bucket Quota error codes. ErrAdminBucketQuotaExceeded ErrAdminNoSuchQuotaConfiguration ErrAdminBucketQuotaDisabled @@ -205,7 +205,7 @@ const ( ErrHealOverlappingPaths ErrIncorrectContinuationToken - // S3 Select Errors + // S3 Select Errors. ErrEmptyRequestBody ErrUnsupportedFunction ErrInvalidExpressionType @@ -1625,7 +1625,7 @@ func GetAPIError(code ErrorCode) Error { } // getErrorResponse gets in standard error and resource value and -// provides a encodable populated response values +// provides a encodable populated response values. func getAPIErrorResponse(ctx context.Context, err error, resource, requestID, hostID string) ErrorResponse { code := "BadRequest" desc := err.Error() @@ -1803,21 +1803,21 @@ func (e BucketLifecycleNotFound) Error() string { return "No bucket lifecycle configuration found for bucket : " + e.Bucket } -// BucketSSEConfigNotFound - no bucket encryption found +// BucketSSEConfigNotFound - no bucket encryption found. type BucketSSEConfigNotFound GenericError func (e BucketSSEConfigNotFound) Error() string { return "No bucket encryption configuration found for bucket: " + e.Bucket } -// BucketTaggingNotFound - no bucket tags found +// BucketTaggingNotFound - no bucket tags found. type BucketTaggingNotFound GenericError func (e BucketTaggingNotFound) Error() string { return "No bucket tags found for bucket: " + e.Bucket } -// BucketObjectLockConfigNotFound - no bucket object lock config found +// BucketObjectLockConfigNotFound - no bucket object lock config found. type BucketObjectLockConfigNotFound GenericError func (e BucketObjectLockConfigNotFound) Error() string { @@ -1874,7 +1874,7 @@ func (e ObjectNamePrefixAsSlash) Error() string { return "Object name contains forward slash as pefix: " + e.Bucket + "#" + e.Object } -// AllAccessDisabled All access to this object has been disabled +// AllAccessDisabled All access to this object has been disabled. type AllAccessDisabled GenericError // Error returns string an error formatted as the given text. @@ -1945,7 +1945,7 @@ func (e InvalidUploadID) Error() string { return "Invalid upload id " + e.UploadID } -// InvalidPart One or more of the specified parts could not be found +// InvalidPart One or more of the specified parts could not be found. type InvalidPart struct { PartNumber int ExpETag string @@ -1975,21 +1975,21 @@ func (e PartTooBig) Error() string { return "Part size bigger than the allowed limit" } -// InvalidETag error returned when the etag has changed on disk +// InvalidETag error returned when the etag has changed on disk. type InvalidETag struct{} func (e InvalidETag) Error() string { return "etag of the object has changed" } -// NotImplemented If a feature is not implemented +// NotImplemented If a feature is not implemented. type NotImplemented struct{} func (e NotImplemented) Error() string { return "Not Implemented" } -// UnsupportedMetadata - unsupported metadata +// UnsupportedMetadata - unsupported metadata. type UnsupportedMetadata struct{} func (e UnsupportedMetadata) Error() string { @@ -2003,14 +2003,14 @@ func (e BackendDown) Error() string { return "Backend down" } -// PreConditionFailed - Check if copy precondition failed +// PreConditionFailed - Check if copy precondition failed. type PreConditionFailed struct{} func (e PreConditionFailed) Error() string { return "At least one of the pre-conditions you specified did not hold" } -// DeleteError - returns when cant remove object +// DeleteError - returns when cant remove object. type DeleteError struct { Err error Object string diff --git a/api/handler/delete.go b/api/handler/delete.go index e99d4731..72e2da22 100644 --- a/api/handler/delete.go +++ b/api/handler/delete.go @@ -68,7 +68,7 @@ func (h *handler) DeleteObjectHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) } -// DeleteMultipleObjectsHandler : +// DeleteMultipleObjectsHandler handles multiple delete requests. func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Request) { var ( req = mux.Vars(r) diff --git a/api/handler/response.go b/api/handler/response.go index c44e71b1..cccdd23d 100644 --- a/api/handler/response.go +++ b/api/handler/response.go @@ -2,7 +2,7 @@ package handler import "encoding/xml" -// ListBucketsResponse - format for list buckets response +// ListBucketsResponse - format for list buckets response. type ListBucketsResponse struct { XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult" json:"-"` @@ -45,13 +45,13 @@ type ListObjectsV2Response struct { EncodingType string `xml:"EncodingType,omitempty"` } -// Bucket container for bucket metadata +// Bucket container for bucket metadata. type Bucket struct { Name string CreationDate string // time string of format "2006-01-02T15:04:05.000Z" } -// Owner - bucket owner/principal +// Owner - bucket owner/principal. type Owner struct { ID string DisplayName string @@ -87,12 +87,12 @@ type ListObjectsResponse struct { EncodingType string `xml:"EncodingType,omitempty"` } -// CommonPrefix container for prefix response in ListObjectsResponse +// CommonPrefix container for prefix response in ListObjectsResponse. type CommonPrefix struct { Prefix string } -// Object container for object metadata +// Object container for object metadata. type Object struct { Key string LastModified string // time string of format "2006-01-02T15:04:05.000Z" @@ -118,7 +118,7 @@ type LocationResponse struct { Location string `xml:",chardata"` } -// CopyObjectResponse container returns ETag and LastModified of the successfully copied object +// CopyObjectResponse container returns ETag and LastModified of the successfully copied object. type CopyObjectResponse struct { XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CopyObjectResult" json:"-"` LastModified string // time string of format "2006-01-02T15:04:05.000Z" diff --git a/api/headers.go b/api/headers.go index 225e24f2..085e3f77 100644 --- a/api/headers.go +++ b/api/headers.go @@ -1,6 +1,6 @@ package api -// Standard S3 HTTP response constants +// Standard S3 HTTP response constants. const ( LastModified = "Last-Modified" Date = "Date" diff --git a/api/layer/layer.go b/api/layer/layer.go index 2f88eae2..927c0279 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -103,7 +103,7 @@ func (n *layer) Owner(ctx context.Context) *owner.ID { return n.cli.Owner() } -// Get NeoFS Object by refs.Address (should be used by auth.Center) +// Get NeoFS Object by refs.Address (should be used by auth.Center). func (n *layer) Get(ctx context.Context, address *object.Address) (*object.Object, error) { return n.cli.Object().Get(ctx, address) } diff --git a/api/metrics/api.go b/api/metrics/api.go index d72297a6..56b40638 100644 --- a/api/metrics/api.go +++ b/api/metrics/api.go @@ -20,7 +20,7 @@ type ( } // HTTPStats holds statistics information about - // HTTP requests made by all clients + // HTTP requests made by all clients. HTTPStats struct { currentS3Requests HTTPAPIStats totalS3Requests HTTPAPIStats @@ -63,8 +63,8 @@ var ( ) ) -// collects http metrics for NeoFS S3 Gate in Prometheus specific format -// and sends to given channel +// Collects HTTP metrics for NeoFS S3 Gate in Prometheus specific format +// and sends to given channel. func collectHTTPMetrics(ch chan<- prometheus.Metric) { for api, value := range httpStatsMetric.currentS3Requests.Load() { ch <- prometheus.MustNewConstMetric( @@ -176,7 +176,7 @@ func (st *HTTPStats) getOutputBytes() uint64 { return atomic.LoadUint64(&st.totalOutputBytes) } -// Update statistics from http request and response data +// Update statistics from http request and response data. func (st *HTTPStats) updateStats(api string, w http.ResponseWriter, r *http.Request, durationSecs float64) { var code int @@ -200,7 +200,7 @@ func (st *HTTPStats) updateStats(api string, w http.ResponseWriter, r *http.Requ } } -// WriteHeader - writes http status code +// WriteHeader - writes http status code. func (w *responseWrapper) WriteHeader(code int) { w.Do(func() { w.statusCode = code diff --git a/api/reqinfo.go b/api/reqinfo.go index 606ada4e..374a1308 100644 --- a/api/reqinfo.go +++ b/api/reqinfo.go @@ -13,7 +13,7 @@ import ( ) type ( - // KeyVal - appended to ReqInfo.Tags + // KeyVal - appended to ReqInfo.Tags. KeyVal struct { Key string Val string @@ -40,7 +40,7 @@ type ( } ) -// Key used for Get/SetReqInfo +// Key used for Get/SetReqInfo. type contextKeyType string const ctxRequestInfo = contextKeyType("NeoFS-S3-Gate") @@ -54,7 +54,7 @@ var ( var ( // RFC7239 defines a new "Forwarded: " header designed to replace the // existing use of X-Forwarded-* headers. - // e.g. Forwarded: for=192.0.2.60;proto=https;by=203.0.113.43 + // e.g. Forwarded: for=192.0.2.60;proto=https;by=203.0.113.43. forwarded = http.CanonicalHeaderKey("Forwarded") // Allows for a sub-match of the first value after 'for=' to the next // comma, semi-colon or space. The match is case-insensitive. @@ -125,7 +125,7 @@ func prepareContext(w http.ResponseWriter, r *http.Request) context.Context { })) } -// NewReqInfo : +// NewReqInfo returns new ReqInfo based on parameters. func NewReqInfo(w http.ResponseWriter, r *http.Request, req ObjectRequest) *ReqInfo { return &ReqInfo{ API: req.Method, @@ -138,7 +138,7 @@ func NewReqInfo(w http.ResponseWriter, r *http.Request, req ObjectRequest) *ReqI } } -// AppendTags - appends key/val to ReqInfo.tags +// AppendTags - appends key/val to ReqInfo.tags. func (r *ReqInfo) AppendTags(key string, val string) *ReqInfo { if r == nil { return nil @@ -149,7 +149,7 @@ func (r *ReqInfo) AppendTags(key string, val string) *ReqInfo { return r } -// SetTags - sets key/val to ReqInfo.tags +// SetTags - sets key/val to ReqInfo.tags. func (r *ReqInfo) SetTags(key string, val string) *ReqInfo { if r == nil { return nil @@ -172,7 +172,7 @@ func (r *ReqInfo) SetTags(key string, val string) *ReqInfo { return r } -// GetTags - returns the user defined tags +// GetTags - returns the user defined tags. func (r *ReqInfo) GetTags() []KeyVal { if r == nil { return nil diff --git a/api/response.go b/api/response.go index 6640d4cb..872eeac1 100644 --- a/api/response.go +++ b/api/response.go @@ -14,7 +14,7 @@ import ( ) type ( - // ErrorResponse - error response format + // ErrorResponse - error response format. ErrorResponse struct { XMLName xml.Name `xml:"Error" json:"-"` Code string @@ -32,11 +32,11 @@ type ( // Captures the server string returned in response header. Server string `xml:"-" json:"-"` - // Underlying HTTP status code for the returned error + // Underlying HTTP status code for the returned error. StatusCode int `xml:"-" json:"-"` } - // APIError structure + // APIError structure. Error struct { Code string Description string @@ -117,7 +117,7 @@ var s3ErrorResponseMap = map[string]string{ // Add new API errors here. } -// WriteErrorResponse writes error headers +// WriteErrorResponse writes error headers. func WriteErrorResponse(ctx context.Context, w http.ResponseWriter, err error, reqURL *url.URL) { code := http.StatusBadRequest @@ -141,7 +141,7 @@ func WriteErrorResponse(ctx context.Context, w http.ResponseWriter, err error, r WriteResponse(w, code, encodedErrorResponse, MimeXML) } -// If none of the http routes match respond with appropriate errors +// If none of the http routes match respond with appropriate errors. func errorResponseHandler(w http.ResponseWriter, r *http.Request) { desc := fmt.Sprintf("Unknown API request at %s", r.URL.Path) WriteErrorResponse(r.Context(), w, Error{ @@ -151,7 +151,7 @@ func errorResponseHandler(w http.ResponseWriter, r *http.Request) { }, r.URL) } -// Write http common headers +// Write http common headers. func setCommonHeaders(w http.ResponseWriter) { w.Header().Set(hdrServerInfo, "NeoFS-S3-Gate/"+misc.Version) w.Header().Set(hdrAcceptRanges, "bytes") diff --git a/cmd/gate/app-settings.go b/cmd/gate/app-settings.go index 6662fb86..5c9b705e 100644 --- a/cmd/gate/app-settings.go +++ b/cmd/gate/app-settings.go @@ -34,8 +34,8 @@ const ( defaultMaxClientsDeadline = time.Second * 30 ) -const ( // settings - // Logger: +const ( // Settings. + // Logger. cfgLoggerLevel = "logger.level" cfgLoggerFormat = "logger.format" cfgLoggerTraceLevel = "logger.trace_level" @@ -44,47 +44,47 @@ const ( // settings cfgLoggerSamplingInitial = "logger.sampling.initial" cfgLoggerSamplingThereafter = "logger.sampling.thereafter" - // KeepAlive + // KeepAlive. cfgKeepaliveTime = "keepalive.time" cfgKeepaliveTimeout = "keepalive.timeout" cfgKeepalivePermitWithoutStream = "keepalive.permit_without_stream" - // Keys + // Keys. cfgNeoFSPrivateKey = "neofs-key" cfgGateAuthPrivateKey = "auth-key" - // HTTPS/TLS + // HTTPS/TLS. cfgTLSKeyFile = "tls.key_file" cfgTLSCertFile = "tls.cert_file" - // Timeouts + // Timeouts. cfgConnectionTTL = "con_ttl" cfgConnectTimeout = "connect_timeout" cfgRequestTimeout = "request_timeout" cfgRebalanceTimer = "rebalance_timer" - // MaxClients + // MaxClients. cfgMaxClientsCount = "max_clients_count" cfgMaxClientsDeadline = "max_clients_deadline" - // gRPC + // gRPC. cfgGRPCVerbose = "verbose" - // Metrics / Profiler / Web + // Metrics / Profiler / Web. cfgEnableMetrics = "metrics" cfgEnableProfiler = "pprof" cfgListenAddress = "listen_address" cfgListenDomains = "listen_domains" - // Peers + // Peers. cfgPeers = "peers" - // Application + // Application. cfgApplicationName = "app.name" cfgApplicationVersion = "app.version" cfgApplicationBuildTime = "app.build_time" - // command line args + // Command line args. cmdHelp = "help" cmdVersion = "version" )