1
0
Fork 0

Update linter

This commit is contained in:
Ludovic Fernandez 2020-05-11 12:06:07 +02:00 committed by GitHub
parent f12c27aa7c
commit 328611c619
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
157 changed files with 489 additions and 508 deletions

View file

@ -5,12 +5,12 @@ import (
"strings"
)
// HTTPCodeRanges holds HTTP code ranges
// HTTPCodeRanges holds HTTP code ranges.
type HTTPCodeRanges [][2]int
// NewHTTPCodeRanges creates HTTPCodeRanges from a given []string.
// Break out the http status code ranges into a low int and high int
// for ease of use at runtime
// for ease of use at runtime.
func NewHTTPCodeRanges(strBlocks []string) (HTTPCodeRanges, error) {
var blocks HTTPCodeRanges
for _, block := range strBlocks {
@ -32,8 +32,7 @@ func NewHTTPCodeRanges(strBlocks []string) (HTTPCodeRanges, error) {
return blocks, nil
}
// Contains tests whether the passed status code is within
// one of its HTTP code ranges.
// Contains tests whether the passed status code is within one of its HTTP code ranges.
func (h HTTPCodeRanges) Contains(statusCode int) bool {
for _, block := range h {
if statusCode >= block[0] && statusCode <= block[1] {

View file

@ -1,11 +1,11 @@
package types
const (
// AccessLogKeep is the keep string value
// AccessLogKeep is the keep string value.
AccessLogKeep = "keep"
// AccessLogDrop is the drop string value
// AccessLogDrop is the drop string value.
AccessLogDrop = "drop"
// AccessLogRedact is the redact string value
// AccessLogRedact is the redact string value.
AccessLogRedact = "redact"
)
@ -48,20 +48,20 @@ func (l *AccessLog) SetDefaults() {
l.Fields.SetDefaults()
}
// AccessLogFilters holds filters configuration
// AccessLogFilters holds filters configuration.
type AccessLogFilters struct {
StatusCodes []string `description:"Keep access logs with status codes in the specified range." json:"statusCodes,omitempty" toml:"statusCodes,omitempty" yaml:"statusCodes,omitempty" export:"true"`
RetryAttempts bool `description:"Keep access logs when at least one retry happened." json:"retryAttempts,omitempty" toml:"retryAttempts,omitempty" yaml:"retryAttempts,omitempty" export:"true"`
MinDuration Duration `description:"Keep access logs when request took longer than the specified duration." json:"minDuration,omitempty" toml:"minDuration,omitempty" yaml:"minDuration,omitempty" export:"true"`
}
// FieldHeaders holds configuration for access log headers
// FieldHeaders holds configuration for access log headers.
type FieldHeaders struct {
DefaultMode string `description:"Default mode for fields: keep | drop | redact" json:"defaultMode,omitempty" toml:"defaultMode,omitempty" yaml:"defaultMode,omitempty" export:"true"`
Names map[string]string `description:"Override mode for headers" json:"names,omitempty" toml:"names,omitempty" yaml:"names,omitempty" export:"true"`
}
// AccessLogFields holds configuration for access log fields
// AccessLogFields holds configuration for access log fields.
type AccessLogFields struct {
DefaultMode string `description:"Default mode for fields: keep | drop" json:"defaultMode,omitempty" toml:"defaultMode,omitempty" yaml:"defaultMode,omitempty" export:"true"`
Names map[string]string `description:"Override mode for fields" json:"names,omitempty" toml:"names,omitempty" yaml:"names,omitempty" export:"true"`
@ -76,7 +76,7 @@ func (f *AccessLogFields) SetDefaults() {
}
}
// Keep check if the field need to be kept or dropped
// Keep check if the field need to be kept or dropped.
func (f *AccessLogFields) Keep(field string) bool {
defaultKeep := true
if f != nil {
@ -89,7 +89,7 @@ func (f *AccessLogFields) Keep(field string) bool {
return defaultKeep
}
// KeepHeader checks if the headers need to be kept, dropped or redacted and returns the status
// KeepHeader checks if the headers need to be kept, dropped or redacted and returns the status.
func (f *AccessLogFields) KeepHeader(header string) string {
defaultValue := AccessLogKeep
if f != nil && f.Headers != nil {

View file

@ -4,7 +4,7 @@ import (
"github.com/gorilla/mux"
)
// RouteAppender appends routes on a router (/api, /ping ...)
// RouteAppender appends routes on a router (/api, /ping ...).
type RouteAppender interface {
Append(systemRouter *mux.Router)
}

View file

@ -12,7 +12,7 @@ import (
)
// ClientTLS holds TLS specific configurations as client
// CA, Cert and Key can be either path or file contents
// CA, Cert and Key can be either path or file contents.
type ClientTLS struct {
CA string `description:"TLS CA" json:"ca,omitempty" toml:"ca,omitempty" yaml:"ca,omitempty"`
CAOptional bool `description:"TLS CA.Optional" json:"caOptional,omitempty" toml:"caOptional,omitempty" yaml:"caOptional,omitempty"`
@ -21,7 +21,7 @@ type ClientTLS struct {
InsecureSkipVerify bool `description:"TLS insecure skip verify" json:"insecureSkipVerify,omitempty" toml:"insecureSkipVerify,omitempty" yaml:"insecureSkipVerify,omitempty"`
}
// CreateTLSConfig creates a TLS config from ClientTLS structures
// CreateTLSConfig creates a TLS config from ClientTLS structures.
func (clientTLS *ClientTLS) CreateTLSConfig(ctx context.Context) (*tls.Config, error) {
if clientTLS == nil {
log.FromContext(ctx).Warnf("clientTLS is nil")
@ -36,7 +36,7 @@ func (clientTLS *ClientTLS) CreateTLSConfig(ctx context.Context) (*tls.Config, e
var err error
ca, err = ioutil.ReadFile(clientTLS.CA)
if err != nil {
return nil, fmt.Errorf("failed to read CA. %s", err)
return nil, fmt.Errorf("failed to read CA. %w", err)
}
} else {
ca = []byte(clientTLS.CA)
@ -66,7 +66,7 @@ func (clientTLS *ClientTLS) CreateTLSConfig(ctx context.Context) (*tls.Config, e
if errKeyIsFile == nil {
cert, err = tls.LoadX509KeyPair(clientTLS.Cert, clientTLS.Key)
if err != nil {
return nil, fmt.Errorf("failed to load TLS keypair: %v", err)
return nil, fmt.Errorf("failed to load TLS keypair: %w", err)
}
} else {
return nil, fmt.Errorf("TLS cert is a file, but tls key is not")
@ -75,7 +75,7 @@ func (clientTLS *ClientTLS) CreateTLSConfig(ctx context.Context) (*tls.Config, e
if errKeyIsFile != nil {
cert, err = tls.X509KeyPair([]byte(clientTLS.Cert), []byte(clientTLS.Key))
if err != nil {
return nil, fmt.Errorf("failed to load TLS keypair: %v", err)
return nil, fmt.Errorf("failed to load TLS keypair: %w", err)
}
} else {
return nil, fmt.Errorf("TLS key is a file, but tls cert is not")