@@ -17,6 +17,7 @@ package manager
1717import (
1818 "context"
1919 "fmt"
20+ "maps"
2021 "math"
2122 "path/filepath"
2223 "strings"
@@ -472,47 +473,39 @@ func setOtelCommonFieldsDefaults(otelCommonFields *otelv1beta1.OpenTelemetryComm
472473 otelCommonFields = & otelv1beta1.OpenTelemetryCommonFields {}
473474 }
474475
475- otelCommonFields .Image = axoflowOtelCollectorImageRef
476+ if otelCommonFields .Image == "" {
477+ otelCommonFields .Image = axoflowOtelCollectorImageRef
478+ }
479+
476480 otelCommonFields .ServiceAccount = saName
477481
478482 if otelCommonFields .Args == nil {
479483 otelCommonFields .Args = make (map [string ]string )
480484 }
481- for key , value := range additionalArgs {
482- otelCommonFields .Args [key ] = value
483- }
484-
485- volumeMounts := []corev1.VolumeMount {
486- {
487- Name : "varlog" ,
488- ReadOnly : true ,
489- MountPath : "/var/log" ,
490- },
491- {
492- Name : "varlibdockercontainers" ,
493- ReadOnly : true ,
494- MountPath : "/var/lib/docker/containers" ,
495- },
496- }
497- otelCommonFields .VolumeMounts = append (otelCommonFields .VolumeMounts , volumeMounts ... )
498-
499- volumes := []corev1.Volume {
500- {
501- Name : "varlog" ,
502- VolumeSource : corev1.VolumeSource {
503- HostPath : & corev1.HostPathVolumeSource {
504- Path : "/var/log" ,
485+ maps .Copy (otelCommonFields .Args , additionalArgs )
486+
487+ volumeConfigs := []struct {
488+ name string
489+ path string
490+ }{
491+ {name : "varlog" , path : "/var/log" },
492+ {name : "varlibdockercontainers" , path : "/var/lib/docker/containers" },
493+ }
494+ for _ , config := range volumeConfigs {
495+ if ! volumeExists (otelCommonFields .Volumes , config .name ) {
496+ otelCommonFields .Volumes = append (otelCommonFields .Volumes , corev1.Volume {
497+ Name : config .name ,
498+ VolumeSource : corev1.VolumeSource {
499+ HostPath : & corev1.HostPathVolumeSource {
500+ Path : config .path ,
501+ },
505502 },
506- },
507- },
508- {
509- Name : "varlibdockercontainers" ,
510- VolumeSource : corev1.VolumeSource {
511- HostPath : & corev1.HostPathVolumeSource {
512- Path : "/var/lib/docker/containers" ,
513- },
514- },
515- },
503+ })
504+ otelCommonFields .VolumeMounts = append (otelCommonFields .VolumeMounts , corev1.VolumeMount {
505+ Name : config .name ,
506+ ReadOnly : true ,
507+ MountPath : config .path ,
508+ })
509+ }
516510 }
517- otelCommonFields .Volumes = append (otelCommonFields .Volumes , volumes ... )
518511}
0 commit comments