From d345cd8d30dcd4ba74d9cb2fb9b1dac7530f8663 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 5 Jun 2020 18:08:30 -0400 Subject: [PATCH] ci: Add ineffsign linter And fix an additional ineffective assignment that was not caught by staticcheck --- .golangci.yml | 1 + agent/agent.go | 21 ++++++++++----------- agent/consul/acl_endpoint_test.go | 1 + lib/decode/decode_test.go | 4 ++++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 8c4bdbedac..306fdc4c4b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,7 @@ linters: - govet - unconvert - staticcheck + - ineffassign issues: # Disable the default exclude list so that all excludes are explicitly diff --git a/agent/agent.go b/agent/agent.go index ce69d8da5c..233e0285ac 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -706,18 +706,17 @@ func (a *Agent) setupClientAutoEncryptWatching(rootsReq *structs.DCSpecificReque // in time. The agent would be stuck in that case because the watches // never use the AutoEncrypt.Sign endpoint. go func() { + // Check 10sec after cert expires. The agent cache + // should be handling the expiration and renew before + // it. + // If there is no cert, AutoEncryptCertNotAfter returns + // a value in the past which immediately triggers the + // renew, but this case shouldn't happen because at + // this point, auto_encrypt was just being setup + // successfully. + interval := a.tlsConfigurator.AutoEncryptCertNotAfter().Sub(time.Now().Add(10 * time.Second)) + autoLogger := a.logger.Named(logging.AutoEncrypt) for { - - // Check 10sec after cert expires. The agent cache - // should be handling the expiration and renew before - // it. - // If there is no cert, AutoEncryptCertNotAfter returns - // a value in the past which immediately triggers the - // renew, but this case shouldn't happen because at - // this point, auto_encrypt was just being setup - // successfully. - autoLogger := a.logger.Named(logging.AutoEncrypt) - interval := a.tlsConfigurator.AutoEncryptCertNotAfter().Sub(time.Now().Add(10 * time.Second)) a.logger.Debug("setting up client certificate expiration check on interval", "interval", interval) select { case <-a.shutdownCh: diff --git a/agent/consul/acl_endpoint_test.go b/agent/consul/acl_endpoint_test.go index 1ae7a9090f..f2176f4b5c 100644 --- a/agent/consul/acl_endpoint_test.go +++ b/agent/consul/acl_endpoint_test.go @@ -4400,6 +4400,7 @@ func TestACLEndpoint_Login(t *testing.T) { structs.BindingRuleBindTypeNode, "${serviceaccount.name}", ) + require.NoError(t, err) t.Run("do not provide a token", func(t *testing.T) { req := structs.ACLLoginRequest{ diff --git a/lib/decode/decode_test.go b/lib/decode/decode_test.go index 1f2b5d3529..8c1e6da5c5 100644 --- a/lib/decode/decode_test.go +++ b/lib/decode/decode_test.go @@ -282,6 +282,9 @@ func decodeHCLToMapStructure(source string, target interface{}) error { Metadata: md, Result: target, }) + if err != nil { + return err + } return decoder.Decode(&raw) } @@ -305,6 +308,7 @@ func TestHookWeakDecodeFromSlice_DoesNotModifySliceTargetsFromSliceInterface(t * }) require.NoError(t, err) err = decoder.Decode(&raw) + require.NoError(t, err) expected := &nested{ Slice: []Item{{Name: "first"}},