Skip to content

Commit 6ba0661

Browse files
committed
fix: golangci-lint issues
1 parent 469dd1f commit 6ba0661

File tree

84 files changed

+313
-381
lines changed

Some content is hidden

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

84 files changed

+313
-381
lines changed

acl/enterprisemeta_ce.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ func (m *EnterpriseMeta) MergeNoWildcard(_ *EnterpriseMeta) {
8484
// do nothing
8585
}
8686

87-
func (_ *EnterpriseMeta) Normalize() {}
88-
func (_ *EnterpriseMeta) NormalizePartition() {}
89-
func (_ *EnterpriseMeta) NormalizeNamespace() {}
87+
func (*EnterpriseMeta) Normalize() {}
88+
func (*EnterpriseMeta) NormalizePartition() {}
89+
func (*EnterpriseMeta) NormalizeNamespace() {}
9090

9191
func (m *EnterpriseMeta) Matches(_ *EnterpriseMeta) bool {
9292
return true

agent/agent_endpoint_test.go

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import (
4040
"github.com/hashicorp/consul/agent/local"
4141
"github.com/hashicorp/consul/agent/structs"
4242
"github.com/hashicorp/consul/agent/token"
43-
tokenStore "github.com/hashicorp/consul/agent/token"
4443
"github.com/hashicorp/consul/api"
4544
"github.com/hashicorp/consul/envoyextensions/xdscommon"
4645
"github.com/hashicorp/consul/lib"
@@ -1728,7 +1727,7 @@ func newDefaultBaseDeps(t *testing.T) BaseDeps {
17281727
func TestHTTPHandlers_AgentMetricsStream_ACLDeny(t *testing.T) {
17291728
t.Skip("this test panics without a license manager in enterprise")
17301729
bd := newDefaultBaseDeps(t)
1731-
bd.Tokens = new(tokenStore.Store)
1730+
bd.Tokens = new(token.Store)
17321731
sink := metrics.NewInmemSink(30*time.Millisecond, time.Second)
17331732
bd.MetricsConfig = &lib.MetricsConfig{
17341733
Handler: sink,
@@ -1760,7 +1759,7 @@ func TestHTTPHandlers_AgentMetricsStream_ACLDeny(t *testing.T) {
17601759
func TestHTTPHandlers_AgentMetricsStream(t *testing.T) {
17611760
t.Skip("this test panics without a license manager in enterprise")
17621761
bd := newDefaultBaseDeps(t)
1763-
bd.Tokens = new(tokenStore.Store)
1762+
bd.Tokens = new(token.Store)
17641763
sink := metrics.NewInmemSink(20*time.Millisecond, time.Second)
17651764
bd.MetricsConfig = &lib.MetricsConfig{
17661765
Handler: sink,
@@ -6479,15 +6478,15 @@ func TestAgent_Token(t *testing.T) {
64796478

64806479
type tokens struct {
64816480
user string
6482-
userSource tokenStore.TokenSource
6481+
userSource token.TokenSource
64836482
agent string
6484-
agentSource tokenStore.TokenSource
6483+
agentSource token.TokenSource
64856484
agentRecovery string
6486-
agentRecoverySource tokenStore.TokenSource
6485+
agentRecoverySource token.TokenSource
64876486
repl string
6488-
replSource tokenStore.TokenSource
6487+
replSource token.TokenSource
64896488
registration string
6490-
registrationSource tokenStore.TokenSource
6489+
registrationSource token.TokenSource
64916490
}
64926491

64936492
resetTokens := func(init tokens) {
@@ -6538,7 +6537,7 @@ func TestAgent_Token(t *testing.T) {
65386537
url: "acl_token",
65396538
body: body("U"),
65406539
code: http.StatusOK,
6541-
raw: tokens{user: "U", userSource: tokenStore.TokenSourceAPI},
6540+
raw: tokens{user: "U", userSource: token.TokenSourceAPI},
65426541
effective: tokens{user: "U", agent: "U"},
65436542
},
65446543
{
@@ -6547,7 +6546,7 @@ func TestAgent_Token(t *testing.T) {
65476546
url: "default",
65486547
body: body("U"),
65496548
code: http.StatusOK,
6550-
raw: tokens{user: "U", userSource: tokenStore.TokenSourceAPI},
6549+
raw: tokens{user: "U", userSource: token.TokenSourceAPI},
65516550
effective: tokens{user: "U", agent: "U"},
65526551
},
65536552
{
@@ -6557,7 +6556,7 @@ func TestAgent_Token(t *testing.T) {
65576556
body: body("A"),
65586557
code: http.StatusOK,
65596558
init: tokens{user: "U", agent: "U"},
6560-
raw: tokens{user: "U", agent: "A", agentSource: tokenStore.TokenSourceAPI},
6559+
raw: tokens{user: "U", agent: "A", agentSource: token.TokenSourceAPI},
65616560
effective: tokens{user: "U", agent: "A"},
65626561
},
65636562
{
@@ -6567,7 +6566,7 @@ func TestAgent_Token(t *testing.T) {
65676566
body: body("A"),
65686567
code: http.StatusOK,
65696568
init: tokens{user: "U", agent: "U"},
6570-
raw: tokens{user: "U", agent: "A", agentSource: tokenStore.TokenSourceAPI},
6569+
raw: tokens{user: "U", agent: "A", agentSource: token.TokenSourceAPI},
65716570
effective: tokens{user: "U", agent: "A"},
65726571
},
65736572
{
@@ -6576,7 +6575,7 @@ func TestAgent_Token(t *testing.T) {
65766575
url: "acl_agent_master_token",
65776576
body: body("M"),
65786577
code: http.StatusOK,
6579-
raw: tokens{agentRecovery: "M", agentRecoverySource: tokenStore.TokenSourceAPI},
6578+
raw: tokens{agentRecovery: "M", agentRecoverySource: token.TokenSourceAPI},
65806579
effective: tokens{agentRecovery: "M"},
65816580
},
65826581
{
@@ -6585,7 +6584,7 @@ func TestAgent_Token(t *testing.T) {
65856584
url: "agent_master",
65866585
body: body("M"),
65876586
code: http.StatusOK,
6588-
raw: tokens{agentRecovery: "M", agentRecoverySource: tokenStore.TokenSourceAPI},
6587+
raw: tokens{agentRecovery: "M", agentRecoverySource: token.TokenSourceAPI},
65896588
effective: tokens{agentRecovery: "M"},
65906589
},
65916590
{
@@ -6594,16 +6593,16 @@ func TestAgent_Token(t *testing.T) {
65946593
url: "agent_recovery",
65956594
body: body("R"),
65966595
code: http.StatusOK,
6597-
raw: tokens{agentRecovery: "R", agentRecoverySource: tokenStore.TokenSourceAPI},
6598-
effective: tokens{agentRecovery: "R", agentRecoverySource: tokenStore.TokenSourceAPI},
6596+
raw: tokens{agentRecovery: "R", agentRecoverySource: token.TokenSourceAPI},
6597+
effective: tokens{agentRecovery: "R", agentRecoverySource: token.TokenSourceAPI},
65996598
},
66006599
{
66016600
name: "set repl legacy",
66026601
method: "PUT",
66036602
url: "acl_replication_token",
66046603
body: body("R"),
66056604
code: http.StatusOK,
6606-
raw: tokens{repl: "R", replSource: tokenStore.TokenSourceAPI},
6605+
raw: tokens{repl: "R", replSource: token.TokenSourceAPI},
66076606
effective: tokens{repl: "R"},
66086607
},
66096608
{
@@ -6612,7 +6611,7 @@ func TestAgent_Token(t *testing.T) {
66126611
url: "replication",
66136612
body: body("R"),
66146613
code: http.StatusOK,
6615-
raw: tokens{repl: "R", replSource: tokenStore.TokenSourceAPI},
6614+
raw: tokens{repl: "R", replSource: token.TokenSourceAPI},
66166615
effective: tokens{repl: "R"},
66176616
},
66186617
{
@@ -6621,7 +6620,7 @@ func TestAgent_Token(t *testing.T) {
66216620
url: "config_file_service_registration",
66226621
body: body("G"),
66236622
code: http.StatusOK,
6624-
raw: tokens{registration: "G", registrationSource: tokenStore.TokenSourceAPI},
6623+
raw: tokens{registration: "G", registrationSource: token.TokenSourceAPI},
66256624
effective: tokens{registration: "G"},
66266625
},
66276626
{
@@ -6631,7 +6630,7 @@ func TestAgent_Token(t *testing.T) {
66316630
body: body(""),
66326631
code: http.StatusOK,
66336632
init: tokens{user: "U"},
6634-
raw: tokens{userSource: tokenStore.TokenSourceAPI},
6633+
raw: tokens{userSource: token.TokenSourceAPI},
66356634
},
66366635
{
66376636
name: "clear default",
@@ -6640,7 +6639,7 @@ func TestAgent_Token(t *testing.T) {
66406639
body: body(""),
66416640
code: http.StatusOK,
66426641
init: tokens{user: "U"},
6643-
raw: tokens{userSource: tokenStore.TokenSourceAPI},
6642+
raw: tokens{userSource: token.TokenSourceAPI},
66446643
},
66456644
{
66466645
name: "clear agent legacy",
@@ -6649,7 +6648,7 @@ func TestAgent_Token(t *testing.T) {
66496648
body: body(""),
66506649
code: http.StatusOK,
66516650
init: tokens{agent: "A"},
6652-
raw: tokens{agentSource: tokenStore.TokenSourceAPI},
6651+
raw: tokens{agentSource: token.TokenSourceAPI},
66536652
},
66546653
{
66556654
name: "clear agent",
@@ -6658,7 +6657,7 @@ func TestAgent_Token(t *testing.T) {
66586657
body: body(""),
66596658
code: http.StatusOK,
66606659
init: tokens{agent: "A"},
6661-
raw: tokens{agentSource: tokenStore.TokenSourceAPI},
6660+
raw: tokens{agentSource: token.TokenSourceAPI},
66626661
},
66636662
{
66646663
name: "clear master legacy",
@@ -6667,7 +6666,7 @@ func TestAgent_Token(t *testing.T) {
66676666
body: body(""),
66686667
code: http.StatusOK,
66696668
init: tokens{agentRecovery: "M"},
6670-
raw: tokens{agentRecoverySource: tokenStore.TokenSourceAPI},
6669+
raw: tokens{agentRecoverySource: token.TokenSourceAPI},
66716670
},
66726671
{
66736672
name: "clear master",
@@ -6676,7 +6675,7 @@ func TestAgent_Token(t *testing.T) {
66766675
body: body(""),
66776676
code: http.StatusOK,
66786677
init: tokens{agentRecovery: "M"},
6679-
raw: tokens{agentRecoverySource: tokenStore.TokenSourceAPI},
6678+
raw: tokens{agentRecoverySource: token.TokenSourceAPI},
66806679
},
66816680
{
66826681
name: "clear recovery",
@@ -6685,7 +6684,7 @@ func TestAgent_Token(t *testing.T) {
66856684
body: body(""),
66866685
code: http.StatusOK,
66876686
init: tokens{agentRecovery: "R"},
6688-
raw: tokens{agentRecoverySource: tokenStore.TokenSourceAPI},
6687+
raw: tokens{agentRecoverySource: token.TokenSourceAPI},
66896688
},
66906689
{
66916690
name: "clear repl legacy",
@@ -6694,7 +6693,7 @@ func TestAgent_Token(t *testing.T) {
66946693
body: body(""),
66956694
code: http.StatusOK,
66966695
init: tokens{repl: "R"},
6697-
raw: tokens{replSource: tokenStore.TokenSourceAPI},
6696+
raw: tokens{replSource: token.TokenSourceAPI},
66986697
},
66996698
{
67006699
name: "clear repl",
@@ -6703,7 +6702,7 @@ func TestAgent_Token(t *testing.T) {
67036702
body: body(""),
67046703
code: http.StatusOK,
67056704
init: tokens{repl: "R"},
6706-
raw: tokens{replSource: tokenStore.TokenSourceAPI},
6705+
raw: tokens{replSource: token.TokenSourceAPI},
67076706
},
67086707
{
67096708
name: "clear registration",
@@ -6712,7 +6711,7 @@ func TestAgent_Token(t *testing.T) {
67126711
body: body(""),
67136712
code: http.StatusOK,
67146713
init: tokens{registration: "G"},
6715-
raw: tokens{registrationSource: tokenStore.TokenSourceAPI},
6714+
raw: tokens{registrationSource: token.TokenSourceAPI},
67166715
},
67176716
}
67186717
for _, tt := range tests {

agent/auto-config/auto_config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ func TestFallback(t *testing.T) {
10911091
// auto-config response which is how the Fallback for auto-config works
10921092
testAC.mcfg.tokens.On("UpdateAgentToken", testAC.originalToken, token.TokenSourceConfig).Return(true).Once()
10931093

1094-
testAC.mcfg.expectInitialTLS(t, "autoconf", "dc1", testAC.originalToken, secondCA, secondRoots, thirdCert, testAC.extraCerts)
1094+
testAC.mcfg.expectInitialTLS("autoconf", "dc1", testAC.originalToken, secondCA, secondRoots, thirdCert, testAC.extraCerts)
10951095

10961096
// after the second RPC we now will use the new certs validity period in the next run loop iteration
10971097
testAC.mcfg.tlsCfg.On("AutoEncryptCert").Return(&x509.Certificate{

agent/auto-config/auto_encrypt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ func TestAutoEncrypt_Fallback(t *testing.T) {
569569
&expectedRequest,
570570
&structs.SignedResponse{}).Return(nil).Run(populateResponse).Once()
571571

572-
testAC.mcfg.expectInitialTLS(t, "autoconf", "dc1", testAC.originalToken, secondCA, &secondRoots, thirdCert, testAC.extraCerts)
572+
testAC.mcfg.expectInitialTLS("autoconf", "dc1", testAC.originalToken, secondCA, &secondRoots, thirdCert, testAC.extraCerts)
573573

574574
// after the second RPC we now will use the new certs validity period in the next run loop iteration
575575
testAC.mcfg.tlsCfg.On("AutoEncryptCert").Return(&x509.Certificate{

agent/auto-config/config_ce.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ package autoconf
99
type EnterpriseConfig struct{}
1010

1111
// finalize is a noop for CE
12-
func (_ *EnterpriseConfig) validateAndFinalize() error {
12+
func (*EnterpriseConfig) validateAndFinalize() error {
1313
return nil
1414
}

agent/auto-config/mock_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func newMockedConfig(t *testing.T) *mockedConfig {
360360
}
361361
}
362362

363-
func (m *mockedConfig) expectInitialTLS(t *testing.T, agentName, datacenter, token string, ca *structs.CARoot, indexedRoots *structs.IndexedCARoots, cert *structs.IssuedCert, extraCerts []string) {
363+
func (m *mockedConfig) expectInitialTLS(agentName, datacenter, token string, ca *structs.CARoot, indexedRoots *structs.IndexedCARoots, cert *structs.IssuedCert, extraCerts []string) {
364364
var pems []string
365365
for _, root := range indexedRoots.Roots {
366366
pems = append(pems, root.RootCert)
@@ -430,6 +430,6 @@ func (m *mockedConfig) setupInitialTLS(t *testing.T, agentName, datacenter, toke
430430
ca2 := connect.TestCA(t, nil)
431431
extraCerts := []string{ca2.RootCert}
432432

433-
m.expectInitialTLS(t, agentName, datacenter, token, ca, indexedRoots, cert, extraCerts)
433+
m.expectInitialTLS(agentName, datacenter, token, ca, indexedRoots, cert, extraCerts)
434434
return indexedRoots, cert, extraCerts
435435
}

agent/cache-types/catalog_list_services.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ func (c *CatalogListServices) Fetch(opts cache.FetchOptions, req cache.Request)
3535
reqReal = &dup
3636

3737
// Set the minimum query index to our current index so we block
38-
reqReal.QueryOptions.MinQueryIndex = opts.MinIndex
39-
reqReal.QueryOptions.MaxQueryTime = opts.Timeout
38+
reqReal.MinQueryIndex = opts.MinIndex
39+
reqReal.MaxQueryTime = opts.Timeout
4040

4141
// Always allow stale - there's no point in hitting leader if the request is
4242
// going to be served from cache and end up arbitrarily stale anyway. This
4343
// allows cached service-discover to automatically read scale across all
4444
// servers too.
45-
reqReal.QueryOptions.AllowStale = true
45+
reqReal.AllowStale = true
4646

4747
if opts.LastResult != nil {
48-
reqReal.QueryOptions.AllowNotModifiedResponse = true
48+
reqReal.AllowNotModifiedResponse = true
4949
}
5050

5151
var reply structs.IndexedServices
@@ -54,7 +54,7 @@ func (c *CatalogListServices) Fetch(opts cache.FetchOptions, req cache.Request)
5454
}
5555

5656
result.Value = &reply
57-
result.Index = reply.QueryMeta.Index
58-
result.NotModified = reply.QueryMeta.NotModified
57+
result.Index = reply.Index
58+
result.NotModified = reply.NotModified
5959
return result, nil
6060
}

agent/cache-types/catalog_list_services_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ func TestCatalogListServices(t *testing.T) {
2525
rpc.On("RPC", mock.Anything, "Catalog.ListServices", mock.Anything, mock.Anything).Return(nil).
2626
Run(func(args mock.Arguments) {
2727
req := args.Get(2).(*structs.DCSpecificRequest)
28-
require.Equal(t, uint64(24), req.QueryOptions.MinQueryIndex)
29-
require.Equal(t, 1*time.Second, req.QueryOptions.MaxQueryTime)
28+
require.Equal(t, uint64(24), req.MinQueryIndex)
29+
require.Equal(t, 1*time.Second, req.MaxQueryTime)
3030
require.True(t, req.AllowStale)
3131

3232
reply := args.Get(3).(*structs.IndexedServices)
3333
reply.Services = map[string][]string{
3434
"foo": {"prod", "linux"},
3535
"bar": {"qa", "windows"},
3636
}
37-
reply.QueryMeta.Index = 48
37+
reply.Index = 48
3838
resp = reply
3939
})
4040

@@ -86,7 +86,7 @@ func TestCatalogListServices_IntegrationWithCache_NotModifiedResponse(t *testing
8686
require.True(t, req.AllowNotModifiedResponse)
8787

8888
reply := args.Get(3).(*structs.IndexedServices)
89-
reply.QueryMeta.Index = 44
89+
reply.Index = 44
9090
reply.NotModified = true
9191
})
9292

agent/cache-types/catalog_service_list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func (c *CatalogServiceList) Fetch(opts cache.FetchOptions, req cache.Request) (
3535
reqReal = &dup
3636

3737
// Set the minimum query index to our current index so we block
38-
reqReal.QueryOptions.MinQueryIndex = opts.MinIndex
39-
reqReal.QueryOptions.MaxQueryTime = opts.Timeout
38+
reqReal.MinQueryIndex = opts.MinIndex
39+
reqReal.MaxQueryTime = opts.Timeout
4040

4141
// Always allow stale - there's no point in hitting leader if the request is
4242
// going to be served from cache and end up arbitrarily stale anyway. This
@@ -51,6 +51,6 @@ func (c *CatalogServiceList) Fetch(opts cache.FetchOptions, req cache.Request) (
5151
}
5252

5353
result.Value = &reply
54-
result.Index = reply.QueryMeta.Index
54+
result.Index = reply.Index
5555
return result, nil
5656
}

agent/cache-types/catalog_service_list_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func TestCatalogServiceList(t *testing.T) {
2424
rpc.On("RPC", mock.Anything, "Catalog.ServiceList", mock.Anything, mock.Anything).Return(nil).
2525
Run(func(args mock.Arguments) {
2626
req := args.Get(2).(*structs.DCSpecificRequest)
27-
require.Equal(t, uint64(24), req.QueryOptions.MinQueryIndex)
28-
require.Equal(t, 1*time.Second, req.QueryOptions.MaxQueryTime)
27+
require.Equal(t, uint64(24), req.MinQueryIndex)
28+
require.Equal(t, 1*time.Second, req.MaxQueryTime)
2929
require.True(t, req.AllowStale)
3030

3131
reply := args.Get(3).(*structs.IndexedServiceList)
@@ -37,7 +37,7 @@ func TestCatalogServiceList(t *testing.T) {
3737
Name: "bar",
3838
},
3939
}
40-
reply.QueryMeta.Index = 48
40+
reply.Index = 48
4141
resp = reply
4242
})
4343

0 commit comments

Comments
 (0)