Skip to content

Commit

Permalink
Moved mTLS file naming consts
Browse files Browse the repository at this point in the history
  • Loading branch information
ItielOlenick committed Sep 25, 2024
1 parent f14821f commit 9f16d57
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 36 deletions.
7 changes: 4 additions & 3 deletions internal/manifests/collector/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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)),
)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/manifests/collector/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
})
}

Expand Down
4 changes: 2 additions & 2 deletions internal/manifests/collector/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
})
}
22 changes: 0 additions & 22 deletions internal/manifests/manifestutils/utils.go

This file was deleted.

7 changes: 4 additions & 3 deletions internal/manifests/targetallocator/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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),
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/manifests/targetallocator/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
})
}

Expand Down
4 changes: 2 additions & 2 deletions internal/manifests/targetallocator/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
})
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/constants/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

0 comments on commit 9f16d57

Please sign in to comment.