Skip to content
Snippets Groups Projects
Commit 0e4adce2 authored by Pawel Rozlach's avatar Pawel Rozlach Committed by Hayley Swimelar
Browse files

ci: revive linter fixes part 1 (of around 11)

parent eb152d03
No related branches found
No related tags found
1 merge request!1927ci: revive linter fixes part 1 (of around 11)
Showing
with 551 additions and 157 deletions
......@@ -66,7 +66,7 @@ commitlint:
codelint:
variables:
GOLANGCI_LINT_VERSION: 'v1.59.1'
GOLANGCI_LINT_VERSION: 'v1.62.0'
TESTIFYLINT_VERSION: 'v1.5.2'
cache: {}
image: golangci/golangci-lint:$GOLANGCI_LINT_VERSION
......
......@@ -45,6 +45,400 @@ linters-settings:
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: false
revive:
# Maximum number of open files at the same time.
# See https://github.com/mgechev/revive#command-line-flags
# Defaults to unlimited.
max-open-files: 2048
# When set to false, ignores files with "GENERATED" header, similar to golint.
# See https://github.com/mgechev/revive#configuration for details.
# Default: false
ignore-generated-header: true
# Sets the default severity.
# See https://github.com/mgechev/revive#configuration
# Default: warning
severity: error
# Enable all available rules.
# Default: false
enable-all-rules: false
# Sets the default failure confidence.
# This means that linting errors with less than 0.8 confidence will be ignored.
# Default: 0.8
confidence: 0.8
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic
- name: atomic
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters
- name: banned-characters
severity: warning
disabled: false
exclude: [""]
arguments: ["Ω", "Σ", "σ", "7"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return
- name: bare-return
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports
- name: blank-imports
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
- name: bool-literal-in-expr
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#call-to-gc
- name: call-to-gc
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#comment-spacings
- name: comment-spacings
severity: warning
disabled: false
exclude: [""]
arguments:
- mypragma
- otherpragma
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-naming
- name: confusing-naming
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-results
- name: confusing-results
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr
- name: constant-logical-expr
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument
- name: context-as-argument
severity: warning
disabled: false
exclude: [""]
arguments:
- allowTypesBefore: "*testing.T,*github.com/user/repo/testing.Harness"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type
- name: context-keys-type
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#datarace
- name: datarace
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit
- name: deep-exit
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer
- name: defer
severity: warning
disabled: false
exclude: [""]
arguments:
- ["call-chain", "loop"]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports
- name: dot-imports
severity: warning
disabled: false
exclude: [""]
arguments: []
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports
- name: duplicated-imports
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
- name: early-return
severity: warning
disabled: false
exclude: [""]
arguments:
- "preserveScope"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block
- name: empty-block
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
- name: empty-lines
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#enforce-map-style
- name: enforce-map-style
severity: warning
disabled: false
exclude: [""]
arguments:
- "make"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#enforce-repeated-arg-type-style
- name: enforce-repeated-arg-type-style
severity: warning
disabled: false
exclude: [""]
arguments:
- "short"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#enforce-slice-style
- name: enforce-slice-style
severity: warning
disabled: false
exclude: [""]
arguments:
- "make"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming
- name: error-naming
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return
- name: error-return
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings
- name: error-strings
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf
- name: errorf
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#get-return
- name: get-return
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches
- name: identical-branches
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return
- name: if-return
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-alias-naming
- name: import-alias-naming
severity: warning
disabled: false
exclude: [""]
arguments:
- "^[a-z][a-z0-9]{0,}$"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing
- name: import-shadowing
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blocklist
- name: imports-blocklist
severity: warning
disabled: false
exclude: [""]
arguments:
- "crypto/md5"
- "crypto/sha1"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement
- name: increment-decrement
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow
- name: indent-error-flow
severity: warning
disabled: false
exclude: [""]
arguments:
- "preserveScope"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-control-nesting
- name: max-control-nesting
severity: warning
disabled: false
exclude: [""]
arguments: [3]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-parameter
- name: modifies-parameter
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-value-receiver
- name: modifies-value-receiver
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#optimize-operands-order
- name: optimize-operands-order
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range
- name: range
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address
- name: range-val-address
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure
- name: range-val-in-closure
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id
- name: redefines-builtin-id
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias
- name: redundant-import-alias
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format
- name: string-format
severity: warning
disabled: false
exclude: [""]
arguments:
- - 'core.WriteError[1].Message'
- '/^([^A-Z]|$)/'
- must not start with a capital letter
- - 'fmt.Errorf[0]'
- '/(^|[^\.!?])$/'
- must not end in punctuation
- - panic
- '/^[^\n]*$/'
- must not contain line breaks
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int
- name: string-of-int
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
severity: warning
disabled: false
exclude: [""]
arguments:
- "json,inline"
- "bson,outline,gnu"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else
- name: superfluous-else
severity: warning
disabled: false
exclude: [""]
arguments:
- "preserveScope"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal
- name: time-equal
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-naming
- name: time-naming
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unchecked-type-assertion
- name: unchecked-type-assertion
severity: warning
disabled: false
exclude: [""]
arguments:
- acceptIgnoredAssertionResult: true
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion
- name: unconditional-recursion
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
- name: unexported-naming
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
- name: unexported-return
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
- name: unhandled-error
severity: warning
disabled: false
exclude: [""]
arguments:
- "fmt.Printf"
- "myFunction"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt
- name: unnecessary-stmt
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unreachable-code
- name: unreachable-code
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
severity: warning
disabled: false
exclude: [""]
arguments:
- allowRegex: "^_"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
- name: unused-receiver
severity: warning
disabled: false
exclude: [""]
arguments:
- allowRegex: "^_"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#use-any
- name: use-any
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
- name: useless-break
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration
- name: var-declaration
severity: warning
disabled: false
exclude: [""]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming
- name: var-naming
severity: warning
disabled: false
exclude: [""]
arguments:
- ["ID"] # AllowList
- ["VM"] # DenyList
- - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks)
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value
- name: waitgroup-by-value
severity: warning
disabled: false
exclude: [""]
govet:
# settings per analyzer
settings:
......
# Root directory of the project (absolute path).
ROOTDIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
GOLANGCI_VERSION ?= v1.59.1
GOLANGCI_VERSION ?= v1.62.0
DOCSLINT_VERSION ?= registry.gitlab.com/gitlab-org/gitlab-docs/lint-markdown:alpine-3.20-vale-3.6.1-markdownlint2-0.13.0-lychee-0.15.1
# Used to populate version variable in main package.
......
......@@ -198,7 +198,7 @@ type BlobIngester interface {
// BlobIngester receiving them.
// TODO (brianbland): unify this with ManifestServiceOption in the future
type BlobCreateOption interface {
Apply(interface{}) error
Apply(any) error
}
// CreateOptions is a collection of blob creation modifiers relevant to general
......
......@@ -48,7 +48,7 @@ type Configuration struct {
// Fields allows users to specify static string fields to include in
// the logger context.
Fields map[string]interface{} `yaml:"fields,omitempty"`
Fields map[string]any `yaml:"fields,omitempty"`
}
// Loglevel is the level at which registry operations are logged.
......@@ -613,7 +613,7 @@ type v0_1Configuration Configuration
// UnmarshalYAML implements the yaml.Unmarshaler interface
// Unmarshals a string of the form X.Y into a Version, validating that X and Y can represent unsigned integers
func (version *Version) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (version *Version) UnmarshalYAML(unmarshal func(any) error) error {
var versionString string
err := unmarshal(&versionString)
if err != nil {
......@@ -672,7 +672,7 @@ func (l Loglevel) isValid() bool {
// UnmarshalYAML implements the yaml.Umarshaler interface for Loglevel, parsing it and validating that it represents a
// valid log level.
func (l *Loglevel) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (l *Loglevel) UnmarshalYAML(unmarshal func(any) error) error {
var val string
err := unmarshal(&val)
if err != nil {
......@@ -728,7 +728,7 @@ func (out logOutput) isValid() bool {
// UnmarshalYAML implements the yaml.Umarshaler interface for logOutput, parsing it and validating that it represents a
// valid log output destination.
func (out *logOutput) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (out *logOutput) UnmarshalYAML(unmarshal func(any) error) error {
var val string
if err := unmarshal(&val); err != nil {
return err
......@@ -773,7 +773,7 @@ func (ft logFormat) isValid() bool {
// UnmarshalYAML implements the yaml.Umarshaler interface for logFormat, parsing it and validating that it
// represents a valid application log output format.
func (ft *logFormat) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (ft *logFormat) UnmarshalYAML(unmarshal func(any) error) error {
var val string
if err := unmarshal(&val); err != nil {
return err
......@@ -818,7 +818,7 @@ func (ft accessLogFormat) isValid() bool {
// UnmarshalYAML implements the yaml.Umarshaler interface for accessLogFormat, parsing it and validating that it
// represents a valid access log output format.
func (ft *accessLogFormat) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (ft *accessLogFormat) UnmarshalYAML(unmarshal func(any) error) error {
var val string
if err := unmarshal(&val); err != nil {
return err
......@@ -834,7 +834,7 @@ func (ft *accessLogFormat) UnmarshalYAML(unmarshal func(interface{}) error) erro
}
// Parameters defines a key-value parameters mapping
type Parameters map[string]interface{}
type Parameters map[string]any
// Storage defines the configuration for registry object storage
type Storage map[string]Parameters
......@@ -873,13 +873,13 @@ func (storage Storage) Parameters() Parameters {
}
// setParameter changes the parameter at the provided key to the new value
func (storage Storage) setParameter(key string, value interface{}) {
func (storage Storage) setParameter(key string, value any) {
storage[storage.Type()][key] = value
}
// UnmarshalYAML implements the yaml.Unmarshaler interface
// Unmarshals a single item map into a Storage or a string into a Storage type with no parameters
func (storage *Storage) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (storage *Storage) UnmarshalYAML(unmarshal func(any) error) error {
var storageMap map[string]Parameters
err := unmarshal(&storageMap)
if err == nil {
......@@ -919,7 +919,7 @@ func (storage *Storage) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
// MarshalYAML implements the yaml.Marshaler interface
func (storage Storage) MarshalYAML() (interface{}, error) {
func (storage Storage) MarshalYAML() (any, error) {
if storage.Parameters() == nil {
return storage.Type(), nil
}
......@@ -944,13 +944,13 @@ func (auth Auth) Parameters() Parameters {
}
// setParameter changes the parameter at the provided key to the new value
func (auth Auth) setParameter(key string, value interface{}) {
func (auth Auth) setParameter(key string, value any) {
auth[auth.Type()][key] = value
}
// UnmarshalYAML implements the yaml.Unmarshaler interface
// Unmarshals a single item map into a Storage or a string into a Storage type with no parameters
func (auth *Auth) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (auth *Auth) UnmarshalYAML(unmarshal func(any) error) error {
var m map[string]Parameters
err := unmarshal(&m)
if err == nil {
......@@ -977,7 +977,7 @@ func (auth *Auth) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
// MarshalYAML implements the yaml.Marshaler interface
func (auth Auth) MarshalYAML() (interface{}, error) {
func (auth Auth) MarshalYAML() (any, error) {
if auth.Parameters() == nil {
return auth.Type(), nil
}
......@@ -1086,7 +1086,7 @@ func Parse(rd io.Reader, opts ...ParseOption) (*Configuration, error) {
{
Version: MajorMinorVersion(0, 1),
ParseAs: reflect.TypeOf(v0_1Configuration{}),
ConversionFunc: func(c interface{}) (interface{}, error) {
ConversionFunc: func(c any) (any, error) {
if v0_1, ok := c.(*v0_1Configuration); ok {
if v0_1.Log.Level == Loglevel("") {
if v0_1.Loglevel != Loglevel("") {
......
......@@ -25,10 +25,10 @@ var configStruct = Configuration{
Disabled bool `yaml:"disabled,omitempty"`
Formatter accessLogFormat `yaml:"formatter,omitempty"`
} `yaml:"accesslog,omitempty"`
Level Loglevel `yaml:"level,omitempty"`
Formatter logFormat `yaml:"formatter,omitempty"`
Output logOutput `yaml:"output,omitempty"`
Fields map[string]interface{} `yaml:"fields,omitempty"`
Level Loglevel `yaml:"level,omitempty"`
Formatter logFormat `yaml:"formatter,omitempty"`
Output logOutput `yaml:"output,omitempty"`
Fields map[string]any `yaml:"fields,omitempty"`
}{
AccessLog: struct {
Disabled bool `yaml:"disabled,omitempty"`
......@@ -39,7 +39,7 @@ var configStruct = Configuration{
Level: "info",
Formatter: "json",
Output: "stdout",
Fields: map[string]interface{}{"environment": "test"},
Fields: map[string]any{"environment": "test"},
},
Storage: Storage{
"s3": Parameters{
......@@ -446,12 +446,12 @@ func (suite *ConfigSuite) TestParseWithoutStorageValidation() {
type parameterTest struct {
name string
value string
want interface{}
want any
wantErr bool
err string
}
type parameterValidator func(t *testing.T, want interface{}, got *Configuration)
type parameterValidator func(t *testing.T, want any, got *Configuration)
func testParameter(t *testing.T, yml, envVar string, tests []parameterTest, fn parameterValidator) {
t.Helper()
......@@ -537,7 +537,7 @@ storage: inmemory
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Log.Level.String())
}
......@@ -576,7 +576,7 @@ storage: inmemory
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Log.Output.String())
}
......@@ -615,7 +615,7 @@ storage: inmemory
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Log.Formatter.String())
}
......@@ -655,7 +655,7 @@ storage: inmemory
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Log.AccessLog.Formatter.String())
}
......@@ -731,10 +731,10 @@ func (suite *ConfigSuite) TestParseExtraneousVars() {
// TestParseEnvVarImplicitMaps validates that environment variables can set
// values in maps that don't already exist.
func (suite *ConfigSuite) TestParseEnvVarImplicitMaps() {
readonly := make(map[string]interface{})
readonly := make(map[string]any)
readonly["enabled"] = true
maintenance := make(map[string]interface{})
maintenance := make(map[string]any)
maintenance["readonly"] = readonly
suite.expectedConfig.Storage["maintenance"] = maintenance
......@@ -835,7 +835,7 @@ http:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.HTTP.Debug.Pprof.Enabled))
}
......@@ -853,7 +853,7 @@ http:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.HTTP.Debug.TLS.Enabled))
}
......@@ -871,7 +871,7 @@ http:
`
tt := stringParameterTests("")
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.HTTP.Debug.TLS.Certificate)
}
......@@ -889,7 +889,7 @@ http:
`
tt := stringParameterTests("")
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.HTTP.Debug.TLS.Key)
}
......@@ -907,7 +907,7 @@ http:
`
tt := stringParameterTests("")
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.HTTP.Debug.TLS.MinimumTLS)
}
......@@ -940,7 +940,7 @@ http:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.ElementsMatch(t, want, got.HTTP.Debug.TLS.ClientCAs)
}
......@@ -957,7 +957,7 @@ profiling:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Profiling.Stackdriver.Enabled))
}
......@@ -984,7 +984,7 @@ profiling:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Profiling.Stackdriver.Service)
}
......@@ -1011,7 +1011,7 @@ profiling:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Profiling.Stackdriver.ServiceVersion)
}
......@@ -1038,7 +1038,7 @@ profiling:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Profiling.Stackdriver.ProjectID)
}
......@@ -1065,7 +1065,7 @@ profiling:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Profiling.Stackdriver.KeyFile)
}
......@@ -1082,7 +1082,7 @@ redis:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Redis.TLS.Enabled))
}
......@@ -1099,7 +1099,7 @@ redis:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Redis.TLS.Insecure))
}
......@@ -1130,7 +1130,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Addr)
}
......@@ -1156,7 +1156,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.MainName)
}
......@@ -1183,7 +1183,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Pool.Size)
}
......@@ -1210,7 +1210,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Pool.MaxLifetime)
}
......@@ -1237,7 +1237,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Pool.IdleTimeout)
}
......@@ -1263,7 +1263,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.SSLMode)
}
......@@ -1289,7 +1289,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.SSLCert)
}
......@@ -1315,7 +1315,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.SSLKey)
}
......@@ -1341,7 +1341,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.SSLRootCert)
}
......@@ -1357,7 +1357,7 @@ database:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Database.PreparedStatements))
}
......@@ -1383,7 +1383,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.DrainTimeout)
}
......@@ -1410,7 +1410,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.Pool.MaxIdle)
}
......@@ -1437,7 +1437,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.Pool.MaxOpen)
}
......@@ -1464,7 +1464,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.Pool.MaxLifetime)
}
......@@ -1481,7 +1481,7 @@ database:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Database.LoadBalancing.Enabled))
}
......@@ -1514,7 +1514,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.ElementsMatch(t, want, got.Database.LoadBalancing.Hosts)
}
......@@ -1535,7 +1535,7 @@ database:
{name: "custom", value: "nameserver.example.com", want: "nameserver.example.com"},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.LoadBalancing.Nameserver)
}
......@@ -1563,7 +1563,7 @@ database:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.LoadBalancing.Port)
}
......@@ -1584,7 +1584,7 @@ database:
{name: "custom", value: "db-replica-registry.service.consul", want: "db-replica-registry.service.consul"},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.LoadBalancing.Record)
}
......@@ -1605,7 +1605,7 @@ database:
{name: "custom", value: "2m", want: 2 * time.Minute},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Database.LoadBalancing.ReplicaCheckInterval)
}
......@@ -1622,7 +1622,7 @@ reporting:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Reporting.Sentry.Enabled))
}
......@@ -1649,7 +1649,7 @@ reporting:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Reporting.Sentry.DSN)
}
......@@ -1676,7 +1676,7 @@ reporting:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Reporting.Sentry.Environment)
}
......@@ -1726,7 +1726,7 @@ func copyConfig(config Configuration) *Configuration {
configCopy.Version = MajorMinorVersion(config.Version.Major(), config.Version.Minor())
configCopy.Loglevel = config.Loglevel
configCopy.Log = config.Log
configCopy.Log.Fields = make(map[string]interface{}, len(config.Log.Fields))
configCopy.Log.Fields = make(map[string]any, len(config.Log.Fields))
for k, v := range config.Log.Fields {
configCopy.Log.Fields[k] = v
}
......@@ -1779,7 +1779,7 @@ validation:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Validation.Manifests.PayloadSizeLimit)
}
......@@ -1796,7 +1796,7 @@ redis:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Redis.Cache.Enabled))
}
......@@ -1815,7 +1815,7 @@ redis:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Redis.Cache.TLS.Enabled))
}
......@@ -1834,7 +1834,7 @@ redis:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Redis.Cache.TLS.Insecure))
}
......@@ -1867,7 +1867,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Cache.Addr)
}
......@@ -1895,7 +1895,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Cache.MainName)
}
......@@ -1925,7 +1925,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Cache.SentinelUsername)
}
......@@ -1954,7 +1954,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Cache.SentinelPassword)
}
......@@ -1983,7 +1983,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Cache.Pool.Size)
}
......@@ -2012,7 +2012,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Cache.Pool.MaxLifetime)
}
......@@ -2041,7 +2041,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.Cache.Pool.IdleTimeout)
}
......@@ -2058,7 +2058,7 @@ redis:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Redis.RateLimiter.Enabled))
}
......@@ -2077,7 +2077,7 @@ redis:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Redis.RateLimiter.TLS.Enabled))
}
......@@ -2096,7 +2096,7 @@ redis:
`
tt := boolParameterTests()
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, strconv.FormatBool(got.Redis.RateLimiter.TLS.Insecure))
}
......@@ -2129,7 +2129,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.RateLimiter.Addr)
}
......@@ -2157,7 +2157,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.RateLimiter.MainName)
}
......@@ -2186,7 +2186,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.RateLimiter.Pool.Size)
}
......@@ -2215,7 +2215,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.RateLimiter.Pool.MaxLifetime)
}
......@@ -2244,7 +2244,7 @@ redis:
},
}
validator := func(t *testing.T, want interface{}, got *Configuration) {
validator := func(t *testing.T, want any, got *Configuration) {
require.Equal(t, want, got.Redis.RateLimiter.Pool.IdleTimeout)
}
......
......@@ -59,7 +59,7 @@ type VersionedParseInfo struct {
// ConversionFunc defines a method for converting the parsed configuration
// (of type ParseAs) into the current configuration version
// Note: this method signature is very unclear with the absence of generics
ConversionFunc func(interface{}) (interface{}, error)
ConversionFunc func(any) (any, error)
}
type envVar struct {
......@@ -113,7 +113,7 @@ func NewParser(prefix string, parseInfos []VersionedParseInfo) *Parser {
// than version, following the scheme below:
// v.Abc may be replaced by the value of PREFIX_ABC,
// v.Abc.Xyz may be replaced by the value of PREFIX_ABC_XYZ, and so forth
func (p *Parser) Parse(in []byte, v interface{}) error {
func (p *Parser) Parse(in []byte, v any) error {
var versionedStruct struct {
Version Version
}
......@@ -174,7 +174,7 @@ func (p *Parser) overwriteFields(v reflect.Value, fullpath string, path []string
return p.overwriteFields(v.Elem(), fullpath, path, payload)
}
// Interface was empty; create an implicit map
var template map[string]interface{}
var template map[string]any
wrappedV := reflect.MakeMap(reflect.TypeOf(template))
v.Set(wrappedV)
return p.overwriteMap(wrappedV, fullpath, path, payload)
......
......@@ -43,7 +43,7 @@ func (suite *ParserSuite) TestParserOverwriteIninitializedPoiner() {
{
Version: "0.1",
ParseAs: reflect.TypeOf(config),
ConversionFunc: func(c interface{}) (interface{}, error) {
ConversionFunc: func(c any) (any, error) {
return c, nil
},
},
......@@ -64,7 +64,7 @@ func (suite *ParserSuite) TestParseOverwriteUnininitializedPoiner() {
{
Version: "0.1",
ParseAs: reflect.TypeOf(config),
ConversionFunc: func(c interface{}) (interface{}, error) {
ConversionFunc: func(c any) (any, error) {
return c, nil
},
},
......
......@@ -15,7 +15,7 @@ type instanceContext struct {
once sync.Once // once protect generation of the id
}
func (ic *instanceContext) Value(key interface{}) interface{} {
func (ic *instanceContext) Value(key any) any {
if key == "instance.id" {
ic.once.Do(func() {
// We want to lazy initialize the UUID such that we don't
......@@ -45,13 +45,13 @@ func Background() context.Context {
// key, falling back to a parent if not present.
type stringMapContext struct {
context.Context
m map[string]interface{}
m map[string]any
}
// WithValues returns a context that proxies lookups through a map. Only
// supports string keys.
func WithValues(ctx context.Context, m map[string]interface{}) context.Context {
mo := make(map[string]interface{}, len(m)) // make our own copy.
func WithValues(ctx context.Context, m map[string]any) context.Context {
mo := make(map[string]any, len(m)) // make our own copy.
for k, v := range m {
mo[k] = v
}
......@@ -62,7 +62,7 @@ func WithValues(ctx context.Context, m map[string]interface{}) context.Context {
}
}
func (smc stringMapContext) Value(key interface{}) interface{} {
func (smc stringMapContext) Value(key any) any {
if ks, ok := key.(string); ok {
if v, ok := smc.m[ks]; ok {
return v
......
......@@ -234,7 +234,7 @@ type httpRequestContext struct {
// Value returns a keyed element of the request for use in the context. To get
// the request itself, query "request". For other components, access them as
// "request.<component>". For example, r.RequestURI
func (ctx *httpRequestContext) Value(key interface{}) interface{} {
func (ctx *httpRequestContext) Value(key any) any {
if keyStr, ok := key.(string); ok {
if keyStr == "http.request" {
return ctx.r
......@@ -291,7 +291,7 @@ type httpMappedRequestContext struct {
// Value returns a keyed element of the request for use in the context. To get
// the request itself, query "request". For other components, access them as
// "request.<component>". For example, r.RequestURI
func (ctx *httpMappedRequestContext) Value(key interface{}) interface{} {
func (ctx *httpMappedRequestContext) Value(key any) any {
if keyStr, ok := key.(string); ok {
// retrieve the actual http request key that corresponds to the request field
if requestFieldKey, ok := LogRequestFields[keyStr]; ok {
......@@ -306,7 +306,7 @@ type muxVarsContext struct {
vars map[string]string
}
func (ctx *muxVarsContext) Value(key interface{}) interface{} {
func (ctx *muxVarsContext) Value(key any) any {
if keyStr, ok := key.(string); ok {
if keyStr == "vars" {
return ctx.vars
......@@ -364,7 +364,7 @@ func (irw *instrumentedResponseWriter) Flush() {
}
}
func (irw *instrumentedResponseWriter) Value(key interface{}) interface{} {
func (irw *instrumentedResponseWriter) Value(key any) any {
if keyStr, ok := key.(string); ok {
if keyStr == "http.response" {
return irw
......
......@@ -27,7 +27,7 @@ func TestWithRequest(t *testing.T) {
ctx := WithRequest(Background(), &req)
for _, testcase := range []struct {
key string
expected interface{}
expected any
}{
{
key: "http.request",
......@@ -111,7 +111,7 @@ func TestWithRequest_MappedKeys(t *testing.T) {
ctx := WithRequest(Background(), &req)
for _, testcase := range []struct {
key string
expected interface{}
expected any
}{
{
key: "method",
......@@ -252,7 +252,7 @@ func TestWithVars(t *testing.T) {
ctx := WithVars(Background(), &req)
for _, testcase := range []struct {
key string
expected interface{}
expected any
}{
{
key: "vars",
......@@ -349,7 +349,7 @@ func TestWithCFRayID(t *testing.T) {
testcases := []struct {
name string
requestHeaders map[string]string
expectedContextValue interface{}
expectedContextValue any
expectedCFRayIDKey CFRayIDKey
}{
{
......
......@@ -14,41 +14,41 @@ import (
// Logger provides a leveled-logging interface.
type Logger interface {
// standard logger methods
Print(args ...interface{})
Printf(format string, args ...interface{})
Println(args ...interface{})
Print(args ...any)
Printf(format string, args ...any)
Println(args ...any)
Fatal(args ...interface{})
Fatalf(format string, args ...interface{})
Fatalln(args ...interface{})
Fatal(args ...any)
Fatalf(format string, args ...any)
Fatalln(args ...any)
Panic(args ...interface{})
Panicf(format string, args ...interface{})
Panicln(args ...interface{})
Panic(args ...any)
Panicf(format string, args ...any)
Panicln(args ...any)
// Leveled methods, from logrus
Trace(args ...interface{})
Tracef(format string, args ...interface{})
Traceln(args ...interface{})
Trace(args ...any)
Tracef(format string, args ...any)
Traceln(args ...any)
Debug(args ...interface{})
Debugf(format string, args ...interface{})
Debugln(args ...interface{})
Debug(args ...any)
Debugf(format string, args ...any)
Debugln(args ...any)
Error(args ...interface{})
Errorf(format string, args ...interface{})
Errorln(args ...interface{})
Error(args ...any)
Errorf(format string, args ...any)
Errorln(args ...any)
Info(args ...interface{})
Infof(format string, args ...interface{})
Infoln(args ...interface{})
Info(args ...any)
Infof(format string, args ...any)
Infoln(args ...any)
Warn(args ...interface{})
Warnf(format string, args ...interface{})
Warnln(args ...interface{})
Warn(args ...any)
Warnf(format string, args ...any)
Warnln(args ...any)
WithError(err error) *logrus.Entry
WithField(key string, value interface{}) *logrus.Entry
WithField(key string, value any) *logrus.Entry
WithFields(fields logrus.Fields) *logrus.Entry
}
......@@ -60,15 +60,15 @@ func WithLogger(ctx context.Context, logger Logger) context.Context {
// GetLoggerWithField returns a logger instance with the specified field key
// and value without affecting the context. Extra specified keys will be
// resolved from the context.
func GetLoggerWithField(ctx context.Context, key, value interface{}, keys ...interface{}) Logger {
func GetLoggerWithField(ctx context.Context, key, value any, keys ...any) Logger {
return getLogrusLogger(ctx, keys...).WithField(fmt.Sprint(key), value)
}
// GetLoggerWithFields returns a logger instance with the specified fields
// without affecting the context. Extra specified keys will be resolved from
// the context.
func GetLoggerWithFields(ctx context.Context, fields map[interface{}]interface{}, keys ...interface{}) Logger {
// must convert from interface{} -> interface{} to string -> interface{} for logrus.
func GetLoggerWithFields(ctx context.Context, fields map[any]any, keys ...any) Logger {
// must convert from any -> any to string -> any for logrus.
lfields := make(logrus.Fields, len(fields))
for key, value := range fields {
lfields[fmt.Sprint(key)] = value
......@@ -83,7 +83,7 @@ func GetLoggerWithFields(ctx context.Context, fields map[interface{}]interface{}
// argument passed to GetLogger will be passed to fmt.Sprint when expanded as
// a logging key field. If context keys are integer constants, for example,
// its recommended that a String method is implemented.
func GetLogger(ctx context.Context, keys ...interface{}) Logger {
func GetLogger(ctx context.Context, keys ...any) Logger {
return getLogrusLogger(ctx, keys...)
}
......@@ -91,7 +91,7 @@ func GetLogger(ctx context.Context, keys ...interface{}) Logger {
// are provided, they will be resolved on the context and included in the
// logger. Only use this function if specific logrus functionality is
// required.
func getLogrusLogger(ctx context.Context, keys ...interface{}) *logrus.Entry {
func getLogrusLogger(ctx context.Context, keys ...any) *logrus.Entry {
var logger *logrus.Entry
// Get a logger, if it is present.
......
......@@ -37,7 +37,7 @@ import (
//
// Notice that the function name is automatically resolved, along with the
// package and a trace id is emitted that can be linked with parent ids.
func WithTrace(ctx context.Context) (context.Context, func(format string, a ...interface{})) {
func WithTrace(ctx context.Context) (context.Context, func(format string, a ...any)) {
if ctx == nil {
ctx = Background()
}
......@@ -54,7 +54,7 @@ func WithTrace(ctx context.Context) (context.Context, func(format string, a ...i
line: line,
}
return ctx, func(format string, a ...interface{}) {
return ctx, func(format string, a ...any) {
GetLogger(ctx,
"trace.duration",
"trace.id",
......@@ -79,7 +79,7 @@ type traced struct {
line int
}
func (ts *traced) Value(key interface{}) interface{} {
func (ts *traced) Value(key any) any {
switch key {
case "trace.start":
return ts.start
......
......@@ -64,7 +64,7 @@ func TestWithTrace(t *testing.T) {
type valueTestCase struct {
key string
expected interface{}
expected any
notnilorempty bool // just check not empty/not nil
}
......
......@@ -809,7 +809,7 @@ middleware:
Each middleware entry has `name` and `options` entries. The `name` must
correspond to the name under which the middleware registers itself. The
`options` field is a map that details custom configuration required to
initialize the middleware. It is treated as a `map[string]interface{}`. As such,
initialize the middleware. It is treated as a `map[string]any`. As such,
it supports any interesting structures desired, leaving it up to the middleware
initialization function to best determine how to handle the specific
interpretation of the options.
......
......@@ -15,23 +15,23 @@ import (
// Logger provides a leveled-logging interface.
type Logger interface {
// standard logger methods
Print(args ...interface{})
Print(args ...any)
Fatal(args ...interface{})
Fatalln(args ...interface{})
Fatal(args ...any)
Fatalln(args ...any)
Panic(args ...interface{})
Panic(args ...any)
// Leveled methods, from logrus
Trace(args ...interface{})
Trace(args ...any)
Debug(args ...interface{})
Debug(args ...any)
Error(args ...interface{})
Error(args ...any)
Info(args ...interface{})
Info(args ...any)
Warn(args ...interface{})
Warn(args ...any)
WithError(error) Logger
WithFields(Fields) Logger
......@@ -78,7 +78,7 @@ func WithLogger(ctx context.Context, logger Logger) context.Context {
type logOptions struct {
ctx context.Context
keys []interface{}
keys []any
writer io.Writer
}
......@@ -96,7 +96,7 @@ func WithContext(ctx context.Context) logOpt {
// interface, any key argument passed to GetLogger will be passed to fmt.Sprint
// when expanded as a logging key field. If context keys are integer constants,
// for example, its recommended that a String method is implemented.
func WithKeys(keys ...interface{}) logOpt {
func WithKeys(keys ...any) logOpt {
return func(o *logOptions) {
o.keys = keys
}
......@@ -127,7 +127,7 @@ func GetLogger(opts ...logOpt) Logger {
// are provided, they will be resolved on the context and included in the
// logger. Only use this function if specific logrus functionality is
// required.
func getLogrusLogger(ctx context.Context, keys ...interface{}) *logrus.Entry {
func getLogrusLogger(ctx context.Context, keys ...any) *logrus.Entry {
var logger *logrus.Entry
// Get a logger, if it is present.
......
......@@ -278,7 +278,7 @@ func MakeV1ConfigFromConfig(configJSON []byte, v1ID, parentV1ID string, throwawa
return json.Marshal(configAsMap)
}
func rawJSON(value interface{}) *json.RawMessage {
func rawJSON(value any) *json.RawMessage {
jsonval, err := json.Marshal(value)
if err != nil {
return nil
......
......@@ -68,7 +68,7 @@ type Event struct {
}
// Meta is the event meta type
type Meta interface{}
type Meta any
// Target uniquely describes the target of the event.
type Target struct {
......
......@@ -152,11 +152,11 @@ func init() {
var notifications expvar.Map
notifications.Init()
notifications.Set("endpoints", expvar.Func(func() interface{} {
notifications.Set("endpoints", expvar.Func(func() any {
endpoints.mu.Lock()
defer endpoints.mu.Unlock()
var names []interface{}
var names []any
for _, v := range endpoints.registered {
var epjson struct {
Name string `json:"name"`
......
......@@ -11,7 +11,7 @@ import (
func TestMetricsExpvar(t *testing.T) {
endpointsVar := expvar.Get("registry").(*expvar.Map).Get("notifications").(*expvar.Map).Get("endpoints")
var v interface{}
var v any
err := json.Unmarshal([]byte(endpointsVar.String()), &v)
require.NoError(t, err, "unexpected error unmarshaling endpoints")
......@@ -22,7 +22,7 @@ func TestMetricsExpvar(t *testing.T) {
err = json.Unmarshal([]byte(endpointsVar.String()), &v)
require.NoError(t, err, "unexpected error unmarshaling endpoints")
if slice, ok := v.([]interface{}); !ok || len(slice) != 1 {
if slice, ok := v.([]any); !ok || len(slice) != 1 {
t.Logf("expected one-element []interface{}, got %#v", v)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment