mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 16:59:22 +02:00
core/lint: upgrade golangci-lint, replace interface{} with any (#5099)
* core/lint: upgrade golangci-lint, replace interface{} with any * regen proto
This commit is contained in:
parent
614048ae9c
commit
1a5b8b606f
135 changed files with 341 additions and 340 deletions
|
@ -47,7 +47,7 @@ func (cache *localCache) GetOrUpdate(
|
|||
return cached, nil
|
||||
}
|
||||
|
||||
v, err, _ := cache.singleflight.Do(strkey, func() (interface{}, error) {
|
||||
v, err, _ := cache.singleflight.Do(strkey, func() (any, error) {
|
||||
cache.mu.RLock()
|
||||
cached, ok := cache.m[strkey]
|
||||
cache.mu.RUnlock()
|
||||
|
@ -105,7 +105,7 @@ func (cache *globalCache) GetOrUpdate(
|
|||
return data, nil
|
||||
}
|
||||
|
||||
v, err, _ := cache.singleflight.Do(string(key), func() (interface{}, error) {
|
||||
v, err, _ := cache.singleflight.Do(string(key), func() (any, error) {
|
||||
data, expiry, ok := cache.get(key)
|
||||
if ok && now.Before(expiry) {
|
||||
return data, nil
|
||||
|
|
|
@ -14,7 +14,7 @@ func TestLocalCache(t *testing.T) {
|
|||
defer clearTimeout()
|
||||
|
||||
callCount := 0
|
||||
update := func(ctx context.Context) ([]byte, error) {
|
||||
update := func(_ context.Context) ([]byte, error) {
|
||||
callCount++
|
||||
return []byte("v1"), nil
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func TestGlobalCache(t *testing.T) {
|
|||
defer clearTimeout()
|
||||
|
||||
callCount := 0
|
||||
update := func(ctx context.Context) ([]byte, error) {
|
||||
update := func(_ context.Context) ([]byte, error) {
|
||||
callCount++
|
||||
return []byte("v1"), nil
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func TestGlobalCache(t *testing.T) {
|
|||
assert.Equal(t, 2, callCount)
|
||||
|
||||
assert.Eventually(t, func() bool {
|
||||
_, err := c.GetOrUpdate(ctx, []byte("k1"), func(ctx context.Context) ([]byte, error) {
|
||||
_, err := c.GetOrUpdate(ctx, []byte("k1"), func(_ context.Context) ([]byte, error) {
|
||||
return nil, fmt.Errorf("ERROR")
|
||||
})
|
||||
return err != nil
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
)
|
||||
|
||||
func TestFilterExpressionFromStruct(t *testing.T) {
|
||||
type M = map[string]interface{}
|
||||
type A = []interface{}
|
||||
type M = map[string]any
|
||||
type A = []any
|
||||
|
||||
s, err := structpb.NewStruct(M{
|
||||
"$and": A{
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
func TestGetRecordIndex(t *testing.T) {
|
||||
type M = map[string]interface{}
|
||||
type M = map[string]any
|
||||
t.Run("missing", func(t *testing.T) {
|
||||
v, err := structpb.NewStruct(M{
|
||||
"notindex": "value",
|
||||
|
|
|
@ -24,7 +24,7 @@ func newSyncLatestRecordStream(
|
|||
}
|
||||
|
||||
var ready []*databroker.Record
|
||||
generator := func(ctx context.Context, block bool) (*databroker.Record, error) {
|
||||
generator := func(_ context.Context, _ bool) (*databroker.Record, error) {
|
||||
backend.mu.RLock()
|
||||
for _, co := range backend.lookup {
|
||||
for _, record := range co.List() {
|
||||
|
@ -39,7 +39,7 @@ func newSyncLatestRecordStream(
|
|||
|
||||
return storage.NewRecordStream(ctx, backend.closed, []storage.RecordStreamGenerator{
|
||||
generator,
|
||||
func(ctx context.Context, block bool) (*databroker.Record, error) {
|
||||
func(_ context.Context, _ bool) (*databroker.Record, error) {
|
||||
if len(ready) == 0 {
|
||||
return nil, storage.ErrStreamDone
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/pomerium/pomerium/pkg/storage"
|
||||
)
|
||||
|
||||
func addFilterExpressionToQuery(query *string, args *[]interface{}, expr storage.FilterExpression) error {
|
||||
func addFilterExpressionToQuery(query *string, args *[]any, expr storage.FilterExpression) error {
|
||||
compoundExpression := func(subexprs []storage.FilterExpression, op string) error {
|
||||
*query += "( "
|
||||
for i, subexpr := range subexprs {
|
||||
|
|
|
@ -39,9 +39,9 @@ var (
|
|||
)
|
||||
|
||||
type querier interface {
|
||||
Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error)
|
||||
Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
|
||||
QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
|
||||
Exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error)
|
||||
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
|
||||
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
|
||||
}
|
||||
|
||||
func deleteChangesBefore(ctx context.Context, q querier, cutoff time.Time) error {
|
||||
|
@ -207,7 +207,7 @@ func getRecord(
|
|||
}
|
||||
|
||||
func listRecords(ctx context.Context, q querier, expr storage.FilterExpression, offset, limit int) ([]*databroker.Record, error) {
|
||||
args := []interface{}{offset, limit}
|
||||
args := []any{offset, limit}
|
||||
query := `
|
||||
SELECT type, id, version, data, modified_at
|
||||
FROM ` + schemaName + `.` + recordsTableName + `
|
||||
|
|
|
@ -112,7 +112,7 @@ func matchProtoListValue(fd protoreflect.FieldDescriptor, l protoreflect.List, q
|
|||
|
||||
func matchProtoMapValue(fd protoreflect.FieldDescriptor, m protoreflect.Map, query string) bool {
|
||||
matches := false
|
||||
m.Range(func(k protoreflect.MapKey, v protoreflect.Value) bool {
|
||||
m.Range(func(_ protoreflect.MapKey, v protoreflect.Value) bool {
|
||||
matches = matches || matchProtoSingularValue(fd, v, query)
|
||||
return !matches
|
||||
})
|
||||
|
|
|
@ -107,7 +107,7 @@ func RecordStreamToList(recordStream RecordStream) ([]*databroker.Record, error)
|
|||
// RecordListToStream converts a record list to a stream.
|
||||
func RecordListToStream(ctx context.Context, records []*databroker.Record) RecordStream {
|
||||
return NewRecordStream(ctx, nil, []RecordStreamGenerator{
|
||||
func(ctx context.Context, block bool) (*databroker.Record, error) {
|
||||
func(_ context.Context, _ bool) (*databroker.Record, error) {
|
||||
if len(records) == 0 {
|
||||
return nil, ErrStreamDone
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@ func RecordStreamFilterFromFilterExpression(
|
|||
expr FilterExpression,
|
||||
) (filter RecordStreamFilter, err error) {
|
||||
if expr == nil {
|
||||
return func(record *databroker.Record) (keep bool) { return true }, nil
|
||||
return func(_ *databroker.Record) (keep bool) { return true }, nil
|
||||
}
|
||||
|
||||
switch expr := expr.(type) {
|
||||
case AndFilterExpression:
|
||||
if len(expr) == 0 {
|
||||
return func(record *databroker.Record) (keep bool) { return true }, nil
|
||||
return func(_ *databroker.Record) (keep bool) { return true }, nil
|
||||
}
|
||||
|
||||
fs := make([]RecordStreamFilter, len(expr))
|
||||
|
@ -73,7 +73,7 @@ func RecordStreamFilterFromFilterExpression(
|
|||
}, nil
|
||||
case OrFilterExpression:
|
||||
if len(expr) == 0 {
|
||||
return func(record *databroker.Record) (keep bool) { return true }, nil
|
||||
return func(_ *databroker.Record) (keep bool) { return true }, nil
|
||||
}
|
||||
|
||||
fs := make([]RecordStreamFilter, len(expr))
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestRecordStreamFilterFromFilterExpression(t *testing.T) {
|
||||
type M = map[string]interface{}
|
||||
type M = map[string]any
|
||||
|
||||
s, err := structpb.NewStruct(M{
|
||||
"$index": M{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue