Skip to content

Commit 265b14c

Browse files
chore(golangci): address failed linter checks
There were two types of failed checks: - context.Background() could be replaced by t.Context() - printf: non-constant format string in call to github.com/pkg/errors.Wrapf
1 parent 77c201d commit 265b14c

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

pkg/service/restore/alternator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (sw *alternatorSchemaWorker) restore(ctx context.Context) (err error) {
6565
TableName: aws.String(t),
6666
})
6767
if delErr != nil {
68-
err = stdErr.Join(err, errors.Wrapf(delErr, "rollback creation of alternator table "+t))
68+
err = stdErr.Join(err, errors.Wrap(delErr, "rollback creation of alternator table "+t))
6969
return
7070
}
7171
}

pkg/testutils/db/db.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func CreateScyllaManagerDBSession(tb testing.TB) gocqlx.Session {
4848
session := createSessionFromCluster(tb, cluster)
4949

5050
migrate.Callback = nopmigrate.Callback
51-
if err := migrate.FromFS(context.Background(), session, schema.Files); err != nil {
51+
if err := migrate.FromFS(tb.Context(), session, schema.Files); err != nil {
5252
tb.Fatal("migrate:", err)
5353
}
5454
return session
@@ -83,9 +83,8 @@ func CreateSession(tb testing.TB, client *scyllaclient.Client) gocqlx.Session {
8383
// It allows to specify cql user and decide if cluster should be cleared.
8484
func CreateManagedClusterSession(tb testing.TB, empty bool, client *scyllaclient.Client, user, pass string) gocqlx.Session {
8585
tb.Helper()
86-
ctx := context.Background()
8786

88-
sessionHosts, err := cluster.GetRPCAddresses(ctx, client, client.Config().Hosts, false)
87+
sessionHosts, err := cluster.GetRPCAddresses(tb.Context(), client, client.Config().Hosts, false)
8988
if err != nil {
9089
tb.Log(err)
9190
if errors.Is(err, cluster.ErrNoRPCAddressesFound) {
@@ -279,7 +278,7 @@ func FlushTable(t *testing.T, client *scyllaclient.Client, hosts []string, keysp
279278
t.Helper()
280279

281280
for _, h := range hosts {
282-
if err := client.FlushTable(context.Background(), h, keyspace, table); err != nil {
281+
if err := client.FlushTable(t.Context(), h, keyspace, table); err != nil {
283282
t.Fatal(err)
284283
}
285284
}
@@ -352,7 +351,7 @@ func GetAlternatorCreds(t *testing.T, s gocqlx.Session, role string) (accessKeyI
352351
func CreateAlternatorClient(t *testing.T, client *scyllaclient.Client, host, accessKeyID, secretAccessKey string) *dynamodb.Client {
353352
t.Helper()
354353

355-
ni, err := client.NodeInfo(context.Background(), host)
354+
ni, err := client.NodeInfo(t.Context(), host)
356355
if err != nil {
357356
t.Fatal(err)
358357
}
@@ -471,7 +470,7 @@ func CreateAlternatorTable(t *testing.T, client *dynamodb.Client, lsiCnt, gsiCnt
471470
}
472471

473472
for _, table := range tables {
474-
_, err := client.CreateTable(context.Background(), &dynamodb.CreateTableInput{
473+
_, err := client.CreateTable(t.Context(), &dynamodb.CreateTableInput{
475474
TableName: aws.String(table),
476475
AttributeDefinitions: attrDef,
477476
KeySchema: []types.KeySchemaElement{
@@ -499,7 +498,7 @@ func CreateAlternatorGSI(t *testing.T, client *dynamodb.Client, table string, gs
499498
t.Helper()
500499

501500
for _, gsi := range gsis {
502-
_, err := client.UpdateTable(context.Background(), &dynamodb.UpdateTableInput{
501+
_, err := client.UpdateTable(t.Context(), &dynamodb.UpdateTableInput{
503502
TableName: aws.String(table),
504503
AttributeDefinitions: []types.AttributeDefinition{
505504
{
@@ -542,14 +541,14 @@ func CreateAlternatorGSI(t *testing.T, client *dynamodb.Client, table string, gs
542541
func TagAlternatorTable(t *testing.T, client *dynamodb.Client, table string, tags ...string) {
543542
t.Helper()
544543

545-
out, err := client.DescribeTable(context.Background(), &dynamodb.DescribeTableInput{
544+
out, err := client.DescribeTable(t.Context(), &dynamodb.DescribeTableInput{
546545
TableName: aws.String(table),
547546
})
548547
if err != nil {
549548
t.Fatal(err)
550549
}
551550

552-
_, err = client.TagResource(context.Background(), &dynamodb.TagResourceInput{
551+
_, err = client.TagResource(t.Context(), &dynamodb.TagResourceInput{
553552
ResourceArn: out.Table.TableArn,
554553
Tags: slices2.Map(tags, func(tag string) types.Tag {
555554
return types.Tag{
@@ -567,7 +566,7 @@ func TagAlternatorTable(t *testing.T, client *dynamodb.Client, table string, tag
567566
func UpdateAlternatorTableTTL(t *testing.T, client *dynamodb.Client, table, attr string, enabled bool) {
568567
t.Helper()
569568

570-
_, err := client.UpdateTimeToLive(context.Background(), &dynamodb.UpdateTimeToLiveInput{
569+
_, err := client.UpdateTimeToLive(t.Context(), &dynamodb.UpdateTimeToLiveInput{
571570
TableName: aws.String(table),
572571
TimeToLiveSpecification: &types.TimeToLiveSpecification{
573572
AttributeName: aws.String(attr),
@@ -611,7 +610,7 @@ func InsertAlternatorTableData(t *testing.T, client *dynamodb.Client, rowCnt int
611610
table: writeRequests,
612611
},
613612
}
614-
_, err := client.BatchWriteItem(context.Background(), in)
613+
_, err := client.BatchWriteItem(t.Context(), in)
615614
if err != nil {
616615
t.Fatal(err)
617616
}
@@ -624,7 +623,7 @@ func ValidateAlternatorTableData(t *testing.T, client *dynamodb.Client, rowCnt,
624623
t.Helper()
625624

626625
for _, table := range tables {
627-
out, err := client.Scan(context.Background(), &dynamodb.ScanInput{
626+
out, err := client.Scan(t.Context(), &dynamodb.ScanInput{
628627
TableName: aws.String(table),
629628
})
630629
if err != nil {
@@ -635,7 +634,7 @@ func ValidateAlternatorTableData(t *testing.T, client *dynamodb.Client, rowCnt,
635634
}
636635

637636
for lsi := range lsiCnt {
638-
out, err = client.Scan(context.Background(), &dynamodb.ScanInput{
637+
out, err = client.Scan(t.Context(), &dynamodb.ScanInput{
639638
TableName: aws.String(table),
640639
IndexName: aws.String(fmt.Sprint(AlternatorLSIPrefix, lsi)),
641640
})
@@ -648,7 +647,7 @@ func ValidateAlternatorTableData(t *testing.T, client *dynamodb.Client, rowCnt,
648647
}
649648

650649
for gsi := range gsiCnt {
651-
out, err = client.Scan(context.Background(), &dynamodb.ScanInput{
650+
out, err = client.Scan(t.Context(), &dynamodb.ScanInput{
652651
TableName: aws.String(table),
653652
IndexName: aws.String(fmt.Sprint(AlternatorGSIPrefix, gsi)),
654653
})
@@ -667,7 +666,7 @@ func ValidateAlternatorGSIData(t *testing.T, client *dynamodb.Client, rowCnt int
667666
t.Helper()
668667

669668
for _, gsi := range gsis {
670-
out, err := client.Scan(context.Background(), &dynamodb.ScanInput{
669+
out, err := client.Scan(t.Context(), &dynamodb.ScanInput{
671670
TableName: aws.String(table),
672671
IndexName: aws.String(gsi),
673672
})

pkg/testutils/testhelper/helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func NewTestConfigCacheSvc(t *testing.T, clusterID uuid.UUID, hosts []string) co
144144
if err != nil {
145145
t.Fatal(err)
146146
}
147-
err = clusterSvc.PutCluster(context.Background(), ValidCluster(t, clusterID, hosts[0]))
147+
err = clusterSvc.PutCluster(t.Context(), ValidCluster(t, clusterID, hosts[0]))
148148
if err != nil {
149149
t.Fatal(err)
150150
}
@@ -157,7 +157,7 @@ func NewTestConfigCacheSvc(t *testing.T, clusterID uuid.UUID, hosts []string) co
157157
}
158158

159159
svc := configcache.NewService(configcache.DefaultConfig(), clusterSvc, scyllaClientProvider, secretsStore, log.NewDevelopment())
160-
svc.Init(context.Background())
160+
svc.Init(t.Context())
161161
return svc
162162
}
163163

pkg/testutils/version.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package testutils
44

55
import (
6-
"context"
76
"testing"
87

98
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient"
@@ -15,7 +14,7 @@ import (
1514
func CheckAnyConstraint(t *testing.T, client *scyllaclient.Client, constraints ...string) bool {
1615
t.Helper()
1716

18-
ni, err := client.AnyNodeInfo(context.Background())
17+
ni, err := client.AnyNodeInfo(t.Context())
1918
if err != nil {
2019
t.Fatal(err)
2120
}

0 commit comments

Comments
 (0)