Skip to content

Commit ba941c9

Browse files
committed
[chore](apis): fix gofumpt issues part 1
#### Description fix gofumpt issues in apis/v1beta1 --- 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 ba941c9

File tree

9 files changed

+45
-48
lines changed

9 files changed

+45
-48
lines changed

apis/v1alpha1/instrumentation_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,7 @@ type Nginx struct {
371371
}
372372

373373
// InstrumentationStatus defines status of the instrumentation.
374-
type InstrumentationStatus struct {
375-
}
374+
type InstrumentationStatus struct{}
376375

377376
// +kubebuilder:object:root=true
378377
// +kubebuilder:resource:shortName=otelinst;otelinsts

apis/v1alpha1/instrumentation_webhook.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ func (InstrumentationWebhook) validate(r *Instrumentation) (admission.Warnings,
218218
// Example: `endpoint=http://localhost:14250,pollingIntervalMs=5000,initialSamplingRate=0.25`
219219
if r.Spec.Argument != "" {
220220
err := validateJaegerRemoteSamplerArgument(r.Spec.Argument)
221-
222221
if err != nil {
223222
return warnings, fmt.Errorf("spec.sampler.argument is not a valid argument for sampler %s: %w", r.Spec.Type, err)
224223
}

apis/v1alpha1/instrumentation_webhook_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ func TestInstrumentationValidatingWebhook(t *testing.T) {
621621
})
622622
}
623623
}
624+
624625
func TestInstrumentationValidatingWebhook_DeprecationWarnings(t *testing.T) {
625626
defaultSize := resource.MustParse("200Mi")
626627

apis/v1beta1/collector_webhook_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ import (
3737
"github.com/open-telemetry/opentelemetry-operator/internal/rbac"
3838
)
3939

40-
var (
41-
testScheme = scheme.Scheme
42-
)
40+
var testScheme = scheme.Scheme
4341

4442
func TestValidate(t *testing.T) {
4543
tests := []struct {

apis/v1beta1/config.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ func (c *AnyConfig) DeepCopy() *AnyConfig {
7070
return out
7171
}
7272

73-
var _ json.Marshaler = &AnyConfig{}
74-
var _ json.Unmarshaler = &AnyConfig{}
73+
var (
74+
_ json.Marshaler = &AnyConfig{}
75+
_ json.Unmarshaler = &AnyConfig{}
76+
)
7577

7678
// UnmarshalJSON implements an alternative parser for this field.
7779
func (c *AnyConfig) UnmarshalJSON(b []byte) error {
@@ -234,7 +236,7 @@ func (c *Config) getPortsForComponentKinds(logger logr.Logger, componentKinds ..
234236

235237
// getEnvironmentVariablesForComponentKinds gets the environment variables for the given ComponentKind(s).
236238
func (c *Config) getEnvironmentVariablesForComponentKinds(logger logr.Logger, componentKinds ...ComponentKind) ([]corev1.EnvVar, error) {
237-
var envVars = []corev1.EnvVar{}
239+
envVars := []corev1.EnvVar{}
238240
enabledComponents := c.GetEnabledComponents()
239241
for _, componentKind := range componentKinds {
240242
var retriever components.ParserRetriever

apis/v1beta1/config_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,6 @@ func TestConfig_GetEnabledComponents(t *testing.T) {
559559
file string
560560
want map[ComponentKind]map[string]any
561561
}{
562-
563562
{
564563
name: "connectors",
565564
file: "testdata/otelcol-connectors.yaml",
@@ -826,7 +825,6 @@ func TestConfig_GetExporterPorts(t *testing.T) {
826825
want []v1.ServicePort
827826
wantErr bool
828827
}{
829-
830828
{
831829
name: "connectors",
832830
file: "testdata/otelcol-connectors.yaml",

apis/v1beta1/metrics.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (m *Metrics) delete(ctx context.Context, collector *OpenTelemetryCollector)
131131
m.updateGeneralCRMetricsComponents(ctx, collector, false)
132132
}
133133

134-
func (m *Metrics) update(ctx context.Context, oldCollector *OpenTelemetryCollector, newCollector *OpenTelemetryCollector) {
134+
func (m *Metrics) update(ctx context.Context, oldCollector, newCollector *OpenTelemetryCollector) {
135135
m.delete(ctx, oldCollector)
136136
m.create(ctx, newCollector)
137137
}
@@ -147,6 +147,7 @@ func (m *Metrics) updateGeneralCRMetricsComponents(ctx context.Context, collecto
147147
attribute.Key("type").String(string(collector.Spec.Mode)),
148148
))
149149
}
150+
150151
func (m *Metrics) updateComponentCounters(ctx context.Context, collector *OpenTelemetryCollector, up bool) {
151152
components := getComponentsFromConfig(collector.Spec.Config)
152153
moveCounter(ctx, collector, components.receivers, m.receiversCounter, up)
@@ -197,7 +198,8 @@ func getComponentsFromConfig(yamlContent Config) *componentDefinitions {
197198
}
198199

199200
func moveCounter(
200-
ctx context.Context, collector *OpenTelemetryCollector, types []string, upDown metric.Int64UpDownCounter, up bool) {
201+
ctx context.Context, collector *OpenTelemetryCollector, types []string, upDown metric.Int64UpDownCounter, up bool,
202+
) {
201203
for _, exporter := range types {
202204
inc := 1
203205
if !up {

apis/v1beta1/metrics_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestOTELCollectorCRDMetrics(t *testing.T) {
104104
},
105105
}
106106

107-
var tests = []struct {
107+
tests := []struct {
108108
name string
109109
testFunction func(t *testing.T, m *Metrics, collectors []*OpenTelemetryCollector, reader metric.Reader)
110110
}{

apis/v1beta1/targetallocator_rbac.go

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,43 @@ import (
1212
"github.com/open-telemetry/opentelemetry-operator/internal/rbac"
1313
)
1414

15-
var (
16-
17-
// targetAllocatorCRPolicyRules are the policy rules required for the CR functionality.
18-
targetAllocatorCRPolicyRules = []*rbacv1.PolicyRule{
19-
{
20-
APIGroups: []string{"monitoring.coreos.com"},
21-
Resources: []string{"servicemonitors", "podmonitors"},
22-
Verbs: []string{"*"},
23-
}, {
24-
APIGroups: []string{""},
25-
Resources: []string{"nodes", "nodes/metrics", "services", "endpoints", "pods", "namespaces"},
26-
Verbs: []string{"get", "list", "watch"},
27-
}, {
28-
APIGroups: []string{""},
29-
Resources: []string{"configmaps"},
30-
Verbs: []string{"get"},
31-
}, {
32-
APIGroups: []string{"discovery.k8s.io"},
33-
Resources: []string{"endpointslices"},
34-
Verbs: []string{"get", "list", "watch"},
35-
}, {
36-
APIGroups: []string{"networking.k8s.io"},
37-
Resources: []string{"ingresses"},
38-
Verbs: []string{"get", "list", "watch"},
39-
}, {
40-
NonResourceURLs: []string{"/metrics"},
41-
Verbs: []string{"get"},
42-
}, {
43-
NonResourceURLs: []string{"/api", "/api/*", "/apis", "/apis/*"},
44-
Verbs: []string{"get"},
45-
},
46-
}
47-
)
15+
// targetAllocatorCRPolicyRules are the policy rules required for the CR functionality.
16+
var targetAllocatorCRPolicyRules = []*rbacv1.PolicyRule{
17+
{
18+
APIGroups: []string{"monitoring.coreos.com"},
19+
Resources: []string{"servicemonitors", "podmonitors"},
20+
Verbs: []string{"*"},
21+
}, {
22+
APIGroups: []string{""},
23+
Resources: []string{"nodes", "nodes/metrics", "services", "endpoints", "pods", "namespaces"},
24+
Verbs: []string{"get", "list", "watch"},
25+
}, {
26+
APIGroups: []string{""},
27+
Resources: []string{"configmaps"},
28+
Verbs: []string{"get"},
29+
}, {
30+
APIGroups: []string{"discovery.k8s.io"},
31+
Resources: []string{"endpointslices"},
32+
Verbs: []string{"get", "list", "watch"},
33+
}, {
34+
APIGroups: []string{"networking.k8s.io"},
35+
Resources: []string{"ingresses"},
36+
Verbs: []string{"get", "list", "watch"},
37+
}, {
38+
NonResourceURLs: []string{"/metrics"},
39+
Verbs: []string{"get"},
40+
}, {
41+
NonResourceURLs: []string{"/api", "/api/*", "/apis", "/apis/*"},
42+
Verbs: []string{"get"},
43+
},
44+
}
4845

4946
func CheckTargetAllocatorPrometheusCRPolicyRules(
5047
ctx context.Context,
5148
reviewer *rbac.Reviewer,
5249
namespace string,
53-
serviceAccountName string) (warnings []string, err error) {
50+
serviceAccountName string,
51+
) (warnings []string, err error) {
5452
subjectAccessReviews, err := reviewer.CheckPolicyRules(
5553
ctx,
5654
serviceAccountName,

0 commit comments

Comments
 (0)