Skip to content

Commit 6ec0fde

Browse files
committed
apply linter v2.13.1 and modernize v0.23.0 to codebase
Signed-off-by: SungJin1212 <tjdwls1201@gmail.com>
1 parent 30c6a73 commit 6ec0fde

46 files changed

Lines changed: 1013 additions & 1236 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ check-protos: clean-protos protos
223223
@git diff --exit-code -- $(PROTO_GOS)
224224

225225
modernize:
226-
GOTOOLCHAIN=auto go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.22.0 -fix ./...
226+
GOTOOLCHAIN=auto go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v0.23.0 -fix ./...
227227

228228
# Generates the config file documentation.
229229
doc: clean-doc

integration/query_fuzz_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,10 +1599,10 @@ func TestStoreGatewayLazyExpandedPostingsSeriesFuzzWithPrometheus(t *testing.T)
15991599

16001600
flags := mergeFlags(BlocksStorageFlags(), map[string]string{
16011601
"-blocks-storage.bucket-store.index-cache.backend": tsdb.IndexCacheBackendInMemory,
1602-
"-ring.store": "consul",
1603-
"-consul.hostname": consul.NetworkHTTPEndpoint(),
1604-
"-store-gateway.sharding-enabled": "false",
1605-
"-blocks-storage.bucket-store.sync-interval": "1s",
1602+
"-ring.store": "consul",
1603+
"-consul.hostname": consul.NetworkHTTPEndpoint(),
1604+
"-store-gateway.sharding-enabled": "false",
1605+
"-blocks-storage.bucket-store.sync-interval": "1s",
16061606
"-blocks-storage.bucket-store.lazy-expanded-postings-enabled": "true",
16071607
})
16081608

pkg/alertmanager/alertmanager_test.go

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -143,33 +143,29 @@ route:
143143

144144
inputAlerts := []*alert.Alert{
145145
{
146-
Alert: model.Alert{
147-
Labels: model.LabelSet{
148-
"alertname": alertName,
149-
"a": "b",
150-
},
151-
Annotations: model.LabelSet{"foo": "bar"},
152-
StartsAt: now,
153-
EndsAt: now.Add(5 * time.Minute),
154-
GeneratorURL: "http://example.com/prometheus",
146+
Labels: model.LabelSet{
147+
"alertname": alertName,
148+
"a": "b",
155149
},
156-
UpdatedAt: now,
157-
Timeout: false,
150+
Annotations: model.LabelSet{"foo": "bar"},
151+
StartsAt: now,
152+
EndsAt: now.Add(5 * time.Minute),
153+
GeneratorURL: "http://example.com/prometheus",
154+
UpdatedAt: now,
155+
Timeout: false,
158156
},
159157

160158
{
161-
Alert: model.Alert{
162-
Labels: model.LabelSet{
163-
"alertname": alertName,
164-
"z": "y",
165-
},
166-
Annotations: model.LabelSet{"foo": "bar"},
167-
StartsAt: now,
168-
EndsAt: now.Add(5 * time.Minute),
169-
GeneratorURL: "http://example.com/prometheus",
159+
Labels: model.LabelSet{
160+
"alertname": alertName,
161+
"z": "y",
170162
},
171-
UpdatedAt: now,
172-
Timeout: false,
163+
Annotations: model.LabelSet{"foo": "bar"},
164+
StartsAt: now,
165+
EndsAt: now.Add(5 * time.Minute),
166+
GeneratorURL: "http://example.com/prometheus",
167+
UpdatedAt: now,
168+
Timeout: false,
173169
},
174170
}
175171
require.NoError(t, am.alerts.Put(context.Background(), inputAlerts...))

pkg/alertmanager/merger/v2_alerts_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ func v2alert(fingerprint, annotation, updatedAt string) *v2_models.GettableAlert
7373
Name: &receiver,
7474
},
7575
},
76-
StartsAt: v2ParseTime("2020-01-01T12:00:00.000Z"),
77-
Status: &v2_models.AlertStatus{},
78-
UpdatedAt: v2ParseTime(updatedAt),
79-
Alert: v2_models.Alert{
80-
GeneratorURL: strfmt.URI("something"),
81-
Labels: v2_models.LabelSet{"label1": "foo"},
82-
},
76+
StartsAt: v2ParseTime("2020-01-01T12:00:00.000Z"),
77+
Status: &v2_models.AlertStatus{},
78+
UpdatedAt: v2ParseTime(updatedAt),
79+
GeneratorURL: strfmt.URI("something"),
80+
Labels: v2_models.LabelSet{"label1": "foo"},
8381
}
8482
}
8583

pkg/alertmanager/merger/v2_silences_test.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,18 @@ func v2silence(id, endsAt, updatedAt string) *v2_models.GettableSilence {
7676
State: &active,
7777
},
7878
UpdatedAt: v2ParseTime(updatedAt),
79-
Silence: v2_models.Silence{
80-
Comment: &comment,
81-
CreatedBy: &createdBy,
82-
EndsAt: v2ParseTime(endsAt),
83-
Matchers: v2_models.Matchers{
84-
&v2_models.Matcher{
85-
IsEqual: &isEqual,
86-
IsRegex: &isRegex,
87-
Name: &name,
88-
Value: &value,
89-
},
79+
Comment: &comment,
80+
CreatedBy: &createdBy,
81+
EndsAt: v2ParseTime(endsAt),
82+
Matchers: v2_models.Matchers{
83+
&v2_models.Matcher{
84+
IsEqual: &isEqual,
85+
IsRegex: &isRegex,
86+
Name: &name,
87+
Value: &value,
9088
},
91-
StartsAt: v2ParseTime("2020-01-01T12:00:00.000Z"),
9289
},
90+
StartsAt: v2ParseTime("2020-01-01T12:00:00.000Z"),
9391
}
9492
}
9593

pkg/alertmanager/multitenant_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,9 @@ receivers:
713713

714714
// Create an alert to push.
715715
alerts := alert.Alerts(&alert.Alert{
716-
Alert: model.Alert{
717-
Labels: map[model.LabelName]model.LabelValue{model.AlertNameLabel: "test"},
718-
StartsAt: time.Now().Add(-time.Minute),
719-
EndsAt: time.Now().Add(time.Minute),
720-
},
716+
Labels: map[model.LabelName]model.LabelValue{model.AlertNameLabel: "test"},
717+
StartsAt: time.Now().Add(-time.Minute),
718+
EndsAt: time.Now().Add(time.Minute),
721719
UpdatedAt: time.Now(),
722720
Timeout: false,
723721
})

pkg/compactor/block_visit_marker_test.go

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/go-kit/log"
99
"github.com/oklog/ulid/v2"
1010
"github.com/prometheus/client_golang/prometheus"
11-
"github.com/prometheus/prometheus/tsdb"
1211
"github.com/stretchr/testify/require"
1312
"github.com/thanos-io/objstore"
1413
"github.com/thanos-io/thanos/pkg/block/metadata"
@@ -36,19 +35,13 @@ func TestMarkBlocksVisited(t *testing.T) {
3635
},
3736
blocks: []*metadata.Meta{
3837
{
39-
BlockMeta: tsdb.BlockMeta{
40-
ULID: ulid0,
41-
},
38+
ULID: ulid0,
4239
},
4340
{
44-
BlockMeta: tsdb.BlockMeta{
45-
ULID: ulid1,
46-
},
41+
ULID: ulid1,
4742
},
4843
{
49-
BlockMeta: tsdb.BlockMeta{
50-
ULID: ulid2,
51-
},
44+
ULID: ulid2,
5245
},
5346
},
5447
},
@@ -61,19 +54,13 @@ func TestMarkBlocksVisited(t *testing.T) {
6154
},
6255
blocks: []*metadata.Meta{
6356
{
64-
BlockMeta: tsdb.BlockMeta{
65-
ULID: ulid0,
66-
},
57+
ULID: ulid0,
6758
},
6859
{
69-
BlockMeta: tsdb.BlockMeta{
70-
ULID: ulid1,
71-
},
60+
ULID: ulid1,
7261
},
7362
{
74-
BlockMeta: tsdb.BlockMeta{
75-
ULID: ulid2,
76-
},
63+
ULID: ulid2,
7764
},
7865
},
7966
},

pkg/compactor/compactor_paritioning_test.go

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/prometheus/client_golang/prometheus"
2121
prom_testutil "github.com/prometheus/client_golang/prometheus/testutil"
2222
"github.com/prometheus/prometheus/model/labels"
23-
"github.com/prometheus/prometheus/tsdb"
2423
"github.com/stretchr/testify/assert"
2524
"github.com/stretchr/testify/mock"
2625
"github.com/stretchr/testify/require"
@@ -997,18 +996,14 @@ func TestPartitionCompactor_ShouldSkipOutOrOrderBlocks(t *testing.T) {
997996

998997
tsdbPlanner.On("Plan", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]*metadata.Meta{
999998
{
1000-
BlockMeta: tsdb.BlockMeta{
1001-
ULID: b1,
1002-
MinTime: 10,
1003-
MaxTime: 20,
1004-
},
999+
ULID: b1,
1000+
MinTime: 10,
1001+
MaxTime: 20,
10051002
},
10061003
{
1007-
BlockMeta: tsdb.BlockMeta{
1008-
ULID: b2,
1009-
MinTime: 20,
1010-
MaxTime: 30,
1011-
},
1004+
ULID: b2,
1005+
MinTime: 20,
1006+
MaxTime: 30,
10121007
},
10131008
}, nil)
10141009

@@ -2031,11 +2026,9 @@ func (s *raceConditionTestSetup) createCortexMetaExtensions(creationTime int64)
20312026
func (s *raceConditionTestSetup) createTestMetadata() []*metadata.Meta {
20322027
return []*metadata.Meta{
20332028
{
2034-
BlockMeta: tsdb.BlockMeta{
2035-
ULID: ulid.MustNew(ulid.Now(), nil),
2036-
MinTime: 0,
2037-
MaxTime: 2 * 60 * 60 * 1000,
2038-
},
2029+
ULID: ulid.MustNew(ulid.Now(), nil),
2030+
MinTime: 0,
2031+
MaxTime: 2 * 60 * 60 * 1000,
20392032
},
20402033
}
20412034
}

pkg/compactor/compactor_test.go

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -955,18 +955,14 @@ func TestCompactor_ShouldSkipOutOrOrderBlocks(t *testing.T) {
955955

956956
tsdbPlanner.On("Plan", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]*metadata.Meta{
957957
{
958-
BlockMeta: tsdb.BlockMeta{
959-
ULID: b1,
960-
MinTime: 10,
961-
MaxTime: 20,
962-
},
958+
ULID: b1,
959+
MinTime: 10,
960+
MaxTime: 20,
963961
},
964962
{
965-
BlockMeta: tsdb.BlockMeta{
966-
ULID: b2,
967-
MinTime: 20,
968-
MaxTime: 30,
969-
},
963+
ULID: b2,
964+
MinTime: 20,
965+
MaxTime: 30,
970966
},
971967
}, nil)
972968

@@ -1735,18 +1731,17 @@ func mockBlockMetaJSONWithTime(id string, orgID string, minTime int64, maxTime i
17351731
Thanos: metadata.Thanos{
17361732
Labels: map[string]string{"__org_id__": orgID},
17371733
},
1738-
}
17391734

1740-
meta.BlockMeta = tsdb.BlockMeta{
1741-
Version: 1,
1742-
ULID: ulid.MustParse(id),
1743-
MinTime: minTime,
1744-
MaxTime: maxTime,
1745-
Compaction: tsdb.BlockMetaCompaction{
1746-
Level: 1,
1747-
Sources: []ulid.ULID{ulid.MustParse(id)},
1748-
},
1749-
}
1735+
BlockMeta: tsdb.BlockMeta{
1736+
Version: 1,
1737+
ULID: ulid.MustParse(id),
1738+
MinTime: minTime,
1739+
MaxTime: maxTime,
1740+
Compaction: tsdb.BlockMetaCompaction{
1741+
Level: 1,
1742+
Sources: []ulid.ULID{ulid.MustParse(id)},
1743+
},
1744+
}}
17501745

17511746
content, err := json.Marshal(meta)
17521747
if err != nil {
@@ -1987,18 +1982,14 @@ func TestCompactor_ShouldNotTreatInterruptionsAsErrors(t *testing.T) {
19871982
})
19881983
tsdbPlanner.On("Plan", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]*metadata.Meta{
19891984
{
1990-
BlockMeta: tsdb.BlockMeta{
1991-
ULID: b1,
1992-
MinTime: 10,
1993-
MaxTime: 20,
1994-
},
1985+
ULID: b1,
1986+
MinTime: 10,
1987+
MaxTime: 20,
19951988
},
19961989
{
1997-
BlockMeta: tsdb.BlockMeta{
1998-
ULID: b2,
1999-
MinTime: 20,
2000-
MaxTime: 30,
2001-
},
1990+
ULID: b2,
1991+
MinTime: 20,
1992+
MaxTime: 30,
20021993
},
20031994
}, nil)
20041995
require.NoError(t, services.StartAndAwaitRunning(ctx, c))

pkg/compactor/partition_compaction_grouper.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,9 @@ func (g *PartitionCompactionGrouper) partitionBlocksGroup(partitionCount int, bl
500500
addToPartitionedGroups := func(blocks []*metadata.Meta, partitionID int) {
501501
if _, ok := partitionedGroups[partitionID]; !ok {
502502
partitionedGroups[partitionID] = blocksGroupWithPartition{
503-
blocksGroup: blocksGroup{
504-
rangeStart: rangeStart,
505-
rangeEnd: rangeEnd,
506-
blocks: []*metadata.Meta{},
507-
},
503+
rangeStart: rangeStart,
504+
rangeEnd: rangeEnd,
505+
blocks: []*metadata.Meta{},
508506
}
509507
}
510508
partitionedGroup := partitionedGroups[partitionID]

0 commit comments

Comments
 (0)