Skip to content

Commit

Permalink
Fix some lint errors
Browse files Browse the repository at this point in the history
(cherry picked from commit bd23b8d)
  • Loading branch information
swiatekm committed Dec 11, 2024
1 parent cc6c580 commit 6eff15a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
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 6eff15a

Please sign in to comment.