*: fix all godot errors

This commit is contained in:
Roman Khimov 2021-05-13 22:25:32 +03:00
parent a0ecb8ff52
commit 70a70bfa2c
9 changed files with 56 additions and 56 deletions

View file

@ -118,7 +118,7 @@ const (
ErrInvalidTagDirective ErrInvalidTagDirective
// Add new error codes here. // Add new error codes here.
// SSE-S3 related API errors // SSE-S3 related API errors.
ErrInvalidEncryptionMethod ErrInvalidEncryptionMethod
// Server-Side-Encryption (with Customer provided key) related API errors. // Server-Side-Encryption (with Customer provided key) related API errors.
@ -157,8 +157,8 @@ const (
// Add new extended error codes here. // Add new extended error codes here.
// MinIO extended errors. // MinIO extended errors.
// ErrReadQuorum // ErrReadQuorum
// ErrWriteQuorum // ErrWriteQuorum
ErrParentIsObject ErrParentIsObject
ErrStorageFull ErrStorageFull
ErrRequestBodyParse ErrRequestBodyParse
@ -170,7 +170,7 @@ const (
ErrOperationTimedOut ErrOperationTimedOut
ErrOperationMaxedOut ErrOperationMaxedOut
ErrInvalidRequest ErrInvalidRequest
// MinIO storage class error codes // MinIO storage class error codes.
ErrInvalidStorageClass ErrInvalidStorageClass
ErrBackendDown ErrBackendDown
// Add new extended error codes here. // Add new extended error codes here.
@ -192,7 +192,7 @@ const (
ErrAdminCredentialsMismatch ErrAdminCredentialsMismatch
ErrInsecureClientRequest ErrInsecureClientRequest
ErrObjectTampered ErrObjectTampered
// Bucket Quota error codes // Bucket Quota error codes.
ErrAdminBucketQuotaExceeded ErrAdminBucketQuotaExceeded
ErrAdminNoSuchQuotaConfiguration ErrAdminNoSuchQuotaConfiguration
ErrAdminBucketQuotaDisabled ErrAdminBucketQuotaDisabled
@ -205,7 +205,7 @@ const (
ErrHealOverlappingPaths ErrHealOverlappingPaths
ErrIncorrectContinuationToken ErrIncorrectContinuationToken
// S3 Select Errors // S3 Select Errors.
ErrEmptyRequestBody ErrEmptyRequestBody
ErrUnsupportedFunction ErrUnsupportedFunction
ErrInvalidExpressionType ErrInvalidExpressionType
@ -1625,7 +1625,7 @@ func GetAPIError(code ErrorCode) Error {
} }
// getErrorResponse gets in standard error and resource value and // 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 { func getAPIErrorResponse(ctx context.Context, err error, resource, requestID, hostID string) ErrorResponse {
code := "BadRequest" code := "BadRequest"
desc := err.Error() desc := err.Error()
@ -1803,21 +1803,21 @@ func (e BucketLifecycleNotFound) Error() string {
return "No bucket lifecycle configuration found for bucket : " + e.Bucket return "No bucket lifecycle configuration found for bucket : " + e.Bucket
} }
// BucketSSEConfigNotFound - no bucket encryption found // BucketSSEConfigNotFound - no bucket encryption found.
type BucketSSEConfigNotFound GenericError type BucketSSEConfigNotFound GenericError
func (e BucketSSEConfigNotFound) Error() string { func (e BucketSSEConfigNotFound) Error() string {
return "No bucket encryption configuration found for bucket: " + e.Bucket return "No bucket encryption configuration found for bucket: " + e.Bucket
} }
// BucketTaggingNotFound - no bucket tags found // BucketTaggingNotFound - no bucket tags found.
type BucketTaggingNotFound GenericError type BucketTaggingNotFound GenericError
func (e BucketTaggingNotFound) Error() string { func (e BucketTaggingNotFound) Error() string {
return "No bucket tags found for bucket: " + e.Bucket 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 type BucketObjectLockConfigNotFound GenericError
func (e BucketObjectLockConfigNotFound) Error() string { 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 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 type AllAccessDisabled GenericError
// Error returns string an error formatted as the given text. // 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 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 { type InvalidPart struct {
PartNumber int PartNumber int
ExpETag string ExpETag string
@ -1975,21 +1975,21 @@ func (e PartTooBig) Error() string {
return "Part size bigger than the allowed limit" 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{} type InvalidETag struct{}
func (e InvalidETag) Error() string { func (e InvalidETag) Error() string {
return "etag of the object has changed" return "etag of the object has changed"
} }
// NotImplemented If a feature is not implemented // NotImplemented If a feature is not implemented.
type NotImplemented struct{} type NotImplemented struct{}
func (e NotImplemented) Error() string { func (e NotImplemented) Error() string {
return "Not Implemented" return "Not Implemented"
} }
// UnsupportedMetadata - unsupported metadata // UnsupportedMetadata - unsupported metadata.
type UnsupportedMetadata struct{} type UnsupportedMetadata struct{}
func (e UnsupportedMetadata) Error() string { func (e UnsupportedMetadata) Error() string {
@ -2003,14 +2003,14 @@ func (e BackendDown) Error() string {
return "Backend down" return "Backend down"
} }
// PreConditionFailed - Check if copy precondition failed // PreConditionFailed - Check if copy precondition failed.
type PreConditionFailed struct{} type PreConditionFailed struct{}
func (e PreConditionFailed) Error() string { func (e PreConditionFailed) Error() string {
return "At least one of the pre-conditions you specified did not hold" 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 { type DeleteError struct {
Err error Err error
Object string Object string

View file

@ -68,7 +68,7 @@ func (h *handler) DeleteObjectHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNoContent) w.WriteHeader(http.StatusNoContent)
} }
// DeleteMultipleObjectsHandler : // DeleteMultipleObjectsHandler handles multiple delete requests.
func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Request) { func (h *handler) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *http.Request) {
var ( var (
req = mux.Vars(r) req = mux.Vars(r)

View file

@ -2,7 +2,7 @@ package handler
import "encoding/xml" import "encoding/xml"
// ListBucketsResponse - format for list buckets response // ListBucketsResponse - format for list buckets response.
type ListBucketsResponse struct { type ListBucketsResponse struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ ListAllMyBucketsResult" json:"-"` 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"` EncodingType string `xml:"EncodingType,omitempty"`
} }
// Bucket container for bucket metadata // Bucket container for bucket metadata.
type Bucket struct { type Bucket struct {
Name string Name string
CreationDate string // time string of format "2006-01-02T15:04:05.000Z" CreationDate string // time string of format "2006-01-02T15:04:05.000Z"
} }
// Owner - bucket owner/principal // Owner - bucket owner/principal.
type Owner struct { type Owner struct {
ID string ID string
DisplayName string DisplayName string
@ -87,12 +87,12 @@ type ListObjectsResponse struct {
EncodingType string `xml:"EncodingType,omitempty"` EncodingType string `xml:"EncodingType,omitempty"`
} }
// CommonPrefix container for prefix response in ListObjectsResponse // CommonPrefix container for prefix response in ListObjectsResponse.
type CommonPrefix struct { type CommonPrefix struct {
Prefix string Prefix string
} }
// Object container for object metadata // Object container for object metadata.
type Object struct { type Object struct {
Key string Key string
LastModified string // time string of format "2006-01-02T15:04:05.000Z" LastModified string // time string of format "2006-01-02T15:04:05.000Z"
@ -118,7 +118,7 @@ type LocationResponse struct {
Location string `xml:",chardata"` 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 { type CopyObjectResponse struct {
XMLName xml.Name `xml:"http://s3.amazonaws.com/doc/2006-03-01/ CopyObjectResult" json:"-"` 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" LastModified string // time string of format "2006-01-02T15:04:05.000Z"

View file

@ -1,6 +1,6 @@
package api package api
// Standard S3 HTTP response constants // Standard S3 HTTP response constants.
const ( const (
LastModified = "Last-Modified" LastModified = "Last-Modified"
Date = "Date" Date = "Date"

View file

@ -103,7 +103,7 @@ func (n *layer) Owner(ctx context.Context) *owner.ID {
return n.cli.Owner() 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) { func (n *layer) Get(ctx context.Context, address *object.Address) (*object.Object, error) {
return n.cli.Object().Get(ctx, address) return n.cli.Object().Get(ctx, address)
} }

View file

@ -20,7 +20,7 @@ type (
} }
// HTTPStats holds statistics information about // HTTPStats holds statistics information about
// HTTP requests made by all clients // HTTP requests made by all clients.
HTTPStats struct { HTTPStats struct {
currentS3Requests HTTPAPIStats currentS3Requests HTTPAPIStats
totalS3Requests HTTPAPIStats totalS3Requests HTTPAPIStats
@ -63,8 +63,8 @@ var (
) )
) )
// collects http metrics for NeoFS S3 Gate in Prometheus specific format // Collects HTTP metrics for NeoFS S3 Gate in Prometheus specific format
// and sends to given channel // and sends to given channel.
func collectHTTPMetrics(ch chan<- prometheus.Metric) { func collectHTTPMetrics(ch chan<- prometheus.Metric) {
for api, value := range httpStatsMetric.currentS3Requests.Load() { for api, value := range httpStatsMetric.currentS3Requests.Load() {
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
@ -176,7 +176,7 @@ func (st *HTTPStats) getOutputBytes() uint64 {
return atomic.LoadUint64(&st.totalOutputBytes) 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) { func (st *HTTPStats) updateStats(api string, w http.ResponseWriter, r *http.Request, durationSecs float64) {
var code int 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) { func (w *responseWrapper) WriteHeader(code int) {
w.Do(func() { w.Do(func() {
w.statusCode = code w.statusCode = code

View file

@ -13,7 +13,7 @@ import (
) )
type ( type (
// KeyVal - appended to ReqInfo.Tags // KeyVal - appended to ReqInfo.Tags.
KeyVal struct { KeyVal struct {
Key string Key string
Val string Val string
@ -40,7 +40,7 @@ type (
} }
) )
// Key used for Get/SetReqInfo // Key used for Get/SetReqInfo.
type contextKeyType string type contextKeyType string
const ctxRequestInfo = contextKeyType("NeoFS-S3-Gate") const ctxRequestInfo = contextKeyType("NeoFS-S3-Gate")
@ -54,7 +54,7 @@ var (
var ( var (
// RFC7239 defines a new "Forwarded: " header designed to replace the // RFC7239 defines a new "Forwarded: " header designed to replace the
// existing use of X-Forwarded-* headers. // 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") forwarded = http.CanonicalHeaderKey("Forwarded")
// Allows for a sub-match of the first value after 'for=' to the next // Allows for a sub-match of the first value after 'for=' to the next
// comma, semi-colon or space. The match is case-insensitive. // 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 { func NewReqInfo(w http.ResponseWriter, r *http.Request, req ObjectRequest) *ReqInfo {
return &ReqInfo{ return &ReqInfo{
API: req.Method, 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 { func (r *ReqInfo) AppendTags(key string, val string) *ReqInfo {
if r == nil { if r == nil {
return nil return nil
@ -149,7 +149,7 @@ func (r *ReqInfo) AppendTags(key string, val string) *ReqInfo {
return r 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 { func (r *ReqInfo) SetTags(key string, val string) *ReqInfo {
if r == nil { if r == nil {
return nil return nil
@ -172,7 +172,7 @@ func (r *ReqInfo) SetTags(key string, val string) *ReqInfo {
return r return r
} }
// GetTags - returns the user defined tags // GetTags - returns the user defined tags.
func (r *ReqInfo) GetTags() []KeyVal { func (r *ReqInfo) GetTags() []KeyVal {
if r == nil { if r == nil {
return nil return nil

View file

@ -14,7 +14,7 @@ import (
) )
type ( type (
// ErrorResponse - error response format // ErrorResponse - error response format.
ErrorResponse struct { ErrorResponse struct {
XMLName xml.Name `xml:"Error" json:"-"` XMLName xml.Name `xml:"Error" json:"-"`
Code string Code string
@ -32,11 +32,11 @@ type (
// Captures the server string returned in response header. // Captures the server string returned in response header.
Server string `xml:"-" json:"-"` Server string `xml:"-" json:"-"`
// Underlying HTTP status code for the returned error // Underlying HTTP status code for the returned error.
StatusCode int `xml:"-" json:"-"` StatusCode int `xml:"-" json:"-"`
} }
// APIError structure // APIError structure.
Error struct { Error struct {
Code string Code string
Description string Description string
@ -117,7 +117,7 @@ var s3ErrorResponseMap = map[string]string{
// Add new API errors here. // 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) { func WriteErrorResponse(ctx context.Context, w http.ResponseWriter, err error, reqURL *url.URL) {
code := http.StatusBadRequest code := http.StatusBadRequest
@ -141,7 +141,7 @@ func WriteErrorResponse(ctx context.Context, w http.ResponseWriter, err error, r
WriteResponse(w, code, encodedErrorResponse, MimeXML) 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) { func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
desc := fmt.Sprintf("Unknown API request at %s", r.URL.Path) desc := fmt.Sprintf("Unknown API request at %s", r.URL.Path)
WriteErrorResponse(r.Context(), w, Error{ WriteErrorResponse(r.Context(), w, Error{
@ -151,7 +151,7 @@ func errorResponseHandler(w http.ResponseWriter, r *http.Request) {
}, r.URL) }, r.URL)
} }
// Write http common headers // Write http common headers.
func setCommonHeaders(w http.ResponseWriter) { func setCommonHeaders(w http.ResponseWriter) {
w.Header().Set(hdrServerInfo, "NeoFS-S3-Gate/"+misc.Version) w.Header().Set(hdrServerInfo, "NeoFS-S3-Gate/"+misc.Version)
w.Header().Set(hdrAcceptRanges, "bytes") w.Header().Set(hdrAcceptRanges, "bytes")

View file

@ -34,8 +34,8 @@ const (
defaultMaxClientsDeadline = time.Second * 30 defaultMaxClientsDeadline = time.Second * 30
) )
const ( // settings const ( // Settings.
// Logger: // Logger.
cfgLoggerLevel = "logger.level" cfgLoggerLevel = "logger.level"
cfgLoggerFormat = "logger.format" cfgLoggerFormat = "logger.format"
cfgLoggerTraceLevel = "logger.trace_level" cfgLoggerTraceLevel = "logger.trace_level"
@ -44,47 +44,47 @@ const ( // settings
cfgLoggerSamplingInitial = "logger.sampling.initial" cfgLoggerSamplingInitial = "logger.sampling.initial"
cfgLoggerSamplingThereafter = "logger.sampling.thereafter" cfgLoggerSamplingThereafter = "logger.sampling.thereafter"
// KeepAlive // KeepAlive.
cfgKeepaliveTime = "keepalive.time" cfgKeepaliveTime = "keepalive.time"
cfgKeepaliveTimeout = "keepalive.timeout" cfgKeepaliveTimeout = "keepalive.timeout"
cfgKeepalivePermitWithoutStream = "keepalive.permit_without_stream" cfgKeepalivePermitWithoutStream = "keepalive.permit_without_stream"
// Keys // Keys.
cfgNeoFSPrivateKey = "neofs-key" cfgNeoFSPrivateKey = "neofs-key"
cfgGateAuthPrivateKey = "auth-key" cfgGateAuthPrivateKey = "auth-key"
// HTTPS/TLS // HTTPS/TLS.
cfgTLSKeyFile = "tls.key_file" cfgTLSKeyFile = "tls.key_file"
cfgTLSCertFile = "tls.cert_file" cfgTLSCertFile = "tls.cert_file"
// Timeouts // Timeouts.
cfgConnectionTTL = "con_ttl" cfgConnectionTTL = "con_ttl"
cfgConnectTimeout = "connect_timeout" cfgConnectTimeout = "connect_timeout"
cfgRequestTimeout = "request_timeout" cfgRequestTimeout = "request_timeout"
cfgRebalanceTimer = "rebalance_timer" cfgRebalanceTimer = "rebalance_timer"
// MaxClients // MaxClients.
cfgMaxClientsCount = "max_clients_count" cfgMaxClientsCount = "max_clients_count"
cfgMaxClientsDeadline = "max_clients_deadline" cfgMaxClientsDeadline = "max_clients_deadline"
// gRPC // gRPC.
cfgGRPCVerbose = "verbose" cfgGRPCVerbose = "verbose"
// Metrics / Profiler / Web // Metrics / Profiler / Web.
cfgEnableMetrics = "metrics" cfgEnableMetrics = "metrics"
cfgEnableProfiler = "pprof" cfgEnableProfiler = "pprof"
cfgListenAddress = "listen_address" cfgListenAddress = "listen_address"
cfgListenDomains = "listen_domains" cfgListenDomains = "listen_domains"
// Peers // Peers.
cfgPeers = "peers" cfgPeers = "peers"
// Application // Application.
cfgApplicationName = "app.name" cfgApplicationName = "app.name"
cfgApplicationVersion = "app.version" cfgApplicationVersion = "app.version"
cfgApplicationBuildTime = "app.build_time" cfgApplicationBuildTime = "app.build_time"
// command line args // Command line args.
cmdHelp = "help" cmdHelp = "help"
cmdVersion = "version" cmdVersion = "version"
) )