Skip to content

Commit 798cd0d

Browse files
authored
[instrumentation] Remove env var prefix validation (open-telemetry#2768)
* Remove env var prefix validation * changelog
1 parent a7967a9 commit 798cd0d

File tree

2 files changed

+16
-40
lines changed

2 files changed

+16
-40
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: enhancement
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: instrumentation
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Remove env var prefix validation
9+
10+
# One or more tracking issues related to the change
11+
issues: [2768]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

apis/v1alpha1/instrumentation_webhook.go

-40
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ import (
3131
"github.com/open-telemetry/opentelemetry-operator/pkg/constants"
3232
)
3333

34-
const (
35-
envPrefix = "OTEL_"
36-
envSplunkPrefix = "SPLUNK_"
37-
)
38-
3934
var (
4035
_ admission.CustomValidator = &InstrumentationWebhook{}
4136
_ admission.CustomDefaulter = &InstrumentationWebhook{}
@@ -245,44 +240,9 @@ func (w InstrumentationWebhook) validate(r *Instrumentation) (admission.Warnings
245240
default:
246241
return warnings, fmt.Errorf("spec.sampler.type is not valid: %s", r.Spec.Sampler.Type)
247242
}
248-
249-
// validate env vars
250-
if err := w.validateEnv(r.Spec.Env); err != nil {
251-
return warnings, err
252-
}
253-
if err := w.validateEnv(r.Spec.Java.Env); err != nil {
254-
return warnings, err
255-
}
256-
if err := w.validateEnv(r.Spec.NodeJS.Env); err != nil {
257-
return warnings, err
258-
}
259-
if err := w.validateEnv(r.Spec.Python.Env); err != nil {
260-
return warnings, err
261-
}
262-
if err := w.validateEnv(r.Spec.DotNet.Env); err != nil {
263-
return warnings, err
264-
}
265-
if err := w.validateEnv(r.Spec.Go.Env); err != nil {
266-
return warnings, err
267-
}
268-
if err := w.validateEnv(r.Spec.ApacheHttpd.Env); err != nil {
269-
return warnings, err
270-
}
271-
if err := w.validateEnv(r.Spec.Nginx.Env); err != nil {
272-
return warnings, err
273-
}
274243
return warnings, nil
275244
}
276245

277-
func (w InstrumentationWebhook) validateEnv(envs []corev1.EnvVar) error {
278-
for _, env := range envs {
279-
if !strings.HasPrefix(env.Name, envPrefix) && !strings.HasPrefix(env.Name, envSplunkPrefix) {
280-
return fmt.Errorf("env name should start with \"OTEL_\" or \"SPLUNK_\": %s", env.Name)
281-
}
282-
}
283-
return nil
284-
}
285-
286246
func validateJaegerRemoteSamplerArgument(argument string) error {
287247
parts := strings.Split(argument, ",")
288248

0 commit comments

Comments
 (0)