Skip to content

Commit

Permalink
Update tool github.com/golangci/golangci-lint/cmd/golangci-lint to v1…
Browse files Browse the repository at this point in the history
….62.2 (#3538)

* Update tool github.com/golangci/golangci-lint/cmd/golangci-lint to v1.62.2

* Fix some lint errors

(cherry picked from commit bd23b8d)

* Fix remaining lint error

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Mikołaj Świątek <[email protected]>
  • Loading branch information
renovate[bot] and swiatekm authored Dec 30, 2024
1 parent 8061478 commit ea0da98
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion apis/v1beta1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package v1beta1
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"reflect"
"regexp"
Expand Down Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion cmd/operator-opamp-bridge/metrics/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/operator-opamp-bridge/operator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion internal/components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions internal/components/exporters/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestExporterComponentParsers(t *testing.T) {
for _, tt := range []struct {
exporterName string
parserName string
defaultPort int
defaultPort int32
}{
{"prometheus", "__prometheus", 8888},
} {
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
})
})
}
Expand Down
6 changes: 3 additions & 3 deletions internal/components/extensions/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
} {
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
})
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit ea0da98

Please sign in to comment.