diff --git a/internal/manifests/collector/configmap.go b/internal/manifests/collector/configmap.go index f6adbbdb9a..b611dea178 100644 --- a/internal/manifests/collector/configmap.go +++ b/internal/manifests/collector/configmap.go @@ -25,6 +25,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" ta "github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator/adapters" "github.com/open-telemetry/opentelemetry-operator/internal/naming" + "github.com/open-telemetry/opentelemetry-operator/pkg/constants" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -46,9 +47,9 @@ func ConfigMap(params manifests.Params) (*corev1.ConfigMap, error) { if params.Config.CertManagerAvailability() == certmanager.Available && featuregate.EnableTargetAllocatorMTLS.IsEnabled() { replaceCfgOpts = append(replaceCfgOpts, ta.WithTLSConfig( - filepath.Join(manifestutils.TLSDirPath, manifestutils.CAFileName), - filepath.Join(manifestutils.TLSDirPath, manifestutils.TLSCertFileName), - filepath.Join(manifestutils.TLSDirPath, manifestutils.TLSKeyFileName), + filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorCAFileName), + filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorTLSCertFileName), + filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorTLSKeyFileName), naming.TAService(params.OtelCol.Name)), ) } diff --git a/internal/manifests/collector/container.go b/internal/manifests/collector/container.go index b595e331f9..e7b131d571 100644 --- a/internal/manifests/collector/container.go +++ b/internal/manifests/collector/container.go @@ -29,8 +29,8 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/certmanager" "github.com/open-telemetry/opentelemetry-operator/internal/config" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector/adapters" - "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" "github.com/open-telemetry/opentelemetry-operator/internal/naming" + "github.com/open-telemetry/opentelemetry-operator/pkg/constants" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -97,7 +97,7 @@ func Container(cfg config.Config, logger logr.Logger, otelcol v1beta1.OpenTeleme volumeMounts = append(volumeMounts, corev1.VolumeMount{ Name: naming.TAClientCertificate(otelcol.Name), - MountPath: manifestutils.TLSDirPath, + MountPath: constants.TACollectorTLSDirPath, }) } diff --git a/internal/manifests/collector/container_test.go b/internal/manifests/collector/container_test.go index 39a9cd808d..3f48fc26da 100644 --- a/internal/manifests/collector/container_test.go +++ b/internal/manifests/collector/container_test.go @@ -30,8 +30,8 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/certmanager" "github.com/open-telemetry/opentelemetry-operator/internal/config" . "github.com/open-telemetry/opentelemetry-operator/internal/manifests/collector" - "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" "github.com/open-telemetry/opentelemetry-operator/internal/naming" + "github.com/open-telemetry/opentelemetry-operator/pkg/constants" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -881,6 +881,6 @@ func TestContainerWithCertManagerAvailable(t *testing.T) { // verify assert.Contains(t, c.VolumeMounts, corev1.VolumeMount{ Name: naming.TAClientCertificate(""), - MountPath: manifestutils.TLSDirPath, + MountPath: constants.TACollectorTLSDirPath, }) } diff --git a/internal/manifests/manifestutils/utils.go b/internal/manifests/manifestutils/utils.go deleted file mode 100644 index 7fdb0ef1c3..0000000000 --- a/internal/manifests/manifestutils/utils.go +++ /dev/null @@ -1,22 +0,0 @@ -// 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 manifestutils - -const ( - TLSDirPath = "/tls" - CAFileName = "ca.crt" - TLSKeyFileName = "tls.key" - TLSCertFileName = "tls.crt" -) diff --git a/internal/manifests/targetallocator/configmap.go b/internal/manifests/targetallocator/configmap.go index 36439cd024..b17df29151 100644 --- a/internal/manifests/targetallocator/configmap.go +++ b/internal/manifests/targetallocator/configmap.go @@ -28,6 +28,7 @@ import ( "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" "github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator/adapters" "github.com/open-telemetry/opentelemetry-operator/internal/naming" + "github.com/open-telemetry/opentelemetry-operator/pkg/constants" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -110,9 +111,9 @@ func ConfigMap(params Params) (*corev1.ConfigMap, error) { taConfig["https"] = map[string]interface{}{ "enabled": true, "listen_addr": ":8443", - "ca_file_path": filepath.Join(manifestutils.TLSDirPath, manifestutils.CAFileName), - "tls_cert_file_path": filepath.Join(manifestutils.TLSDirPath, manifestutils.TLSCertFileName), - "tls_key_file_path": filepath.Join(manifestutils.TLSDirPath, manifestutils.TLSKeyFileName), + "ca_file_path": filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorCAFileName), + "tls_cert_file_path": filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorTLSCertFileName), + "tls_key_file_path": filepath.Join(constants.TACollectorTLSDirPath, constants.TACollectorTLSKeyFileName), } } diff --git a/internal/manifests/targetallocator/container.go b/internal/manifests/targetallocator/container.go index 7fc472b3db..f1e5e78bbc 100644 --- a/internal/manifests/targetallocator/container.go +++ b/internal/manifests/targetallocator/container.go @@ -26,8 +26,8 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1" "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/certmanager" "github.com/open-telemetry/opentelemetry-operator/internal/config" - "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" "github.com/open-telemetry/opentelemetry-operator/internal/naming" + "github.com/open-telemetry/opentelemetry-operator/pkg/constants" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -138,7 +138,7 @@ func Container(cfg config.Config, logger logr.Logger, instance v1alpha1.TargetAl }) volumeMounts = append(volumeMounts, corev1.VolumeMount{ Name: naming.TAServerCertificate(instance.Name), - MountPath: manifestutils.TLSDirPath, + MountPath: constants.TACollectorTLSDirPath, }) } diff --git a/internal/manifests/targetallocator/container_test.go b/internal/manifests/targetallocator/container_test.go index 65b79f6ff7..7ce57d4257 100644 --- a/internal/manifests/targetallocator/container_test.go +++ b/internal/manifests/targetallocator/container_test.go @@ -30,8 +30,8 @@ import ( "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1" "github.com/open-telemetry/opentelemetry-operator/internal/autodetect/certmanager" "github.com/open-telemetry/opentelemetry-operator/internal/config" - "github.com/open-telemetry/opentelemetry-operator/internal/manifests/manifestutils" "github.com/open-telemetry/opentelemetry-operator/internal/naming" + "github.com/open-telemetry/opentelemetry-operator/pkg/constants" "github.com/open-telemetry/opentelemetry-operator/pkg/featuregate" ) @@ -409,7 +409,7 @@ func TestContainerWithCertManagerAvailable(t *testing.T) { assert.Contains(t, c.VolumeMounts, corev1.VolumeMount{ Name: naming.TAServerCertificate(""), - MountPath: manifestutils.TLSDirPath, + MountPath: constants.TACollectorTLSDirPath, }) } diff --git a/pkg/constants/env.go b/pkg/constants/env.go index 45d0a82982..a3e6922c4a 100644 --- a/pkg/constants/env.go +++ b/pkg/constants/env.go @@ -46,4 +46,9 @@ const ( FlagNginx = "enable-nginx-instrumentation" FlagNodeJS = "enable-nodejs-instrumentation" FlagJava = "enable-java-instrumentation" + + TACollectorTLSDirPath = "/tls" + TACollectorCAFileName = "ca.crt" + TACollectorTLSKeyFileName = "tls.key" + TACollectorTLSCertFileName = "tls.crt" )