Skip to content

Commit 10eec12

Browse files
authored
chore: Configure DWO with tlsCertificateConfigmapRef when certificates imported to che-operator (#2146)
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
1 parent cd0093d commit 10eec12

17 files changed

Lines changed: 4138 additions & 3451 deletions

bundle/next/eclipse-che/manifests/che-operator.clusterserviceversion.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ metadata:
8686
categories: Developer Tools
8787
certified: "false"
8888
containerImage: quay.io/eclipse/che-operator:next
89-
createdAt: "2026-06-16T14:03:55Z"
89+
createdAt: "2026-06-23T10:08:27Z"
9090
description: A Kube-native development solution that delivers portable and collaborative
9191
developer workspaces.
9292
features.operators.openshift.io/cnf: "false"
@@ -108,7 +108,7 @@ metadata:
108108
operatorframework.io/arch.amd64: supported
109109
operatorframework.io/arch.arm64: supported
110110
operatorframework.io/os.linux: supported
111-
name: eclipse-che.v7.119.0-990.next
111+
name: eclipse-che.v7.120.0-991.next
112112
namespace: placeholder
113113
spec:
114114
apiservicedefinitions: {}
@@ -1153,7 +1153,7 @@ spec:
11531153
name: gateway-authorization-sidecar
11541154
- image: quay.io/che-incubator/header-rewrite-proxy:latest
11551155
name: gateway-header-sidecar
1156-
version: 7.119.0-990.next
1156+
version: 7.120.0-991.next
11571157
webhookdefinitions:
11581158
- admissionReviewVersions:
11591159
- v1

controllers/workspaceconfig/workspaces_config_controller_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
"testing"
1919

2020
"github.com/eclipse-che/che-operator/controllers/namespacecache"
21-
"github.com/eclipse-che/che-operator/pkg/common/diffs"
22-
"github.com/google/go-cmp/cmp"
2321
"k8s.io/apimachinery/pkg/api/errors"
2422

2523
rbacv1 "k8s.io/api/rbac/v1"
@@ -84,10 +82,9 @@ func TestCreate(t *testing.T) {
8482
assert.NoError(t, err)
8583

8684
dstCm := &corev1.ConfigMap{}
87-
exists, err := deploy.Get(ctx, types.NamespacedName{Namespace: "user-che", Name: "test"}, dstCm)
85+
err = ctx.ClusterAPI.Client.Get(context.TODO(), types.NamespacedName{Namespace: "user-che", Name: "test"}, dstCm)
8886

8987
assert.NoError(t, err)
90-
assert.True(t, exists)
9188
assert.Equal(t, 1, len(dstCm.Data))
9289
assert.Equal(t, "new-value", dstCm.Data["key"])
9390
}
@@ -141,7 +138,8 @@ func TestUpdate(t *testing.T) {
141138
err = ctx.ClusterAPI.Client.Get(context.TODO(), types.NamespacedName{Name: "test", Namespace: "eclipse-che"}, srcCm)
142139

143140
assert.NoError(t, err)
144-
assert.True(t, cmp.Equal(dstCm, srcCm, diffs.ConfigMap([]string{constants.KubernetesPartOfLabelKey, constants.KubernetesComponentLabelKey}, nil)))
141+
assert.Equal(t, srcCm.Labels[constants.KubernetesPartOfLabelKey], dstCm.Labels[constants.KubernetesPartOfLabelKey])
142+
assert.Equal(t, srcCm.Labels[constants.KubernetesComponentLabelKey], dstCm.Labels[constants.KubernetesComponentLabelKey])
145143

146144
// update source and destination config maps
147145

pkg/common/diffs/diffs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,19 @@ var ConfigMapEnsureLabels = cmp.Options{
5151
}),
5252
}
5353

54-
func ConfigMap(labels []string, annotations []string) cmp.Options {
54+
// ConfigMap respects existed labels and annotations
55+
func ConfigMap(labelKeys []string, annotationKeys []string) cmp.Options {
5556
return cmp.Options{
5657
cmpopts.IgnoreFields(corev1.ConfigMap{}, "TypeMeta"),
57-
objectMetaComparator(labels, annotations),
58+
cmpMetadata(labelKeys, annotationKeys),
5859
}
5960
}
6061

6162
var ServiceMonitor = cmp.Options{
6263
cmpopts.IgnoreFields(monitoringv1.ServiceMonitor{}, "TypeMeta", "ObjectMeta"),
6364
}
6465

65-
func objectMetaComparator(labels []string, annotations []string) cmp.Option {
66+
func cmpMetadata(labels []string, annotations []string) cmp.Option {
6667
return cmp.Comparer(func(x, y metav1.ObjectMeta) bool {
6768
for _, label := range labels {
6869
if x.Labels[label] != y.Labels[label] {

pkg/deploy/devworkspace/dev_workspace_config.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package devworkspace
1414

1515
import (
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+
304344
func 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

Comments
 (0)