From 0200c08584d176520cd827a01644239301e92715 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:55:09 +0000 Subject: [PATCH 1/3] Update tool github.com/golangci/golangci-lint/cmd/golangci-lint to v1.62.2 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a0bb674bf5..0508ac4b0c 100644 --- a/Makefile +++ b/Makefile @@ -496,7 +496,7 @@ KUSTOMIZE_VERSION ?= v5.5.0 # renovate: datasource=go depName=sigs.k8s.io/controller-tools/cmd/controller-gen CONTROLLER_TOOLS_VERSION ?= v0.16.5 # renovate: datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.57.2 +GOLANGCI_LINT_VERSION ?= v1.62.2 # renovate: datasource=go depName=sigs.k8s.io/kind KIND_VERSION ?= v0.26.0 # renovate: datasource=go depName=github.com/kyverno/chainsaw From 2ab93f03cd4121aaa8a77a30104381c007390756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Mon, 11 Nov 2024 16:48:26 +0100 Subject: [PATCH 2/3] Fix some lint errors (cherry picked from commit bd23b8d039bffc1537afe219ef9c94af4520e150) --- cmd/operator-opamp-bridge/metrics/reporter.go | 2 +- cmd/operator-opamp-bridge/operator/client.go | 2 +- internal/components/component.go | 2 +- internal/components/exporters/helpers_test.go | 6 +++--- internal/components/extensions/helpers_test.go | 6 +++--- .../components/receivers/single_endpoint_receiver_test.go | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/operator-opamp-bridge/metrics/reporter.go b/cmd/operator-opamp-bridge/metrics/reporter.go index 5afc573056..131704a246 100644 --- a/cmd/operator-opamp-bridge/metrics/reporter.go +++ b/cmd/operator-opamp-bridge/metrics/reporter.go @@ -107,7 +107,7 @@ func NewMetricReporter(logger logr.Logger, dest *protobufs.TelemetryConnectionSe reporter.meter = provider.Meter("opamp") - reporter.process, err = process.NewProcess(int32(os.Getpid())) + reporter.process, err = process.NewProcess(int32(os.Getpid())) //nolint: gosec // this is guaranteed to not overflow if err != nil { return nil, fmt.Errorf("cannot query own process: %w", err) } diff --git a/cmd/operator-opamp-bridge/operator/client.go b/cmd/operator-opamp-bridge/operator/client.go index 1033e40cff..bba972b952 100644 --- a/cmd/operator-opamp-bridge/operator/client.go +++ b/cmd/operator-opamp-bridge/operator/client.go @@ -117,7 +117,7 @@ func (c Client) Apply(name string, namespace string, configmap *protobufs.AgentC } func (c Client) validateComponents(collectorConfig *v1beta1.Config) error { - if c.componentsAllowed == nil || len(c.componentsAllowed) == 0 { + if len(c.componentsAllowed) == 0 { return nil } diff --git a/internal/components/component.go b/internal/components/component.go index 5c8975b9c2..b2341177e8 100644 --- a/internal/components/component.go +++ b/internal/components/component.go @@ -89,7 +89,7 @@ func PortFromEndpoint(endpoint string) (int32, error) { return UnsetPort, PortNotFoundErr } - return int32(port), err + return int32(port), err //nolint: gosec // disable G115, this is guaranteed to not overflow due to the bitSize in the ParseInt call } type ParserRetriever func(string) Parser diff --git a/internal/components/exporters/helpers_test.go b/internal/components/exporters/helpers_test.go index 77fb67aced..0e74b2bba3 100644 --- a/internal/components/exporters/helpers_test.go +++ b/internal/components/exporters/helpers_test.go @@ -54,7 +54,7 @@ func TestExporterComponentParsers(t *testing.T) { for _, tt := range []struct { exporterName string parserName string - defaultPort int + defaultPort int32 }{ {"prometheus", "__prometheus", 8888}, } { @@ -88,7 +88,7 @@ func TestExporterComponentParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, tt.defaultPort, ports[0].Port) - assert.Equal(t, naming.PortName(tt.exporterName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.exporterName, tt.defaultPort), ports[0].Name) }) t.Run("allows port to be overridden", func(t *testing.T) { @@ -104,7 +104,7 @@ func TestExporterComponentParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, 65535, ports[0].Port) - assert.Equal(t, naming.PortName(tt.exporterName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.exporterName, tt.defaultPort), ports[0].Name) }) }) } diff --git a/internal/components/extensions/helpers_test.go b/internal/components/extensions/helpers_test.go index 826072aef9..b747e3a9ec 100644 --- a/internal/components/extensions/helpers_test.go +++ b/internal/components/extensions/helpers_test.go @@ -54,7 +54,7 @@ func TestExtensionsComponentParsers(t *testing.T) { for _, tt := range []struct { exporterName string parserName string - defaultPort int + defaultPort int32 }{ {"health_check", "__health_check", 13133}, } { @@ -88,7 +88,7 @@ func TestExtensionsComponentParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, tt.defaultPort, ports[0].Port) - assert.Equal(t, naming.PortName(tt.exporterName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.exporterName, tt.defaultPort), ports[0].Name) }) t.Run("allows port to be overridden", func(t *testing.T) { @@ -104,7 +104,7 @@ func TestExtensionsComponentParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, 65535, ports[0].Port) - assert.Equal(t, naming.PortName(tt.exporterName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.exporterName, tt.defaultPort), ports[0].Name) }) }) } diff --git a/internal/components/receivers/single_endpoint_receiver_test.go b/internal/components/receivers/single_endpoint_receiver_test.go index abb866a8d8..4811323c97 100644 --- a/internal/components/receivers/single_endpoint_receiver_test.go +++ b/internal/components/receivers/single_endpoint_receiver_test.go @@ -64,7 +64,7 @@ func TestDownstreamParsers(t *testing.T) { desc string receiverName string parserName string - defaultPort int + defaultPort int32 listenAddrParser bool }{ {"zipkin", "zipkin", "__zipkin", 9411, false}, @@ -118,7 +118,7 @@ func TestDownstreamParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, tt.defaultPort, ports[0].Port) - assert.Equal(t, naming.PortName(tt.receiverName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.receiverName, tt.defaultPort), ports[0].Name) }) t.Run("allows port to be overridden", func(t *testing.T) { @@ -142,7 +142,7 @@ func TestDownstreamParsers(t *testing.T) { assert.NoError(t, err) assert.Len(t, ports, 1) assert.EqualValues(t, 65535, ports[0].Port) - assert.Equal(t, naming.PortName(tt.receiverName, int32(tt.defaultPort)), ports[0].Name) + assert.Equal(t, naming.PortName(tt.receiverName, tt.defaultPort), ports[0].Name) }) t.Run("returns a default config", func(t *testing.T) { From 7dd722a5f45b292f84b50bfcbf7b5f59b88d4d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Mon, 30 Dec 2024 18:02:04 +0100 Subject: [PATCH 3/3] Fix remaining lint error --- apis/v1beta1/config.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apis/v1beta1/config.go b/apis/v1beta1/config.go index 7761433702..a7fd65835d 100644 --- a/apis/v1beta1/config.go +++ b/apis/v1beta1/config.go @@ -17,6 +17,7 @@ package v1beta1 import ( "bytes" "encoding/json" + "errors" "fmt" "reflect" "regexp" @@ -452,7 +453,7 @@ func (s *Service) MetricsEndpoint(logger logr.Logger) (string, int32, error) { errMsg := fmt.Sprintf("couldn't determine metrics port from configuration: %s", telemetry.Metrics.Address) logger.Info(errMsg) - return "", 0, fmt.Errorf(errMsg) + return "", 0, errors.New(errMsg) } // The regex below matches on strings that end with a colon followed by 1 or more numbers (representing the port).