diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7998730b9..4e23b0348 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -6,7 +6,7 @@ on: # yamllint disable-line rule:truthy env: DESIRED_GO_VERSION: '1.20' - DESIRED_GOLANGCI_LINT_VERSION: 'v1.56' + DESIRED_GOLANGCI_LINT_VERSION: 'v1.60' DESIRED_PYTHON_VERSION: '3.12' jobs: diff --git a/.sonarcloud.properties b/.sonarcloud.properties new file mode 100644 index 000000000..d08e0660a --- /dev/null +++ b/.sonarcloud.properties @@ -0,0 +1,4 @@ +sonar.python.version=3.8, 3.9, 3.11, 3.12 +sonar.sources=. +sonar.test.inclusions=**/*_test.go, receptorctl/tests/ +sonar.tests=. diff --git a/pkg/backends/null_test.go b/pkg/backends/null_test.go index 61f432004..1f32a9ccd 100644 --- a/pkg/backends/null_test.go +++ b/pkg/backends/null_test.go @@ -1,6 +1,12 @@ -package backends +package backends_test -import "testing" +import ( + "crypto/tls" + "reflect" + "testing" + + "github.com/ansible/receptor/pkg/backends" +) func TestNullBackendCfgGetAddr(t *testing.T) { type fields struct { @@ -21,7 +27,7 @@ func TestNullBackendCfgGetAddr(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - cfg := &NullBackendCfg{ + cfg := &backends.NullBackendCfg{ Local: tt.fields.Local, } if got := cfg.GetAddr(); got != tt.want { @@ -30,3 +36,32 @@ func TestNullBackendCfgGetAddr(t *testing.T) { }) } } + +func TestNullBackendCfgGetTLS(t *testing.T) { + type fields struct { + Local bool + } + tests := []struct { + name string + fields fields + want *tls.Config + }{ + { + name: "Positive", + fields: fields{ + Local: true, + }, + want: nil, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + cfg := &backends.NullBackendCfg{ + Local: tt.fields.Local, + } + if got := cfg.GetTLS(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("NullBackendCfg.GetTLS() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/pkg/backends/websockets_test.go b/pkg/backends/websockets_test.go index 9122e6c98..9c4b5efd7 100644 --- a/pkg/backends/websockets_test.go +++ b/pkg/backends/websockets_test.go @@ -24,6 +24,14 @@ import ( "github.com/golang/mock/gomock" ) +const ( + expectedWebsocketListenerError = "Expected Websocket Listener, got nil" + newWebsocketDialerError = "NewWebsockerDialer return error: %+v" + websocketListenerExpectedError = "Websocket listener expected, nil returned" + websocketsTestNewWebsocketDialer = "websockets_test.go>TestNewWebsocketDialer" + wssTestTesting = "wss://test.testing" +) + func setupTLSCfg(t *testing.T) tls.Certificate { // Create a server TLS certificate for "localhost" key, err := rsa.GenerateKey(rand.Reader, 2048) @@ -66,7 +74,7 @@ func TestNewWebsocketDialer(t *testing.T) { }{ { name: "NewWebsocketDialer wss Success ", - address: "wss://test.testing", + address: wssTestTesting, redial: false, tlscfg: &tls.Config{ Certificates: []tls.Certificate{setupTLSCfg(t)}, @@ -74,7 +82,7 @@ func TestNewWebsocketDialer(t *testing.T) { PreferServerCipherSuites: true, }, extraHeader: "", - logger: logger.NewReceptorLogger("websockets_test.go>TestNewWebsocketDialer"), + logger: logger.NewReceptorLogger(websocketsTestNewWebsocketDialer), expectedErr: "", failedTestString: "Expected no error, but got: %v", }, @@ -88,7 +96,7 @@ func TestNewWebsocketDialer(t *testing.T) { PreferServerCipherSuites: true, }, extraHeader: "", - logger: logger.NewReceptorLogger("websockets_test.go>TestNewWebsocketDialer"), + logger: logger.NewReceptorLogger(websocketsTestNewWebsocketDialer), expectedErr: "", failedTestString: "Expected no error, but got: %v", }, @@ -130,9 +138,9 @@ func TestWebsocketDialerStart(t *testing.T) { ctx := context.Background() defer ctx.Done() - wd, wdErr := backends.NewWebsocketDialer("wss://test.testing", &tls.Config{}, "", false, logger.NewReceptorLogger("websockets_test.go>TestNewWebsocketDialer"), mockWebsocketDialer) + wd, wdErr := backends.NewWebsocketDialer(wssTestTesting, &tls.Config{}, "", false, logger.NewReceptorLogger(websocketsTestNewWebsocketDialer), mockWebsocketDialer) if wdErr != nil { - t.Errorf("NewWebsockerDialer return error: %v", wdErr) + t.Errorf(newWebsocketDialerError, wdErr) } resp := &http.Response{ Body: io.NopCloser(bytes.NewBufferString("Hello World")), @@ -158,7 +166,7 @@ func TestWebsocketDialerStart(t *testing.T) { mockWebsocketConner.EXPECT().ReadMessage().Return(0, []byte{}, nil).AnyTimes() sess, err := wd.Start(ctx, &sync.WaitGroup{}) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } s := <-sess @@ -175,10 +183,10 @@ func TestWebsocketDialerStart(t *testing.T) { func TestWebsocketDialerGetAddr(t *testing.T) { _, mockWebsocketDialer := setUpDialer(t) - address := "wss://test.testing" - wd, wdErr := backends.NewWebsocketDialer(address, &tls.Config{}, "", false, logger.NewReceptorLogger("websockets_test.go>TestNewWebsocketDialer"), mockWebsocketDialer) + address := wssTestTesting + wd, wdErr := backends.NewWebsocketDialer(address, &tls.Config{}, "", false, logger.NewReceptorLogger(websocketsTestNewWebsocketDialer), mockWebsocketDialer) if wdErr != nil { - t.Errorf("NewWebsockerDialer return error: %v", wdErr) + t.Errorf(newWebsocketDialerError, wdErr) } add := wd.GetAddr() if add != address { @@ -190,9 +198,9 @@ func TestWebsocketDialerGetTLS(t *testing.T) { _, mockWebsocketDialer := setUpDialer(t) blankTLS := &tls.Config{} - wd, wdErr := backends.NewWebsocketDialer("wss://test.testing", blankTLS, "", false, logger.NewReceptorLogger("websockets_test.go>TestNewWebsocketDialer"), mockWebsocketDialer) + wd, wdErr := backends.NewWebsocketDialer(wssTestTesting, blankTLS, "", false, logger.NewReceptorLogger(websocketsTestNewWebsocketDialer), mockWebsocketDialer) if wdErr != nil { - t.Errorf("NewWebsockerDialer return error: %v", wdErr) + t.Errorf(newWebsocketDialerError, wdErr) } TLS := wd.GetTLS() if TLS != blankTLS { @@ -214,11 +222,11 @@ func TestNewWebsocketListener(t *testing.T) { wi, err := backends.NewWebsocketListener("address", &tls.Config{}, logger.NewReceptorLogger("test"), mockWebsocketUpgrader, mockServer) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if wi == nil { - t.Errorf("Websocket listener expected, nil returned") + t.Error(websocketListenerExpectedError) } } @@ -227,11 +235,11 @@ func TestWebsocketListenerSetandGetPath(t *testing.T) { wi, err := backends.NewWebsocketListener("address", &tls.Config{}, logger.NewReceptorLogger("test"), mockWebsocketUpgrader, mockServer) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if wi == nil { - t.Errorf("Websocket listener expected, nil returned") + t.Error(websocketListenerExpectedError) } pathName := "Test Path" @@ -251,10 +259,10 @@ func TestWebsocketListenerStart(t *testing.T) { wi, err := backends.NewWebsocketListener("localhost:21700", &tls.Config{}, logger.NewReceptorLogger("test"), mockWebsocketUpgrader, mockServer) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if wi == nil { - t.Errorf("Websocket listener expected, nil returned") + t.Error(websocketListenerExpectedError) } mockWebsocketUpgrader.EXPECT().Upgrade(gomock.Any(), gomock.Any(), gomock.Any()).Return(mockWebsocketConner, nil).AnyTimes() @@ -264,10 +272,10 @@ func TestWebsocketListenerStart(t *testing.T) { bs, err := wi.Start(ctx, &sync.WaitGroup{}) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if bs == nil { - t.Errorf("Expected Websocket Listener, got nil") + t.Error(expectedWebsocketListenerError) } } @@ -278,10 +286,10 @@ func TestWebsocketListenerStartUpgradeError(t *testing.T) { wi, err := backends.NewWebsocketListener("localhost:21701", &tls.Config{}, logger.NewReceptorLogger("test"), mockWebsocketUpgrader, mockServer) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if wi == nil { - t.Errorf("Websocket listener expected, nil returned") + t.Error(websocketListenerExpectedError) } returnError := errors.New("Upgrade Error") @@ -295,7 +303,7 @@ func TestWebsocketListenerStartUpgradeError(t *testing.T) { t.Errorf("Expected error %v, got %v instead", nil, err) } if bs == nil { - t.Errorf("Expected Websocket Listener, got nil") + t.Error(expectedWebsocketListenerError) } } @@ -309,17 +317,17 @@ func TestWebsocketListenerStartNetError(t *testing.T) { badAddress := "127.0.0.1:80" wi, err := backends.NewWebsocketListener(badAddress, &tls.Config{}, logger.NewReceptorLogger("test"), mockWebsocketUpgrader, mockServer) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if wi == nil { - t.Errorf("Websocket listener expected, nil returned") + t.Error(websocketListenerExpectedError) } mockWebsocketUpgrader.EXPECT().Upgrade(gomock.Any(), gomock.Any(), gomock.Any()).Return(mockWebsocketConner, nil).AnyTimes() bs, err := wi.Start(ctx, &sync.WaitGroup{}) if !strings.Contains(err.Error(), "listen tcp 127.0.0.1:80: bind: permission denied") { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if bs != nil { t.Errorf("Expected Websocket Listener to be nil") @@ -335,10 +343,10 @@ func TestWebsocketListenerStartTLSNil(t *testing.T) { wi, err := backends.NewWebsocketListener("localhost:21702", nil, logger.NewReceptorLogger("test"), mockWebsocketUpgrader, mockServer) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if wi == nil { - t.Errorf("Websocket listener expected, nil returned") + t.Error(websocketListenerExpectedError) } mockWebsocketUpgrader.EXPECT().Upgrade(gomock.Any(), gomock.Any(), gomock.Any()).Return(mockWebsocketConner, nil).AnyTimes() @@ -347,7 +355,7 @@ func TestWebsocketListenerStartTLSNil(t *testing.T) { bs, err := wi.Start(ctx, &sync.WaitGroup{}) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if bs == nil { t.Errorf("Expected Websocket Listener not be nil") @@ -364,10 +372,10 @@ func TestWebsocketListenerGetAddr(t *testing.T) { wi, err := backends.NewWebsocketListener(address, &tls.Config{}, logger.NewReceptorLogger("test"), mockWebsocketUpgrader, mockServer) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if wi == nil { - t.Errorf("Websocket listener expected, nil returned") + t.Error(websocketListenerExpectedError) } mockWebsocketUpgrader.EXPECT().Upgrade(gomock.Any(), gomock.Any(), gomock.Any()).Return(mockWebsocketConner, nil).AnyTimes() @@ -377,10 +385,10 @@ func TestWebsocketListenerGetAddr(t *testing.T) { bs, err := wi.Start(ctx, &sync.WaitGroup{}) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if bs == nil { - t.Errorf("Expected Websocket Listener, got nil") + t.Error(expectedWebsocketListenerError) } add := wi.GetAddr() @@ -395,10 +403,10 @@ func TestWebsocketListenerGetTLS(t *testing.T) { blankTLS := &tls.Config{} wi, err := backends.NewWebsocketListener("127.0.0.1:21704", blankTLS, logger.NewReceptorLogger("test"), mockWebsocketUpgrader, mockServer) if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } if wi == nil { - t.Errorf("Websocket listener expected, nil returned") + t.Error(websocketListenerExpectedError) } TLS := wi.GetTLS() @@ -442,6 +450,6 @@ func TestWebsocketListenerCfg(t *testing.T) { err := wlc.Prepare() if err != nil { - t.Errorf(err.Error()) + t.Errorf(err.Error()) //nolint:govet,staticcheck } } diff --git a/pkg/controlsvc/controlsvc.go b/pkg/controlsvc/controlsvc.go index 0c2015afd..f483cacde 100644 --- a/pkg/controlsvc/controlsvc.go +++ b/pkg/controlsvc/controlsvc.go @@ -516,7 +516,7 @@ func (cfg CmdlineConfigUnix) Run() error { } } err = MainInstance.RunControlSvc(context.Background(), cfg.Service, tlscfg, cfg.Filename, - os.FileMode(cfg.Permissions), cfg.TCPListen, tcptls) + os.FileMode(cfg.Permissions), cfg.TCPListen, tcptls) //nolint:gosec if err != nil { return err } diff --git a/pkg/framer/framer.go b/pkg/framer/framer.go index 7e15af92a..0224c037a 100644 --- a/pkg/framer/framer.go +++ b/pkg/framer/framer.go @@ -32,7 +32,7 @@ func New() Framer { // SendData takes a data buffer and returns a framed buffer. func (f *framer) SendData(data []byte) []byte { buf := make([]byte, len(data)+2) - binary.LittleEndian.PutUint16(buf[0:2], uint16(len(data))) + binary.LittleEndian.PutUint16(buf[0:2], uint16(len(data))) //nolint:gosec copy(buf[2:], data) return buf diff --git a/pkg/netceptor/netceptor.go b/pkg/netceptor/netceptor.go index 96f532f7e..01b372eaf 100644 --- a/pkg/netceptor/netceptor.go +++ b/pkg/netceptor/netceptor.go @@ -1025,7 +1025,7 @@ func ReceptorVerifyFunc(tlscfg *tls.Config, pinnedFingerprints [][]byte, expecte if err != nil { logger.Error("RVF failed to parse: %s", err) - return fmt.Errorf("failed to parse certificate from server: " + err.Error()) + return fmt.Errorf("failed to parse certificate from server: " + err.Error()) //nolint:govet } certs[i] = cert } @@ -1383,7 +1383,7 @@ func (s *Netceptor) printRoutingTable() { _, _ = fmt.Fprintf(sb, "%s(%.2f) ", peer, s.knownConnectionCosts[conn][peer]) } _, _ = fmt.Fprintf(sb, "\n") - s.Logger.Log(logLevel, sb.String()) + s.Logger.Log(logLevel, sb.String()) //nolint:govet } s.Logger.Log(logLevel, "Routing Table:\n") for node := range s.routingTable { @@ -1656,7 +1656,7 @@ func (s *Netceptor) handleMessageData(md *MessageData) error { if !ok || pc.context.Err() != nil { s.listenerLock.RUnlock() if md.FromNode == s.nodeID { - return fmt.Errorf(ProblemServiceUnknown) + return fmt.Errorf(ProblemServiceUnknown) //nolint:staticcheck } _ = s.sendUnreachable(md.FromNode, &UnreachableMessage{ FromNode: md.FromNode, diff --git a/pkg/netceptor/ping.go b/pkg/netceptor/ping.go index af4acf021..028eb3c8b 100644 --- a/pkg/netceptor/ping.go +++ b/pkg/netceptor/ping.go @@ -43,7 +43,7 @@ func SendPing(ctx context.Context, s NetcForPing, target string, hopsToLive byte go func() { for msg := range unrCh { errorChan <- errorResult{ - err: fmt.Errorf(msg.Problem), + err: fmt.Errorf(msg.Problem), //nolint:govet fromNode: msg.ReceivedFromNode, } } diff --git a/pkg/services/unix_proxy.go b/pkg/services/unix_proxy.go index de56b25e6..a3c463818 100644 --- a/pkg/services/unix_proxy.go +++ b/pkg/services/unix_proxy.go @@ -92,7 +92,7 @@ func (cfg UnixProxyInboundCfg) Run() error { return err } - return UnixProxyServiceInbound(netceptor.MainInstance, cfg.Filename, os.FileMode(cfg.Permissions), + return UnixProxyServiceInbound(netceptor.MainInstance, cfg.Filename, os.FileMode(cfg.Permissions), //nolint:gosec cfg.RemoteNode, cfg.RemoteService, tlscfg) } diff --git a/pkg/utils/error_kind_test.go b/pkg/utils/error_kind_test.go index b7da476bd..69b39e477 100644 --- a/pkg/utils/error_kind_test.go +++ b/pkg/utils/error_kind_test.go @@ -13,7 +13,7 @@ const ( goodErrorString string = "unit was already started" ) -var errUnitWasAlreadyStarted error = fmt.Errorf(goodErrorString) +var errUnitWasAlreadyStarted error = fmt.Errorf(goodErrorString) //nolint:staticcheck func TestErrorWithKind_Error(t *testing.T) { type fields struct { diff --git a/pkg/workceptor/command.go b/pkg/workceptor/command.go index a51fd9ba0..2ff793ce5 100644 --- a/pkg/workceptor/command.go +++ b/pkg/workceptor/command.go @@ -436,7 +436,7 @@ func filenameExists(filename string) error { func (cfg SigningKeyPrivateCfg) Prepare() error { duration, err := cfg.PrepareSigningKeyPrivateCfg() if err != nil { - return fmt.Errorf(err.Error()) + return fmt.Errorf(err.Error()) //nolint:govet,staticcheck } MainInstance.SigningExpiration = *duration diff --git a/pkg/workceptor/kubernetes.go b/pkg/workceptor/kubernetes.go index 67e4ae461..ce094303c 100644 --- a/pkg/workceptor/kubernetes.go +++ b/pkg/workceptor/kubernetes.go @@ -261,7 +261,7 @@ func (kw *KubeUnit) kubeLoggingConnectionHandler(timestamps bool, sinceTime time } if err != nil { errMsg := fmt.Sprintf("Error opening log stream for pod %s/%s. Error: %s", podNamespace, podName, err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) return nil, err @@ -329,7 +329,7 @@ func (kw *KubeUnit) kubeLoggingWithReconnect(streamWait *sync.WaitGroup, stdout } if err != nil { errMsg := fmt.Sprintf("Error getting pod %s/%s. Error: %s", podNamespace, podName, err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) // fail to get pod, no need to continue @@ -559,10 +559,10 @@ func (kw *KubeUnit) createPod(env map[string]string) error { stdout, err2 := NewStdoutWriter(FileSystem{}, kw.UnitDir()) if err2 != nil { errMsg := fmt.Sprintf("Error opening stdout file: %s", err2) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) - return fmt.Errorf(errMsg) + return fmt.Errorf(errMsg) //nolint:govet,staticcheck } var stdoutErr error var streamWait sync.WaitGroup @@ -611,7 +611,7 @@ func (kw *KubeUnit) runWorkUsingLogger() { if err := kw.createPod(nil); err != nil { if err != ErrPodCompleted { errMsg := fmt.Sprintf("Error creating pod: %s", err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) return @@ -628,7 +628,7 @@ func (kw *KubeUnit) runWorkUsingLogger() { errMsg := fmt.Sprintf("Error creating pod: pod namespace is empty for pod %s", podName, ) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) return @@ -641,7 +641,7 @@ func (kw *KubeUnit) runWorkUsingLogger() { select { case <-kw.GetContext().Done(): errMsg := fmt.Sprintf("Context Done while getting pod %s/%s. Error: %s", podNamespace, podName, kw.GetContext().Err()) - kw.GetWorkceptor().nc.GetLogger().Warning(errMsg) + kw.GetWorkceptor().nc.GetLogger().Warning(errMsg) //nolint:govet return default: @@ -662,7 +662,7 @@ func (kw *KubeUnit) runWorkUsingLogger() { } if err != nil { errMsg := fmt.Sprintf("Error getting pod %s/%s. Error: %s", podNamespace, podName, err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) return @@ -715,7 +715,7 @@ func (kw *KubeUnit) runWorkUsingLogger() { skipStdin = true } else { errMsg := fmt.Sprintf("Error opening stdin file: %s", err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) return @@ -740,7 +740,7 @@ func (kw *KubeUnit) runWorkUsingLogger() { stdout, err := NewStdoutWriter(FileSystem{}, kw.UnitDir()) if err != nil { errMsg := fmt.Sprintf("Error opening stdout file: %s", err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) return @@ -806,7 +806,7 @@ func (kw *KubeUnit) runWorkUsingLogger() { podName, err, ) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, stdout.Size()) close(stdinErrChan) // signal STDOUT goroutine to stop @@ -816,7 +816,7 @@ func (kw *KubeUnit) runWorkUsingLogger() { } else { // this is probably not possible... errMsg := fmt.Sprintf("Error reading stdin: %s", stdin.Error()) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.GetWorkceptor().nc.GetLogger().Error("Pod status at time of error %s", kw.pod.Status.String()) kw.UpdateBasicStatus(WorkStateFailed, errMsg, stdout.Size()) @@ -1008,7 +1008,7 @@ func (kw *KubeUnit) runWorkUsingTCP() { if err != nil { errMsg := fmt.Sprintf("Error listening: %s", err) kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet return } @@ -1032,7 +1032,7 @@ func (kw *KubeUnit) runWorkUsingTCP() { if err != nil { errMsg := fmt.Sprintf("Error accepting: %s", err) kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet cancel() return @@ -1045,7 +1045,7 @@ func (kw *KubeUnit) runWorkUsingTCP() { if err != nil { errMsg := fmt.Sprintf("Error creating pod: %s", err) kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet cancel() return @@ -1064,7 +1064,7 @@ func (kw *KubeUnit) runWorkUsingTCP() { stdin, err = NewStdinReader(FileSystem{}, kw.UnitDir()) if err != nil { errMsg := fmt.Sprintf("Error opening stdin file: %s", err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) cancel() @@ -1075,7 +1075,7 @@ func (kw *KubeUnit) runWorkUsingTCP() { stdout, err := NewStdoutWriter(FileSystem{}, kw.UnitDir()) if err != nil { errMsg := fmt.Sprintf("Error opening stdout file: %s", err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) cancel() @@ -1093,7 +1093,7 @@ func (kw *KubeUnit) runWorkUsingTCP() { _ = conn.CloseWrite() if err != nil { errMsg := fmt.Sprintf("Error sending stdin to pod: %s", err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) cancel() @@ -1125,7 +1125,7 @@ func (kw *KubeUnit) runWorkUsingTCP() { } if err != nil { errMsg := fmt.Sprintf("Error reading stdout from pod: %s", err) - kw.GetWorkceptor().nc.GetLogger().Error(errMsg) + kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0) cancel() diff --git a/pkg/workceptor/stdio_utils_test.go b/pkg/workceptor/stdio_utils_test.go index 2b6c73e17..a2e40cbc3 100644 --- a/pkg/workceptor/stdio_utils_test.go +++ b/pkg/workceptor/stdio_utils_test.go @@ -54,7 +54,7 @@ func setupReader(t *testing.T) (*gomock.Controller, *workceptor.STDinReader) { wc, err := workceptor.NewStdinReader(mockfilesystemer, "") if err != nil { - t.Errorf(stdinError) + t.Errorf(stdinError) //nolint:staticcheck } return ctrl, wc diff --git a/tests/functional/mesh/receptorcontrol.go b/tests/functional/mesh/receptorcontrol.go index 3ddc2ec51..b680ddcfb 100644 --- a/tests/functional/mesh/receptorcontrol.go +++ b/tests/functional/mesh/receptorcontrol.go @@ -161,7 +161,7 @@ func (r *ReceptorControl) ReadAndParseJSON() (map[string]interface{}, error) { } if str := string(data); strings.HasPrefix(str, "ERROR") { - return nil, fmt.Errorf(str) + return nil, fmt.Errorf(str) //nolint:govet,staticcheck } jsonData := make(map[string]interface{}) err = json.Unmarshal(data, &jsonData) @@ -213,7 +213,7 @@ func (r *ReceptorControl) getWorkSubmitResponse() (string, error) { msg, err := r.ReadStr() // flush getWorkSubmitResponse if !strings.Contains(msg, "Send stdin data and EOF.") { - return "", fmt.Errorf(msg) + return "", fmt.Errorf(msg) //nolint:govet,staticcheck } if err != nil {