Skip to content

Commit 5e585d4

Browse files
committed
[chore](internal): fix gofumpt issues part 2
#### Description fix gofumpt issues in internal/instrumentation --- This commit was automatically created by review-helper. Changes are split into focused commits grouped by directory to simplify the review process. Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent ebb6ab9 commit 5e585d4

29 files changed

+132
-126
lines changed

internal/components/extensions/jaeger_query_extension.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ const (
2020
port = 16686
2121
)
2222

23-
var (
24-
_ components.Parser = &components.GenericParser[*JaegerQueryExtensionConfig]{}
25-
)
23+
var _ components.Parser = &components.GenericParser[*JaegerQueryExtensionConfig]{}
2624

2725
type JaegerQueryExtensionConfig struct {
2826
HTTP jaegerHTTPAddress `mapstructure:"http,omitempty" yaml:"http,omitempty"`

internal/components/generic_parser.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import (
1212
rbacv1 "k8s.io/api/rbac/v1"
1313
)
1414

15-
var (
16-
_ Parser = &GenericParser[SingleEndpointConfig]{}
17-
)
15+
var _ Parser = &GenericParser[SingleEndpointConfig]{}
1816

1917
// GenericParser serves as scaffolding for custom parsing logic by isolating
2018
// functionality to idempotent functions.

internal/components/single_endpoint.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ import (
1616

1717
const DefaultRecAddress = "0.0.0.0"
1818

19-
var (
20-
_ Parser = &GenericParser[*SingleEndpointConfig]{}
21-
)
19+
var _ Parser = &GenericParser[*SingleEndpointConfig]{}
2220

2321
// SingleEndpointConfig represents the minimal struct for a given YAML configuration input containing either
2422
// endpoint or listen_address.

internal/controllers/builder_test.go

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,23 @@ var (
4444
pathTypePrefix = networkingv1.PathTypePrefix
4545
)
4646

47-
var (
48-
opampbridgeSelectorLabels = map[string]string{
49-
"app.kubernetes.io/managed-by": "opentelemetry-operator",
50-
"app.kubernetes.io/part-of": "opentelemetry",
51-
"app.kubernetes.io/component": "opentelemetry-opamp-bridge",
52-
"app.kubernetes.io/instance": "test.test",
53-
}
54-
)
47+
var opampbridgeSelectorLabels = map[string]string{
48+
"app.kubernetes.io/managed-by": "opentelemetry-operator",
49+
"app.kubernetes.io/part-of": "opentelemetry",
50+
"app.kubernetes.io/component": "opentelemetry-opamp-bridge",
51+
"app.kubernetes.io/instance": "test.test",
52+
}
5553

56-
var (
57-
taSelectorLabels = map[string]string{
58-
"app.kubernetes.io/managed-by": "opentelemetry-operator",
59-
"app.kubernetes.io/part-of": "opentelemetry",
60-
"app.kubernetes.io/component": "opentelemetry-targetallocator",
61-
"app.kubernetes.io/instance": "test.test",
62-
"app.kubernetes.io/name": "test-targetallocator",
63-
}
64-
)
54+
var taSelectorLabels = map[string]string{
55+
"app.kubernetes.io/managed-by": "opentelemetry-operator",
56+
"app.kubernetes.io/part-of": "opentelemetry",
57+
"app.kubernetes.io/component": "opentelemetry-targetallocator",
58+
"app.kubernetes.io/instance": "test.test",
59+
"app.kubernetes.io/name": "test-targetallocator",
60+
}
6561

6662
func TestBuildCollector(t *testing.T) {
67-
var goodConfigYaml = `receivers:
63+
goodConfigYaml := `receivers:
6864
examplereceiver:
6965
endpoint: "0.0.0.0:12345"
7066
exporters:
@@ -1054,7 +1050,6 @@ func TestBuildAll_OpAMPBridge(t *testing.T) {
10541050
wantErr bool
10551051
}{
10561052
{
1057-
10581053
name: "base case",
10591054
args: args{
10601055
instance: v1alpha1.OpAMPBridge{
@@ -1219,7 +1214,8 @@ componentsAllowed:
12191214
receivers:
12201215
- otlp
12211216
endpoint: ws://opamp-server:4320/v1/opamp
1222-
`},
1217+
`,
1218+
},
12231219
},
12241220
&corev1.ServiceAccount{
12251221
ObjectMeta: metav1.ObjectMeta{
@@ -1291,7 +1287,7 @@ endpoint: ws://opamp-server:4320/v1/opamp
12911287
}
12921288

12931289
func TestBuildCollectorTargetAllocatorCR(t *testing.T) {
1294-
var goodConfigYaml = `
1290+
goodConfigYaml := `
12951291
receivers:
12961292
prometheus:
12971293
config:

internal/controllers/clusterobservability_controller.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ func (r *ClusterObservabilityReconciler) reconcileOpenTelemetryResource(ctx cont
242242

243243
return r.Update(ctx, latest)
244244
})
245-
246245
if err != nil {
247246
return fmt.Errorf("failed to update OpenTelemetryCollector %s: %w", key, err)
248247
}
@@ -272,7 +271,6 @@ func (r *ClusterObservabilityReconciler) reconcileOpenTelemetryResource(ctx cont
272271

273272
return r.Update(ctx, latest)
274273
})
275-
276274
if err != nil {
277275
return fmt.Errorf("failed to update Instrumentation %s: %w", key, err)
278276
}

internal/controllers/opampbridge_controller_test.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,20 @@ import (
3232
"github.com/open-telemetry/opentelemetry-operator/internal/controllers"
3333
)
3434

35-
var opampBridgeLogger = logf.Log.WithName("opamp-bridge-controller-unit-tests")
36-
var opampBridgeMockAutoDetector = &mockAutoDetect{
37-
OpenShiftRoutesAvailabilityFunc: func() (openshift.RoutesAvailability, error) {
38-
return openshift.RoutesAvailable, nil
39-
},
40-
PrometheusCRsAvailabilityFunc: func() (prometheus.Availability, error) {
41-
return prometheus.Available, nil
42-
},
43-
RBACPermissionsFunc: func(context.Context) (rbac.Availability, error) {
44-
return rbac.Available, nil
45-
},
46-
}
35+
var (
36+
opampBridgeLogger = logf.Log.WithName("opamp-bridge-controller-unit-tests")
37+
opampBridgeMockAutoDetector = &mockAutoDetect{
38+
OpenShiftRoutesAvailabilityFunc: func() (openshift.RoutesAvailability, error) {
39+
return openshift.RoutesAvailable, nil
40+
},
41+
PrometheusCRsAvailabilityFunc: func() (prometheus.Availability, error) {
42+
return prometheus.Available, nil
43+
},
44+
RBACPermissionsFunc: func(context.Context) (rbac.Availability, error) {
45+
return rbac.Available, nil
46+
},
47+
}
48+
)
4749

4850
func TestNewObjectsOnReconciliation_OpAMPBridge(t *testing.T) {
4951
// prepare

internal/controllers/opentelemetrycollector_controller.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ import (
4848

4949
const resourceOwnerKey = ".metadata.owner"
5050

51-
var (
52-
ownedClusterObjectTypes = []client.Object{
53-
&rbacv1.ClusterRole{},
54-
&rbacv1.ClusterRoleBinding{},
55-
}
56-
)
51+
var ownedClusterObjectTypes = []client.Object{
52+
&rbacv1.ClusterRole{},
53+
&rbacv1.ClusterRoleBinding{},
54+
}
5755

5856
// OpenTelemetryCollectorReconciler reconciles a OpenTelemetryCollector object.
5957
type OpenTelemetryCollectorReconciler struct {

internal/controllers/reconcile_test.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,14 @@ const (
6262
annotationVal = "true"
6363
)
6464

65-
var (
66-
extraPorts = v1beta1.PortsSpec{
67-
ServicePort: v1.ServicePort{
68-
Name: "port-web",
69-
Protocol: "TCP",
70-
Port: 8080,
71-
TargetPort: intstr.FromInt32(8080),
72-
},
73-
}
74-
)
65+
var extraPorts = v1beta1.PortsSpec{
66+
ServicePort: v1.ServicePort{
67+
Name: "port-web",
68+
Protocol: "TCP",
69+
Port: 8080,
70+
TargetPort: intstr.FromInt32(8080),
71+
},
72+
}
7573

7674
type check[T any] func(t *testing.T, params T)
7775

@@ -1481,7 +1479,7 @@ func TestUpgrade(t *testing.T) {
14811479
}
14821480
}
14831481

1484-
func namespacedObjectName(name string, namespace string) types.NamespacedName {
1482+
func namespacedObjectName(name, namespace string) types.NamespacedName {
14851483
return types.NamespacedName{
14861484
Namespace: namespace,
14871485
Name: name,

internal/controllers/suite_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ func testCollectorWithModeAndReplicas(t *testing.T, name string, mode v1beta1.Mo
318318
IntVal: 80,
319319
},
320320
NodePort: 0,
321-
}}},
321+
},
322+
}},
322323
Replicas: &replicas,
323324
},
324325
Config: otelConfig,
@@ -327,7 +328,7 @@ func testCollectorWithModeAndReplicas(t *testing.T, name string, mode v1beta1.Mo
327328
}
328329
}
329330

330-
func testCollectorAssertNoErr(t *testing.T, name string, taContainerImage string, file string) v1beta1.OpenTelemetryCollector {
331+
func testCollectorAssertNoErr(t *testing.T, name, taContainerImage, file string) v1beta1.OpenTelemetryCollector {
331332
p, err := testCollectorWithConfigFile(name, taContainerImage, file)
332333
assert.NoError(t, err)
333334
if len(taContainerImage) == 0 {
@@ -336,7 +337,7 @@ func testCollectorAssertNoErr(t *testing.T, name string, taContainerImage string
336337
return p
337338
}
338339

339-
func testCollectorWithConfigFile(name string, taContainerImage string, file string) (v1beta1.OpenTelemetryCollector, error) {
340+
func testCollectorWithConfigFile(name, taContainerImage, file string) (v1beta1.OpenTelemetryCollector, error) {
340341
replicas := int32(1)
341342
var configYAML []byte
342343
var err error
@@ -375,7 +376,8 @@ func testCollectorWithConfigFile(name string, taContainerImage string, file stri
375376
IntVal: 80,
376377
},
377378
NodePort: 0,
378-
}}},
379+
},
380+
}},
379381
Replicas: &replicas,
380382
},
381383
Mode: v1beta1.ModeStatefulSet,
@@ -419,7 +421,8 @@ func testCollectorWithHPA(t *testing.T, minReps, maxReps int32) v1beta1.OpenTele
419421
IntVal: 80,
420422
},
421423
NodePort: 0,
422-
}}},
424+
},
425+
}},
423426
},
424427

425428
Config: otelConfig,
@@ -484,7 +487,8 @@ func testCollectorWithPDB(t *testing.T, minAvailable, maxUnavailable int32) v1be
484487
IntVal: 80,
485488
},
486489
NodePort: 0,
487-
}}},
490+
},
491+
}},
488492
PodDisruptionBudget: pdb,
489493
},
490494

internal/fips/fipscheck.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
type FIPSCheck interface {
1111
// DisabledComponents checks if a submitted components are denied or not.
12-
DisabledComponents(receivers map[string]any, exporters map[string]any, processors map[string]any, extensions map[string]any) []string
12+
DisabledComponents(receivers, exporters, processors, extensions map[string]any) []string
1313
}
1414

1515
// FipsCheck holds configuration for FIPS deny list.
@@ -38,7 +38,7 @@ func listToMap(list []string) map[string]bool {
3838
return m
3939
}
4040

41-
func (fips fipsCheck) DisabledComponents(receivers map[string]any, exporters map[string]any, processors map[string]any, extensions map[string]any) []string {
41+
func (fips fipsCheck) DisabledComponents(receivers, exporters, processors, extensions map[string]any) []string {
4242
var disabled []string
4343
if comp := isDisabled(fips.receivers, receivers); comp != "" {
4444
disabled = append(disabled, comp)

0 commit comments

Comments
 (0)