1313package devworkspace
1414
1515import (
16+ "context"
1617 "encoding/json"
1718 "fmt"
1819 "maps"
@@ -26,10 +27,12 @@ import (
2627 "github.com/eclipse-che/che-operator/pkg/common/reconciler"
2728 "github.com/eclipse-che/che-operator/pkg/common/utils"
2829 "github.com/eclipse-che/che-operator/pkg/deploy"
30+ "github.com/eclipse-che/che-operator/pkg/deploy/tls"
2931 v1 "k8s.io/api/apps/v1"
3032 corev1 "k8s.io/api/core/v1"
3133 "k8s.io/apimachinery/pkg/api/resource"
3234 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35+ "k8s.io/apimachinery/pkg/types"
3336 "k8s.io/utils/ptr"
3437 "sigs.k8s.io/controller-runtime/pkg/reconcile"
3538)
@@ -123,6 +126,10 @@ func updateWorkspaceConfig(ctx *chetypes.DeployContext, operatorConfig *controll
123126
124127 updateInitContainers (devEnvironments , operatorConfig .Workspace )
125128
129+ if err := updateTLSCertificateConfigmapRef (ctx , operatorConfig ); err != nil {
130+ return err
131+ }
132+
126133 // If the CheCluster has a configured proxy, or if the Che Operator has detected a proxy configuration,
127134 // we need to disable automatic proxy handling in the DevWorkspace Operator as its implementation collides
128135 // with ours -- they set environment variables the deployment spec explicitly, which overrides the proxy-settings
@@ -301,6 +308,39 @@ func updateInitContainers(devEnvironments *chev2.CheClusterDevEnvironments, work
301308 workspaceConfig .InitContainers = devEnvironments .InitContainers
302309}
303310
311+ func updateTLSCertificateConfigmapRef (ctx * chetypes.DeployContext , operatorConfig * controllerv1alpha1.OperatorConfiguration ) error {
312+ cm := & corev1.ConfigMap {}
313+ exists , err := ctx .ClusterAPI .ClientWrapper .GetIgnoreNotFound (
314+ context .TODO (),
315+ types.NamespacedName {
316+ Name : tls .CheMergedCABundleCertsCMName ,
317+ Namespace : ctx .CheCluster .Namespace ,
318+ },
319+ cm ,
320+ )
321+
322+ if err != nil {
323+ return fmt .Errorf ("failed to get ConfigMap %s: %w" , tls .CheMergedCABundleCertsCMName , err )
324+ }
325+
326+ if exists && len (cm .Data ) > 0 {
327+ if operatorConfig .Routing == nil {
328+ operatorConfig .Routing = & controllerv1alpha1.RoutingConfig {}
329+ }
330+
331+ operatorConfig .Routing .TLSCertificateConfigmapRef = & controllerv1alpha1.ConfigmapReference {
332+ Name : tls .CheMergedCABundleCertsCMName ,
333+ Namespace : ctx .CheCluster .Namespace ,
334+ }
335+ } else {
336+ if operatorConfig .Routing != nil {
337+ operatorConfig .Routing .TLSCertificateConfigmapRef = nil
338+ }
339+ }
340+
341+ return nil
342+ }
343+
304344func disableDWOProxy (routingConfig * controllerv1alpha1.RoutingConfig ) {
305345 // Since we create proxy configmaps to mount proxy settings, we want to disable
306346 // proxy handling in DWO; otherwise the env vars added by DWO will override the env
0 commit comments