Skip to content

Commit ef29348

Browse files
committed
chore: fix static check issues, take advantage of go1.23 feature
1 parent acd9dd5 commit ef29348

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

authorization/storage.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
goerrors "errors"
66
"fmt"
7+
"slices"
78

89
"github.com/go-crypt/crypt"
910
"github.com/influxdata/influxdb/v2"
@@ -241,7 +242,7 @@ func (s *Store) autogenerateHasher(ctx context.Context, variantName string) (*Au
241242
hasherVariant := influxdb2_algo.NewVariant(variantName)
242243
decoderVariants = append(decoderVariants, hasherVariant)
243244
delete(foundVariants, hasherVariant)
244-
for variant, _ := range foundVariants {
245+
for variant := range foundVariants {
245246
decoderVariants = append(decoderVariants, variant)
246247
}
247248

@@ -274,26 +275,13 @@ func (s *Store) hashedTokenMigration(ctx context.Context) error {
274275
return err
275276
}
276277

277-
/*
278-
for batch := range slices.Chunk(authsNeedingUpdate, 100) {
279-
err := s.Update(ctx, func(tx kv.Tx) error {
280-
// Now update them. This really seems too simple, but s.UpdateJAuthorization() is magical.
281-
for _, a := range batch {
282-
if _, err := s.UpdateAuthorization(ctx, tx, a.ID, a); err != nil {
283-
return err
284-
}
278+
for batch := range slices.Chunk(authsNeedingUpdate, 100) {
279+
err := s.Update(ctx, func(tx kv.Tx) error {
280+
// Now update them. This really seems too simple, but s.UpdateJAuthorization() is magical.
281+
for _, a := range batch {
282+
if _, err := s.UpdateAuthorization(ctx, tx, a.ID, a); err != nil {
283+
return err
285284
}
286-
return nil
287-
})
288-
if err != nil {
289-
return fmt.Errorf("error migrating hashed tokens: %w", err)
290-
}
291-
}
292-
*/
293-
for _, a := range authsNeedingUpdate {
294-
err = s.Update(ctx, func(tx kv.Tx) error {
295-
if _, err := s.UpdateAuthorization(ctx, tx, a.ID, a); err != nil {
296-
return err
297285
}
298286
return nil
299287
})

http/auth_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"testing"
1212

1313
"github.com/influxdata/httprouter"
14-
"github.com/influxdata/influxdb/v2"
1514
platform "github.com/influxdata/influxdb/v2"
1615
"github.com/influxdata/influxdb/v2/authorization"
1716
pcontext "github.com/influxdata/influxdb/v2/context"
@@ -956,7 +955,7 @@ func initAuthorizationService(f platformtesting.AuthorizationFields, useTokenHas
956955

957956
func runAuthorizationServiceTest(
958957
name string,
959-
tf func(init func(platformtesting.AuthorizationFields, *testing.T) (influxdb.AuthorizationService, string, func()), t *testing.T),
958+
tf func(init func(platformtesting.AuthorizationFields, *testing.T) (platform.AuthorizationService, string, func()), t *testing.T),
960959
initWithHashing func(f platformtesting.AuthorizationFields, useTokenHashing bool, t *testing.T) (platform.AuthorizationService, string, func()),
961960
t *testing.T,
962961
) {

0 commit comments

Comments
 (0)