diff --git a/apis/v1alpha1/collector_webhook_test.go b/apis/v1alpha1/collector_webhook_test.go index 8ccc26bb11..fd8763ebd5 100644 --- a/apis/v1alpha1/collector_webhook_test.go +++ b/apis/v1alpha1/collector_webhook_test.go @@ -277,6 +277,7 @@ func TestOTELColDefaultingWebhook(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { cvw := &CollectorWebhook{ logger: logr.Discard(), @@ -786,6 +787,7 @@ func TestOTELColValidatingWebhook(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { cvw := &CollectorWebhook{ logger: logr.Discard(), diff --git a/apis/v1alpha1/instrumentation_webhook_test.go b/apis/v1alpha1/instrumentation_webhook_test.go index 46f7327ad8..81049cbc0c 100644 --- a/apis/v1alpha1/instrumentation_webhook_test.go +++ b/apis/v1alpha1/instrumentation_webhook_test.go @@ -116,6 +116,7 @@ func TestInstrumentationValidatingWebhook(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { ctx := context.Background() if test.err == "" { diff --git a/apis/v1alpha1/opampbridge_webhook_test.go b/apis/v1alpha1/opampbridge_webhook_test.go index 947eaa03e6..b67551b8ee 100644 --- a/apis/v1alpha1/opampbridge_webhook_test.go +++ b/apis/v1alpha1/opampbridge_webhook_test.go @@ -108,6 +108,7 @@ func TestOpAMPBridgeDefaultingWebhook(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { webhook := &OpAMPBridgeWebhook{ logger: logr.Discard(), @@ -294,6 +295,7 @@ func TestOpAMPBridgeValidatingWebhook(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { webhook := &OpAMPBridgeWebhook{ logger: logr.Discard(), diff --git a/controllers/reconcile_test.go b/controllers/reconcile_test.go index 85b1c137df..b83e165997 100644 --- a/controllers/reconcile_test.go +++ b/controllers/reconcile_test.go @@ -518,6 +518,7 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { testContext := context.Background() nsn := types.NamespacedName{Name: tt.args.params.OtelCol.Name, Namespace: tt.args.params.OtelCol.Namespace} @@ -557,6 +558,7 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) { } // run the next set of checks for pid, updateParam := range tt.args.updates { + updateParam := updateParam existing := v1alpha1.OpenTelemetryCollector{} found, err := populateObjectIfExists(t, &existing, nsn) assert.True(t, found) @@ -676,6 +678,7 @@ func TestOpAMPBridgeReconciler_Reconcile(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { testContext := context.Background() nsn := types.NamespacedName{Name: tt.args.params.OpAMPBridge.Name, Namespace: tt.args.params.OpAMPBridge.Namespace} @@ -710,6 +713,7 @@ func TestOpAMPBridgeReconciler_Reconcile(t *testing.T) { } // run the next set of checks for pid, updateParam := range tt.args.updates { + updateParam := updateParam existing := v1alpha1.OpAMPBridge{} found, err := populateObjectIfExists(t, &existing, nsn) assert.True(t, found) diff --git a/internal/manifests/collector/adapters/config_to_ports.go b/internal/manifests/collector/adapters/config_to_ports.go index 1741e6a18d..b712e1df40 100644 --- a/internal/manifests/collector/adapters/config_to_ports.go +++ b/internal/manifests/collector/adapters/config_to_ports.go @@ -15,7 +15,7 @@ package adapters import ( - "errors" + "fmt" "net" "sort" "strconv" @@ -24,26 +24,24 @@ import ( "github.com/mitchellh/mapstructure" corev1 "k8s.io/api/core/v1" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" exporterParser "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser/exporter" receiverParser "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser/receiver" ) -var ( - // ErrNoExporters indicates that there are no exporters in the configuration. - ErrNoExporters = errors.New("no exporters available as part of the configuration") +type ComponentType int - // ErrNoReceivers indicates that there are no receivers in the configuration. - ErrNoReceivers = errors.New("no receivers available as part of the configuration") - - // ErrReceiversNotAMap indicates that the receivers property isn't a map of values. - ErrReceiversNotAMap = errors.New("receivers property in the configuration doesn't contain valid receivers") - - // ErrExportersNotAMap indicates that the exporters property isn't a map of values. - ErrExportersNotAMap = errors.New("exporters property in the configuration doesn't contain valid exporters") +const ( + ComponentTypeReceiver ComponentType = iota + ComponentTypeExporter ) -// ConfigToExporterPorts converts the incoming configuration object into a set of service ports required by the exporters. -func ConfigToExporterPorts(logger logr.Logger, config map[interface{}]interface{}) ([]corev1.ServicePort, error) { +func (c ComponentType) String() string { + return [...]string{"receiver", "exporter"}[c] +} + +// ConfigToComponentPorts converts the incoming configuration object into a set of service ports required by the exporters. +func ConfigToComponentPorts(logger logr.Logger, cType ComponentType, config map[interface{}]interface{}) ([]corev1.ServicePort, error) { // now, we gather which ports we might need to open // for that, we get all the exporters and check their `endpoint` properties, // extracting the port from it. The port name has to be a "DNS_LABEL", so, we try to make it follow the pattern: @@ -52,119 +50,64 @@ func ConfigToExporterPorts(logger logr.Logger, config map[interface{}]interface{ // the exporter-qualifier is what comes after the slash in the exporter name, but typically nil // examples: // ```yaml - // exporters: - // exampleexporter: + // components: + // componentexample: // endpoint: 0.0.0.0:12345 - // exampleexporter/settings: + // componentexample/settings: // endpoint: 0.0.0.0:12346 - // in this case, we have two ports, named: "exampleexporter" and "exampleexporter-settings" - exportersProperty, ok := config["exporters"] + // in this case, we have 2 ports, named: "componentexample" and "componentexample-settings" + componentsProperty, ok := config[fmt.Sprintf("%ss", cType.String())] if !ok { - return nil, ErrNoExporters - } - expEnabled := GetEnabledExporters(logger, config) - if expEnabled == nil { - return nil, ErrExportersNotAMap + return nil, fmt.Errorf("no %ss available as part of the configuration", cType) } - exporters, ok := exportersProperty.(map[interface{}]interface{}) + + components, ok := componentsProperty.(map[interface{}]interface{}) if !ok { - return nil, ErrExportersNotAMap + return nil, fmt.Errorf("%ss doesn't contain valid components", cType.String()) + } + + compEnabled := getEnabledComponents(config, cType) + + if compEnabled == nil { + return nil, fmt.Errorf("no enabled %ss available as part of the configuration", cType) } ports := []corev1.ServicePort{} - for key, val := range exporters { - // This check will pass only the enabled exporters, + for key, val := range components { + // This check will pass only the enabled components, // then only the related ports will be opened. - if !expEnabled[key] { + if !compEnabled[key] { continue } exporter, ok := val.(map[interface{}]interface{}) if !ok { - logger.V(2).Info("exporter doesn't seem to be a map of properties", "exporter", key) + logger.V(2).Info("component doesn't seem to be a map of properties", cType.String(), key) exporter = map[interface{}]interface{}{} } - exprtName := key.(string) - exprtParser, err := exporterParser.For(logger, exprtName, exporter) - if err != nil { - logger.V(2).Info("no parser found for '%s'", exprtName) - continue + cmptName := key.(string) + var cmptParser parser.ComponentPortParser + var err error + switch cType { + case ComponentTypeExporter: + cmptParser, err = exporterParser.For(logger, cmptName, exporter) + case ComponentTypeReceiver: + cmptParser, err = receiverParser.For(logger, cmptName, exporter) } - exprtPorts, err := exprtParser.Ports() if err != nil { - logger.Error(err, "parser for '%s' has returned an error: %w", exprtName, err) + logger.V(2).Info("no parser found for '%s'", cmptName) continue } - if len(exprtPorts) > 0 { - ports = append(ports, exprtPorts...) - } - } - - sort.Slice(ports, func(i, j int) bool { - return ports[i].Name < ports[j].Name - }) - - return ports, nil -} - -// ConfigToReceiverPorts converts the incoming configuration object into a set of service ports required by the receivers. -func ConfigToReceiverPorts(logger logr.Logger, config map[interface{}]interface{}) ([]corev1.ServicePort, error) { - // now, we gather which ports we might need to open - // for that, we get all the receivers and check their `endpoint` properties, - // extracting the port from it. The port name has to be a "DNS_LABEL", so, we try to make it follow the pattern: - // ${instance.Name}-${receiver.name}-${receiver.qualifier} - // the receiver-name is typically the node name from the receivers map - // the receiver-qualifier is what comes after the slash in the receiver name, but typically nil - // examples: - // ```yaml - // receivers: - // examplereceiver: - // endpoint: 0.0.0.0:12345 - // examplereceiver/settings: - // endpoint: 0.0.0.0:12346 - // in this case, we have two ports, named: "examplereceiver" and "examplereceiver-settings" - receiversProperty, ok := config["receivers"] - if !ok { - return nil, ErrNoReceivers - } - recEnabled := GetEnabledReceivers(logger, config) - if recEnabled == nil { - return nil, ErrReceiversNotAMap - } - receivers, ok := receiversProperty.(map[interface{}]interface{}) - if !ok { - return nil, ErrReceiversNotAMap - } - - ports := []corev1.ServicePort{} - for key, val := range receivers { - // This check will pass only the enabled receivers, - // then only the related ports will be opened. - if !recEnabled[key] { - continue - } - receiver, ok := val.(map[interface{}]interface{}) - if !ok { - logger.Info("receiver doesn't seem to be a map of properties", "receiver", key) - receiver = map[interface{}]interface{}{} - } - - rcvrName := key.(string) - rcvrParser := receiverParser.For(logger, rcvrName, receiver) - - rcvrPorts, err := rcvrParser.Ports() + exprtPorts, err := cmptParser.Ports() if err != nil { - // should we break the process and return an error, or just ignore this faulty parser - // and let the other parsers add their ports to the service? right now, the best - // option seems to be to log the failures and move on, instead of failing them all - logger.Error(err, "parser for '%s' has returned an error: %w", rcvrName, err) + logger.Error(err, "parser for '%s' has returned an error: %w", cmptName, err) continue } - if len(rcvrPorts) > 0 { - ports = append(ports, rcvrPorts...) + if len(exprtPorts) > 0 { + ports = append(ports, exprtPorts...) } } @@ -176,12 +119,12 @@ func ConfigToReceiverPorts(logger logr.Logger, config map[interface{}]interface{ } func ConfigToPorts(logger logr.Logger, config map[interface{}]interface{}) []corev1.ServicePort { - ports, err := ConfigToReceiverPorts(logger, config) + ports, err := ConfigToComponentPorts(logger, ComponentTypeReceiver, config) if err != nil { logger.Error(err, "there was a problem while getting the ports from the receivers") } - exporterPorts, err := ConfigToExporterPorts(logger, config) + exporterPorts, err := ConfigToComponentPorts(logger, ComponentTypeExporter, config) if err != nil { logger.Error(err, "there was a problem while getting the ports from the exporters") } diff --git a/internal/manifests/collector/adapters/config_to_ports_test.go b/internal/manifests/collector/adapters/config_to_ports_test.go index 7c7d9f3d8f..c2ae638ef5 100644 --- a/internal/manifests/collector/adapters/config_to_ports_test.go +++ b/internal/manifests/collector/adapters/config_to_ports_test.go @@ -26,6 +26,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser/receiver" ) @@ -83,7 +84,7 @@ func TestExtractPortsFromConfig(t *testing.T) { require.NotEmpty(t, config) // test - ports, err := adapters.ConfigToReceiverPorts(logger, config) + ports, err := adapters.ConfigToComponentPorts(logger, adapters.ComponentTypeReceiver, config) assert.NoError(t, err) assert.Len(t, ports, 10) @@ -116,12 +117,12 @@ func TestNoPortsParsed(t *testing.T) { configStr string }{ { - expected: adapters.ErrNoReceivers, + expected: errors.New("no receivers available as part of the configuration"), desc: "empty", configStr: "", }, { - expected: adapters.ErrReceiversNotAMap, + expected: errors.New("receivers doesn't contain valid components"), desc: "not a map", configStr: "receivers: some-string", }, @@ -132,7 +133,7 @@ func TestNoPortsParsed(t *testing.T) { require.NoError(t, err) // test - ports, err := adapters.ConfigToReceiverPorts(logger, config) + ports, err := adapters.ConfigToComponentPorts(logger, adapters.ComponentTypeReceiver, config) // verify assert.Nil(t, ports) @@ -161,7 +162,7 @@ func TestInvalidReceivers(t *testing.T) { require.NoError(t, err) // test - ports, err := adapters.ConfigToReceiverPorts(logger, config) + ports, err := adapters.ConfigToComponentPorts(logger, adapters.ComponentTypeReceiver, config) // verify assert.NoError(t, err) @@ -179,7 +180,7 @@ func TestParserFailed(t *testing.T) { return nil, errors.New("mocked error") }, } - receiver.Register("mock", func(logger logr.Logger, name string, config map[interface{}]interface{}) receiver.ReceiverParser { + receiver.Register("mock", func(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return mockParser }) @@ -197,7 +198,7 @@ func TestParserFailed(t *testing.T) { } // test - ports, err := adapters.ConfigToReceiverPorts(logger, config) + ports, err := adapters.ConfigToComponentPorts(logger, adapters.ComponentTypeReceiver, config) // verify assert.Len(t, ports, 0) diff --git a/internal/manifests/collector/adapters/config_validate.go b/internal/manifests/collector/adapters/config_validate.go index 221a4f21a6..8283702cf5 100644 --- a/internal/manifests/collector/adapters/config_validate.go +++ b/internal/manifests/collector/adapters/config_validate.go @@ -14,22 +14,13 @@ package adapters -import ( - "github.com/go-logr/logr" -) +import "fmt" // Following Otel Doc: Configuring a receiver does not enable it. The receivers are enabled via pipelines within the service section. -// GetEnabledReceivers returns all enabled receivers as a true flag set. If it can't find any receiver, it will return a nil interface. -func GetEnabledReceivers(_ logr.Logger, config map[interface{}]interface{}) map[interface{}]bool { - return getEnabledComponents(config, "receivers") -} - -func GetEnabledExporters(_ logr.Logger, config map[interface{}]interface{}) map[interface{}]bool { - return getEnabledComponents(config, "exporters") -} - -func getEnabledComponents(config map[interface{}]interface{}, componentType string) map[interface{}]bool { - cfgComponents, ok := config[componentType] +// getEnabledComponents returns all enabled components as a true flag set. If it can't find any receiver, it will return a nil interface. +func getEnabledComponents(config map[interface{}]interface{}, componentType ComponentType) map[interface{}]bool { + componentTypePlural := fmt.Sprintf("%ss", componentType) + cfgComponents, ok := config[componentTypePlural] if !ok { return nil } @@ -85,7 +76,7 @@ func getEnabledComponents(config map[interface{}]interface{}, componentType stri return nil } for pipSpecID, pipSpecCfg := range pipelineDesc { - if pipSpecID.(string) == componentType { + if pipSpecID.(string) == componentTypePlural { receiversList, ok := pipSpecCfg.([]interface{}) if !ok { continue diff --git a/internal/manifests/collector/adapters/config_validate_test.go b/internal/manifests/collector/adapters/config_validate_test.go index 34cf841181..7003235fed 100644 --- a/internal/manifests/collector/adapters/config_validate_test.go +++ b/internal/manifests/collector/adapters/config_validate_test.go @@ -17,13 +17,9 @@ package adapters import ( "testing" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "github.com/stretchr/testify/require" ) -var logger = logf.Log.WithName("unit-tests") - func TestConfigValidate(t *testing.T) { // prepare @@ -61,7 +57,7 @@ service: require.NotEmpty(t, config) // test - check := GetEnabledReceivers(logger, config) + check := getEnabledComponents(config, ComponentTypeReceiver) require.NotEmpty(t, check) } @@ -102,6 +98,6 @@ service: require.NotEmpty(t, config) // test - check := GetEnabledReceivers(logger, config) + check := getEnabledComponents(config, ComponentTypeReceiver) require.Empty(t, check) } diff --git a/internal/manifests/collector/ingress.go b/internal/manifests/collector/ingress.go index 36e7e15ae3..d1b68106eb 100644 --- a/internal/manifests/collector/ingress.go +++ b/internal/manifests/collector/ingress.go @@ -144,7 +144,7 @@ func servicePortsFromCfg(logger logr.Logger, otelcol v1alpha1.OpenTelemetryColle return nil } - ports, err := adapters.ConfigToReceiverPorts(logger, configFromString) + ports, err := adapters.ConfigToComponentPorts(logger, adapters.ComponentTypeReceiver, configFromString) if err != nil { logger.Error(err, "couldn't build the ingress for this instance") } diff --git a/internal/manifests/collector/parser/exporter/exporter.go b/internal/manifests/collector/parser/exporter/exporter.go index ae0282f736..93c66b8599 100644 --- a/internal/manifests/collector/parser/exporter/exporter.go +++ b/internal/manifests/collector/parser/exporter/exporter.go @@ -25,31 +25,20 @@ import ( "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) -// ExporterParser is an interface that should be implemented by all exporter parsers. -type ExporterParser interface { - // Ports returns the service ports parsed based on the exporter's configuration - Ports() ([]corev1.ServicePort, error) - - // ParserName returns the name of this parser - ParserName() string -} - -// Builder specifies the signature required for parser builders. -type Builder func(logr.Logger, string, map[interface{}]interface{}) ExporterParser - -// registry holds a record of all known parsers. -var registry = make(map[string]Builder) +// registry holds a record of all known exporter parsers. +var registry = make(map[string]parser.Builder) // BuilderFor returns a parser builder for the given exporter name. -func BuilderFor(name string) Builder { +func BuilderFor(name string) parser.Builder { return registry[exporterType(name)] } // For returns a new parser for the given exporter name + config. -func For(logger logr.Logger, name string, config map[interface{}]interface{}) (ExporterParser, error) { +func For(logger logr.Logger, name string, config map[interface{}]interface{}) (parser.ComponentPortParser, error) { builder := BuilderFor(name) if builder == nil { return nil, fmt.Errorf("no builders for %s", name) @@ -58,7 +47,7 @@ func For(logger logr.Logger, name string, config map[interface{}]interface{}) (E } // Register adds a new parser builder to the list of known builders. -func Register(name string, builder Builder) { +func Register(name string, builder parser.Builder) { registry[name] = builder } diff --git a/internal/manifests/collector/parser/exporter/exporter_prometheus.go b/internal/manifests/collector/parser/exporter/exporter_prometheus.go index cc9e17748b..61d58588da 100644 --- a/internal/manifests/collector/parser/exporter/exporter_prometheus.go +++ b/internal/manifests/collector/parser/exporter/exporter_prometheus.go @@ -19,10 +19,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) -var _ ExporterParser = &PrometheusExporterParser{} +var _ parser.ComponentPortParser = &PrometheusExporterParser{} const ( parserNamePrometheus = "__prometheus" @@ -37,7 +38,7 @@ type PrometheusExporterParser struct { } // NewPrometheusExporterParser builds a new parser for OTLP receivers. -func NewPrometheusExporterParser(logger logr.Logger, name string, config map[interface{}]interface{}) ExporterParser { +func NewPrometheusExporterParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &PrometheusExporterParser{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/parser.go b/internal/manifests/collector/parser/parser.go new file mode 100644 index 0000000000..62de283b15 --- /dev/null +++ b/internal/manifests/collector/parser/parser.go @@ -0,0 +1,31 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package parser + +import ( + "github.com/go-logr/logr" + corev1 "k8s.io/api/core/v1" +) + +type ComponentPortParser interface { + // Ports returns the service ports parsed based on the exporter's configuration + Ports() ([]corev1.ServicePort, error) + + // ParserName returns the name of this parser + ParserName() string +} + +// Builder specifies the signature required for parser builders. +type Builder func(logr.Logger, string, map[interface{}]interface{}) ComponentPortParser diff --git a/internal/manifests/collector/parser/receiver/receiver.go b/internal/manifests/collector/parser/receiver/receiver.go index 88c6b4bcf2..97147658f4 100644 --- a/internal/manifests/collector/parser/receiver/receiver.go +++ b/internal/manifests/collector/parser/receiver/receiver.go @@ -26,26 +26,15 @@ import ( corev1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) -// ReceiverParser is an interface that should be implemented by all receiver parsers. -type ReceiverParser interface { - // Ports returns the service ports parsed based on the receiver's configuration - Ports() ([]corev1.ServicePort, error) - - // ParserName returns the name of this parser - ParserName() string -} - -// Builder specifies the signature required for parser builders. -type Builder func(logr.Logger, string, map[interface{}]interface{}) ReceiverParser - -// registry holds a record of all known parsers. -var registry = make(map[string]Builder) +// registry holds a record of all known receiver parsers. +var registry = make(map[string]parser.Builder) // BuilderFor returns a parser builder for the given receiver name. -func BuilderFor(name string) Builder { +func BuilderFor(name string) parser.Builder { builder := registry[receiverType(name)] if builder == nil { builder = NewGenericReceiverParser @@ -55,13 +44,13 @@ func BuilderFor(name string) Builder { } // For returns a new parser for the given receiver name + config. -func For(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func For(logger logr.Logger, name string, config map[interface{}]interface{}) (parser.ComponentPortParser, error) { builder := BuilderFor(name) - return builder(logger, name, config) + return builder(logger, name, config), nil } // Register adds a new parser builder to the list of known builders. -func Register(name string, builder Builder) { +func Register(name string, builder parser.Builder) { registry[name] = builder } diff --git a/internal/manifests/collector/parser/receiver/receiver_aws-xray.go b/internal/manifests/collector/parser/receiver/receiver_aws-xray.go index f5569f247e..44618b3aa5 100644 --- a/internal/manifests/collector/parser/receiver/receiver_aws-xray.go +++ b/internal/manifests/collector/parser/receiver/receiver_aws-xray.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameAWSXRAY = "__awsxray" // NewAWSXrayReceiverParser builds a new parser for AWS xray receivers, from the contrib repository. -func NewAWSXrayReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewAWSXrayReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_carbon.go b/internal/manifests/collector/parser/receiver/receiver_carbon.go index 45c3c04473..b1b0aaa4ce 100644 --- a/internal/manifests/collector/parser/receiver/receiver_carbon.go +++ b/internal/manifests/collector/parser/receiver/receiver_carbon.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameCarbon = "__carbon" // NewCarbonReceiverParser builds a new parser for Carbon receivers, from the contrib repository. -func NewCarbonReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewCarbonReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_collectd.go b/internal/manifests/collector/parser/receiver/receiver_collectd.go index d18e6b72b2..aa42ab0397 100644 --- a/internal/manifests/collector/parser/receiver/receiver_collectd.go +++ b/internal/manifests/collector/parser/receiver/receiver_collectd.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameCollectd = "__collectd" // NewCollectdReceiverParser builds a new parser for Collectd receivers, from the contrib repository. -func NewCollectdReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewCollectdReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_fluent-forward.go b/internal/manifests/collector/parser/receiver/receiver_fluent-forward.go index c55debd964..88881923fa 100644 --- a/internal/manifests/collector/parser/receiver/receiver_fluent-forward.go +++ b/internal/manifests/collector/parser/receiver/receiver_fluent-forward.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameFluentForward = "__fluentforward" // NewFluentForwardReceiverParser builds a new parser for FluentForward receivers, from the contrib repository. -func NewFluentForwardReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewFluentForwardReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_generic.go b/internal/manifests/collector/parser/receiver/receiver_generic.go index 42d5975ec7..864b5bb111 100644 --- a/internal/manifests/collector/parser/receiver/receiver_generic.go +++ b/internal/manifests/collector/parser/receiver/receiver_generic.go @@ -18,12 +18,13 @@ import ( "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) const parserNameGeneric = "__generic" -var _ ReceiverParser = &GenericReceiver{} +var _ parser.ComponentPortParser = &GenericReceiver{} // GenericReceiver is a special parser for generic receivers. It doesn't self-register and should be created/used directly. type GenericReceiver struct { @@ -40,7 +41,7 @@ type GenericReceiver struct { // so that it can expose the required port based on the receiver's config. Receiver scrapers are ignored. // NewGenericReceiverParser builds a new parser for generic receivers. -func NewGenericReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewGenericReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_generic_test.go b/internal/manifests/collector/parser/receiver/receiver_generic_test.go index 4b6580d29e..1adfcf12df 100644 --- a/internal/manifests/collector/parser/receiver/receiver_generic_test.go +++ b/internal/manifests/collector/parser/receiver/receiver_generic_test.go @@ -21,6 +21,7 @@ import ( "github.com/stretchr/testify/assert" logf "sigs.k8s.io/controller-runtime/pkg/log" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser/receiver" ) @@ -59,7 +60,7 @@ func TestFailedToParseEndpoint(t *testing.T) { func TestDownstreamParsers(t *testing.T) { for _, tt := range []struct { - builder func(logr.Logger, string, map[interface{}]interface{}) receiver.ReceiverParser + builder func(logr.Logger, string, map[interface{}]interface{}) parser.ComponentPortParser desc string receiverName string parserName string diff --git a/internal/manifests/collector/parser/receiver/receiver_influxdb.go b/internal/manifests/collector/parser/receiver/receiver_influxdb.go index d2e9cc3e58..0930a29f73 100644 --- a/internal/manifests/collector/parser/receiver/receiver_influxdb.go +++ b/internal/manifests/collector/parser/receiver/receiver_influxdb.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameInfluxdb = "__influxdb" // NewInfluxdbReceiverParser builds a new parser for Influxdb receivers, from the contrib repository. -func NewInfluxdbReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewInfluxdbReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_jaeger.go b/internal/manifests/collector/parser/receiver/receiver_jaeger.go index 26329a6ec9..dcc99d8bd9 100644 --- a/internal/manifests/collector/parser/receiver/receiver_jaeger.go +++ b/internal/manifests/collector/parser/receiver/receiver_jaeger.go @@ -20,10 +20,11 @@ import ( "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) -var _ ReceiverParser = &JaegerReceiverParser{} +var _ parser.ComponentPortParser = &JaegerReceiverParser{} const ( parserNameJaeger = "__jaeger" @@ -42,7 +43,7 @@ type JaegerReceiverParser struct { } // NewJaegerReceiverParser builds a new parser for Jaeger receivers. -func NewJaegerReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewJaegerReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { if protocols, ok := config["protocols"].(map[interface{}]interface{}); ok { return &JaegerReceiverParser{ logger: logger, diff --git a/internal/manifests/collector/parser/receiver/receiver_jaeger_test.go b/internal/manifests/collector/parser/receiver/receiver_jaeger_test.go index 84f343a2cf..dadf3e0cb5 100644 --- a/internal/manifests/collector/parser/receiver/receiver_jaeger_test.go +++ b/internal/manifests/collector/parser/receiver/receiver_jaeger_test.go @@ -28,7 +28,8 @@ func TestJaegerSelfRegisters(t *testing.T) { func TestJaegerIsFoundByName(t *testing.T) { // test - p := For(logger, "jaeger", map[interface{}]interface{}{}) + p, err := For(logger, "jaeger", map[interface{}]interface{}{}) + assert.NoError(t, err) // verify assert.Equal(t, "__jaeger", p.ParserName()) diff --git a/internal/manifests/collector/parser/receiver/receiver_oc.go b/internal/manifests/collector/parser/receiver/receiver_oc.go index c2515a0ad4..3463a8d398 100644 --- a/internal/manifests/collector/parser/receiver/receiver_oc.go +++ b/internal/manifests/collector/parser/receiver/receiver_oc.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameOpenCensus = "__opencensus" // NewOpenCensusReceiverParser builds a new parser for OpenCensus receivers. -func NewOpenCensusReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewOpenCensusReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_otlp.go b/internal/manifests/collector/parser/receiver/receiver_otlp.go index 471ca10c8c..68972fd950 100644 --- a/internal/manifests/collector/parser/receiver/receiver_otlp.go +++ b/internal/manifests/collector/parser/receiver/receiver_otlp.go @@ -21,10 +21,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) -var _ ReceiverParser = &OTLPReceiverParser{} +var _ parser.ComponentPortParser = &OTLPReceiverParser{} const ( parserNameOTLP = "__otlp" @@ -46,7 +47,7 @@ type OTLPReceiverParser struct { } // NewOTLPReceiverParser builds a new parser for OTLP receivers. -func NewOTLPReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewOTLPReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { if protocols, ok := config["protocols"].(map[interface{}]interface{}); ok { return &OTLPReceiverParser{ logger: logger, diff --git a/internal/manifests/collector/parser/receiver/receiver_otlp_test.go b/internal/manifests/collector/parser/receiver/receiver_otlp_test.go index 4f5e4bcb1d..7165153dde 100644 --- a/internal/manifests/collector/parser/receiver/receiver_otlp_test.go +++ b/internal/manifests/collector/parser/receiver/receiver_otlp_test.go @@ -27,7 +27,8 @@ func TestOTLPSelfRegisters(t *testing.T) { func TestOTLPIsFoundByName(t *testing.T) { // test - p := For(logger, "otlp", map[interface{}]interface{}{}) + p, err := For(logger, "otlp", map[interface{}]interface{}{}) + assert.NoError(t, err) // verify assert.Equal(t, "__otlp", p.ParserName()) diff --git a/internal/manifests/collector/parser/receiver/receiver_sapm.go b/internal/manifests/collector/parser/receiver/receiver_sapm.go index e0a3756abb..924b88bff5 100644 --- a/internal/manifests/collector/parser/receiver/receiver_sapm.go +++ b/internal/manifests/collector/parser/receiver/receiver_sapm.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameSAPM = "__sapm" // NewSAPMReceiverParser builds a new parser for SAPM receivers, from the contrib repository. -func NewSAPMReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewSAPMReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_signalfx.go b/internal/manifests/collector/parser/receiver/receiver_signalfx.go index a3ecc6873a..549e802453 100644 --- a/internal/manifests/collector/parser/receiver/receiver_signalfx.go +++ b/internal/manifests/collector/parser/receiver/receiver_signalfx.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameSignalFx = "__signalfx" // NewSignalFxReceiverParser builds a new parser for SignalFx receivers, from the contrib repository. -func NewSignalFxReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewSignalFxReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_skywalking.go b/internal/manifests/collector/parser/receiver/receiver_skywalking.go index 5bee2cb03e..9b72847ee9 100644 --- a/internal/manifests/collector/parser/receiver/receiver_skywalking.go +++ b/internal/manifests/collector/parser/receiver/receiver_skywalking.go @@ -21,10 +21,11 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) -var _ ReceiverParser = &SkywalkingReceiverParser{} +var _ parser.ComponentPortParser = &SkywalkingReceiverParser{} const ( parserNameSkywalking = "__skywalking" @@ -41,7 +42,7 @@ type SkywalkingReceiverParser struct { } // NewSkywalkingReceiverParser builds a new parser for Skywalking receivers. -func NewSkywalkingReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewSkywalkingReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { if protocols, ok := config["protocols"].(map[interface{}]interface{}); ok { return &SkywalkingReceiverParser{ logger: logger, diff --git a/internal/manifests/collector/parser/receiver/receiver_skywalking_test.go b/internal/manifests/collector/parser/receiver/receiver_skywalking_test.go index e373e16d8e..ab00c852c2 100644 --- a/internal/manifests/collector/parser/receiver/receiver_skywalking_test.go +++ b/internal/manifests/collector/parser/receiver/receiver_skywalking_test.go @@ -27,7 +27,8 @@ func TestSkywalkingSelfRegisters(t *testing.T) { func TestSkywalkingIsFoundByName(t *testing.T) { // test - p := For(logger, "skywalking", map[interface{}]interface{}{}) + p, err := For(logger, "skywalking", map[interface{}]interface{}{}) + assert.NoError(t, err) // verify assert.Equal(t, "__skywalking", p.ParserName()) diff --git a/internal/manifests/collector/parser/receiver/receiver_splunk-hec.go b/internal/manifests/collector/parser/receiver/receiver_splunk-hec.go index aa7b478bf0..676415334b 100644 --- a/internal/manifests/collector/parser/receiver/receiver_splunk-hec.go +++ b/internal/manifests/collector/parser/receiver/receiver_splunk-hec.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameSplunkHec = "__splunk_hec" // NewSplunkHecReceiverParser builds a new parser for Splunk Hec receivers, from the contrib repository. -func NewSplunkHecReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewSplunkHecReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_statsd.go b/internal/manifests/collector/parser/receiver/receiver_statsd.go index 725fb27270..0f41520e22 100644 --- a/internal/manifests/collector/parser/receiver/receiver_statsd.go +++ b/internal/manifests/collector/parser/receiver/receiver_statsd.go @@ -17,12 +17,14 @@ package receiver import ( "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" ) const parserNameStatsd = "__statsd" // NewStatsdReceiverParser builds a new parser for Statsd receivers, from the contrib repository. -func NewStatsdReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewStatsdReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_test.go b/internal/manifests/collector/parser/receiver/receiver_test.go index c972f7cd23..44cb04519d 100644 --- a/internal/manifests/collector/parser/receiver/receiver_test.go +++ b/internal/manifests/collector/parser/receiver/receiver_test.go @@ -22,6 +22,7 @@ import ( corev1 "k8s.io/api/core/v1" logf "sigs.k8s.io/controller-runtime/pkg/log" + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" "github.com/open-telemetry/opentelemetry-operator/internal/naming" ) @@ -118,7 +119,8 @@ func TestIgnorekubeletstatsEndpoint(t *testing.T) { func TestReceiverFallbackWhenNotRegistered(t *testing.T) { // test - p := For(logger, "myreceiver", map[interface{}]interface{}{}) + p, err := For(logger, "myreceiver", map[interface{}]interface{}{}) + assert.NoError(t, err) // test assert.Equal(t, "__generic", p.ParserName()) @@ -127,13 +129,13 @@ func TestReceiverFallbackWhenNotRegistered(t *testing.T) { func TestReceiverShouldFindRegisteredParser(t *testing.T) { // prepare builderCalled := false - Register("mock", func(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { + Register("mock", func(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { builderCalled = true return &mockParser{} }) // test - For(logger, "mock", map[interface{}]interface{}{}) + _, _ = For(logger, "mock", map[interface{}]interface{}{}) // verify assert.True(t, builderCalled) diff --git a/internal/manifests/collector/parser/receiver/receiver_wavefront.go b/internal/manifests/collector/parser/receiver/receiver_wavefront.go index 658d192c2a..f2eafb8556 100644 --- a/internal/manifests/collector/parser/receiver/receiver_wavefront.go +++ b/internal/manifests/collector/parser/receiver/receiver_wavefront.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameWavefront = "__wavefront" // NewWavefrontReceiverParser builds a new parser for Wavefront receivers, from the contrib repository. -func NewWavefrontReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewWavefrontReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_zipkin-scribe.go b/internal/manifests/collector/parser/receiver/receiver_zipkin-scribe.go index c45968b1db..8f8d9fe210 100644 --- a/internal/manifests/collector/parser/receiver/receiver_zipkin-scribe.go +++ b/internal/manifests/collector/parser/receiver/receiver_zipkin-scribe.go @@ -14,12 +14,16 @@ package receiver -import "github.com/go-logr/logr" +import ( + "github.com/go-logr/logr" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" +) const parserNameZipkinScribe = "__zipkinscribe" // NewZipkinScribeReceiverParser builds a new parser for ZipkinScribe receivers. -func NewZipkinScribeReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewZipkinScribeReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { return &GenericReceiver{ logger: logger, name: name, diff --git a/internal/manifests/collector/parser/receiver/receiver_zipkin.go b/internal/manifests/collector/parser/receiver/receiver_zipkin.go index 412a8b6cf7..debbf8e9a4 100644 --- a/internal/manifests/collector/parser/receiver/receiver_zipkin.go +++ b/internal/manifests/collector/parser/receiver/receiver_zipkin.go @@ -17,12 +17,14 @@ package receiver import ( "github.com/go-logr/logr" corev1 "k8s.io/api/core/v1" + + "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/parser" ) const parserNameZipkin = "__zipkin" // NewZipkinReceiverParser builds a new parser for Zipkin receivers. -func NewZipkinReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) ReceiverParser { +func NewZipkinReceiverParser(logger logr.Logger, name string, config map[interface{}]interface{}) parser.ComponentPortParser { http := "http" return &GenericReceiver{ logger: logger, diff --git a/internal/manifests/collector/servicemonitor.go b/internal/manifests/collector/servicemonitor.go index abe78c8ce7..8b0a775f29 100644 --- a/internal/manifests/collector/servicemonitor.go +++ b/internal/manifests/collector/servicemonitor.go @@ -79,7 +79,7 @@ func endpointsFromConfig(logger logr.Logger, otelcol v1alpha1.OpenTelemetryColle return []monitoringv1.Endpoint{} } - exporterPorts, err := adapters.ConfigToExporterPorts(logger, c) + exporterPorts, err := adapters.ConfigToComponentPorts(logger, adapters.ComponentTypeExporter, c) if err != nil { logger.Error(err, "couldn't build service monitors from configuration") return []monitoringv1.Endpoint{} diff --git a/internal/webhook/podmutation/webhookhandler_test.go b/internal/webhook/podmutation/webhookhandler_test.go index d5bb69b795..0adbc2b929 100644 --- a/internal/webhook/podmutation/webhookhandler_test.go +++ b/internal/webhook/podmutation/webhookhandler_test.go @@ -123,6 +123,7 @@ func TestShouldInjectSidecar(t *testing.T) { }, }, } { + tt := tt t.Run(tt.name, func(t *testing.T) { err := k8sClient.Create(context.Background(), &tt.ns) require.NoError(t, err) @@ -341,6 +342,7 @@ func TestPodShouldNotBeChanged(t *testing.T) { }}, }, } { + tt := tt t.Run(tt.name, func(t *testing.T) { err := k8sClient.Create(context.Background(), &tt.ns) require.NoError(t, err) diff --git a/pkg/instrumentation/podmutator_test.go b/pkg/instrumentation/podmutator_test.go index b2b39d45f1..7e764abf07 100644 --- a/pkg/instrumentation/podmutator_test.go +++ b/pkg/instrumentation/podmutator_test.go @@ -5139,6 +5139,7 @@ func TestMutatePod(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { if test.setFeatureGates != nil { test.setFeatureGates(t)