@@ -16,12 +16,10 @@ import (
16
16
17
17
func configureExporter (exporter v1alpha1.Exporter , pod * corev1.Pod , container * corev1.Container ) {
18
18
if exporter .Endpoint != "" {
19
- if getIndexOfEnv (container .Env , constants .EnvOTELExporterOTLPEndpoint ) == - 1 {
20
- container .Env = append (container .Env , corev1.EnvVar {
21
- Name : constants .EnvOTELExporterOTLPEndpoint ,
22
- Value : exporter .Endpoint ,
23
- })
24
- }
19
+ container .Env = appendIfNotSet (container .Env , corev1.EnvVar {
20
+ Name : constants .EnvOTELExporterOTLPEndpoint ,
21
+ Value : exporter .Endpoint ,
22
+ })
25
23
}
26
24
if exporter .TLS == nil {
27
25
return
@@ -41,36 +39,30 @@ func configureExporter(exporter v1alpha1.Exporter, pod *corev1.Pod, container *c
41
39
if filepath .IsAbs (exporter .TLS .CA ) {
42
40
envVarVal = exporter .TLS .CA
43
41
}
44
- if getIndexOfEnv (container .Env , constants .EnvOTELExporterCertificate ) == - 1 {
45
- container .Env = append (container .Env , corev1.EnvVar {
46
- Name : constants .EnvOTELExporterCertificate ,
47
- Value : envVarVal ,
48
- })
49
- }
42
+ container .Env = appendIfNotSet (container .Env , corev1.EnvVar {
43
+ Name : constants .EnvOTELExporterCertificate ,
44
+ Value : envVarVal ,
45
+ })
50
46
}
51
47
if exporter .TLS .Cert != "" {
52
48
envVarVal := fmt .Sprintf ("%s/%s" , secretMountPath , exporter .TLS .Cert )
53
49
if filepath .IsAbs (exporter .TLS .Cert ) {
54
50
envVarVal = exporter .TLS .Cert
55
51
}
56
- if getIndexOfEnv (container .Env , constants .EnvOTELExporterClientCertificate ) == - 1 {
57
- container .Env = append (container .Env , corev1.EnvVar {
58
- Name : constants .EnvOTELExporterClientCertificate ,
59
- Value : envVarVal ,
60
- })
61
- }
52
+ container .Env = appendIfNotSet (container .Env , corev1.EnvVar {
53
+ Name : constants .EnvOTELExporterClientCertificate ,
54
+ Value : envVarVal ,
55
+ })
62
56
}
63
57
if exporter .TLS .Key != "" {
64
58
envVarVar := fmt .Sprintf ("%s/%s" , secretMountPath , exporter .TLS .Key )
65
59
if filepath .IsAbs (exporter .TLS .Key ) {
66
60
envVarVar = exporter .TLS .Key
67
61
}
68
- if getIndexOfEnv (container .Env , constants .EnvOTELExporterClientKey ) == - 1 {
69
- container .Env = append (container .Env , corev1.EnvVar {
70
- Name : constants .EnvOTELExporterClientKey ,
71
- Value : envVarVar ,
72
- })
73
- }
62
+ container .Env = appendIfNotSet (container .Env , corev1.EnvVar {
63
+ Name : constants .EnvOTELExporterClientKey ,
64
+ Value : envVarVar ,
65
+ })
74
66
}
75
67
76
68
if exporter .TLS .SecretName != "" {
0 commit comments