Skip to content

Commit 9f16d57

Browse files
committed
Moved mTLS file naming consts
1 parent f14821f commit 9f16d57

File tree

8 files changed

+21
-36
lines changed

8 files changed

+21
-36
lines changed

internal/manifests/collector/configmap.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils"
2626
ta "github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator/adapters"
2727
"github.com/open-telemetry/opentelemetry-operator/internal/naming"
28+
"github.com/open-telemetry/opentelemetry-operator/pkg/constants"
2829
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
2930
)
3031

@@ -46,9 +47,9 @@ func ConfigMap(params manifests.Params) (*corev1.ConfigMap, error) {
4647

4748
if params.Config.CertManagerAvailability() == certmanager.Available && featuregate.EnableTargetAllocatorMTLS.IsEnabled() {
4849
replaceCfgOpts = append(replaceCfgOpts, ta.WithTLSConfig(
49-
filepath.Join(manifestutils.TLSDirPath, manifestutils.CAFileName),
50-
filepath.Join(manifestutils.TLSDirPath, manifestutils.TLSCertFileName),
51-
filepath.Join(manifestutils.TLSDirPath, manifestutils.TLSKeyFileName),
50+
filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorCAFileName),
51+
filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorTLSCertFileName),
52+
filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorTLSKeyFileName),
5253
naming.TAService(params.OtelCol.Name)),
5354
)
5455
}

internal/manifests/collector/container.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import (
2929
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/certmanager"
3030
"github.com/open-telemetry/opentelemetry-operator/internal/config"
3131
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters"
32-
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils"
3332
"github.com/open-telemetry/opentelemetry-operator/internal/naming"
33+
"github.com/open-telemetry/opentelemetry-operator/pkg/constants"
3434
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
3535
)
3636

@@ -97,7 +97,7 @@ func Container(cfg config.Config, logger logr.Logger, otelcol v1beta1.OpenTeleme
9797
volumeMounts = append(volumeMounts,
9898
corev1.VolumeMount{
9999
Name: naming.TAClientCertificate(otelcol.Name),
100-
MountPath: manifestutils.TLSDirPath,
100+
MountPath: constants.TACollectorTLSDirPath,
101101
})
102102
}
103103

internal/manifests/collector/container_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/certmanager"
3131
"github.com/open-telemetry/opentelemetry-operator/internal/config"
3232
. "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector"
33-
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils"
3433
"github.com/open-telemetry/opentelemetry-operator/internal/naming"
34+
"github.com/open-telemetry/opentelemetry-operator/pkg/constants"
3535
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
3636
)
3737

@@ -881,6 +881,6 @@ func TestContainerWithCertManagerAvailable(t *testing.T) {
881881
// verify
882882
assert.Contains(t, c.VolumeMounts, corev1.VolumeMount{
883883
Name: naming.TAClientCertificate(""),
884-
MountPath: manifestutils.TLSDirPath,
884+
MountPath: constants.TACollectorTLSDirPath,
885885
})
886886
}

internal/manifests/manifestutils/utils.go

-22
This file was deleted.

internal/manifests/targetallocator/configmap.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils"
2929
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator/adapters"
3030
"github.com/open-telemetry/opentelemetry-operator/internal/naming"
31+
"github.com/open-telemetry/opentelemetry-operator/pkg/constants"
3132
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
3233
)
3334

@@ -110,9 +111,9 @@ func ConfigMap(params Params) (*corev1.ConfigMap, error) {
110111
taConfig["https"] = map[string]interface{}{
111112
"enabled": true,
112113
"listen_addr": ":8443",
113-
"ca_file_path": filepath.Join(manifestutils.TLSDirPath, manifestutils.CAFileName),
114-
"tls_cert_file_path": filepath.Join(manifestutils.TLSDirPath, manifestutils.TLSCertFileName),
115-
"tls_key_file_path": filepath.Join(manifestutils.TLSDirPath, manifestutils.TLSKeyFileName),
114+
"ca_file_path": filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorCAFileName),
115+
"tls_cert_file_path": filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorTLSCertFileName),
116+
"tls_key_file_path": filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorTLSKeyFileName),
116117
}
117118
}
118119

internal/manifests/targetallocator/container.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import (
2626
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
2727
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/certmanager"
2828
"github.com/open-telemetry/opentelemetry-operator/internal/config"
29-
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils"
3029
"github.com/open-telemetry/opentelemetry-operator/internal/naming"
30+
"github.com/open-telemetry/opentelemetry-operator/pkg/constants"
3131
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
3232
)
3333

@@ -138,7 +138,7 @@ func Container(cfg config.Config, logger logr.Logger, instance v1alpha1.TargetAl
138138
})
139139
volumeMounts = append(volumeMounts, corev1.VolumeMount{
140140
Name: naming.TAServerCertificate(instance.Name),
141-
MountPath: manifestutils.TLSDirPath,
141+
MountPath: constants.TACollectorTLSDirPath,
142142
})
143143
}
144144

internal/manifests/targetallocator/container_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
3131
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/certmanager"
3232
"github.com/open-telemetry/opentelemetry-operator/internal/config"
33-
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils"
3433
"github.com/open-telemetry/opentelemetry-operator/internal/naming"
34+
"github.com/open-telemetry/opentelemetry-operator/pkg/constants"
3535
"github.com/open-telemetry/opentelemetry-operator/pkg/featuregate"
3636
)
3737

@@ -409,7 +409,7 @@ func TestContainerWithCertManagerAvailable(t *testing.T) {
409409

410410
assert.Contains(t, c.VolumeMounts, corev1.VolumeMount{
411411
Name: naming.TAServerCertificate(""),
412-
MountPath: manifestutils.TLSDirPath,
412+
MountPath: constants.TACollectorTLSDirPath,
413413
})
414414
}
415415

pkg/constants/env.go

+5
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ const (
4646
FlagNginx = "enable-nginx-instrumentation"
4747
FlagNodeJS = "enable-nodejs-instrumentation"
4848
FlagJava = "enable-java-instrumentation"
49+
50+
TACollectorTLSDirPath = "/tls"
51+
TACollectorCAFileName = "ca.crt"
52+
TACollectorTLSKeyFileName = "tls.key"
53+
TACollectorTLSCertFileName = "tls.crt"
4954
)

0 commit comments

Comments
 (0)