Skip to content

Commit 66ee28b

Browse files
committed
fixup! Inject certificate to http client from a configmap referenced in the config
Signed-off-by: ivinokur <[email protected]>
1 parent c850c63 commit 66ee28b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

controllers/workspace/devworkspace_controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818
import (
1919
"context"
2020
"fmt"
21+
"net/http"
2122
"strconv"
2223
"strings"
2324
"time"
@@ -27,6 +28,7 @@ import (
2728
"github.com/devfile/devworkspace-operator/controllers/workspace/metrics"
2829
"github.com/devfile/devworkspace-operator/pkg/common"
2930
"github.com/devfile/devworkspace-operator/pkg/conditions"
31+
"github.com/devfile/devworkspace-operator/pkg/config"
3032
wkspConfig "github.com/devfile/devworkspace-operator/pkg/config"
3133
"github.com/devfile/devworkspace-operator/pkg/constants"
3234
"github.com/devfile/devworkspace-operator/pkg/dwerrors"
@@ -142,7 +144,12 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
142144
reqLogger = reqLogger.WithValues(constants.DevWorkspaceIDLoggerKey, workspace.Status.DevWorkspaceId)
143145
reqLogger.Info("Reconciling Workspace", "resolvedConfig", configString)
144146

145-
setupHttpClients(r.Client, config, r.Log)
147+
// Inject ca certificates to the http clint if the certificates configmap is created and defined in the config.
148+
if certs, ok := readCertificates(r.Client, config, r.Log); ok {
149+
for _, certsPem := range certs {
150+
injectCertificates([]byte(certsPem), httpClient.Transport.(*http.Transport))
151+
}
152+
}
146153

147154
// Check if the DevWorkspaceRouting instance is marked to be deleted, which is
148155
// indicated by the deletion timestamp being set.
@@ -670,6 +677,8 @@ func (r *DevWorkspaceReconciler) getWorkspaceId(ctx context.Context, workspace *
670677
}
671678

672679
func (r *DevWorkspaceReconciler) SetupWithManager(mgr ctrl.Manager) error {
680+
setupHttpClients(mgr.GetClient(), config.GetGlobalConfig(), mgr.GetLogger())
681+
673682
maxConcurrentReconciles, err := wkspConfig.GetMaxConcurrentReconciles()
674683
if err != nil {
675684
return err

0 commit comments

Comments
 (0)