@@ -22,8 +22,6 @@ import (
2222 "errors"
2323 "fmt"
2424 "io"
25- "os"
26- "path/filepath"
2725 "sort"
2826 "strings"
2927 "sync"
@@ -75,6 +73,7 @@ import (
7573 catalogfilter "github.com/operator-framework/operator-controller/internal/catalogmetadata/filter"
7674 catalogsort "github.com/operator-framework/operator-controller/internal/catalogmetadata/sort"
7775 "github.com/operator-framework/operator-controller/internal/conditionsets"
76+ "github.com/operator-framework/operator-controller/internal/httputil"
7877 "github.com/operator-framework/operator-controller/internal/labels"
7978)
8079
@@ -533,7 +532,7 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundle *catalogmetad
533532}
534533
535534func (r * ClusterExtensionReconciler ) generateBundleDeploymentForUnpack (ctx context.Context , bundlePath string , ce * ocv1alpha1.ClusterExtension ) * rukpakv1alpha2.BundleDeployment {
536- certData , err := r . getCertificateData ( ce )
535+ certData , err := httputil . LoadCerts ( r . CaCertDir )
537536 if err != nil {
538537 log .FromContext (ctx ).WithName ("operator-controller" ).WithValues ("cluster-extension" , ce .GetName ()).Error (err , "unable to get TLS certificate" )
539538 }
@@ -560,29 +559,6 @@ func (r *ClusterExtensionReconciler) generateBundleDeploymentForUnpack(ctx conte
560559 }
561560}
562561
563- func (r * ClusterExtensionReconciler ) getCertificateData (ce * ocv1alpha1.ClusterExtension ) (string , error ) {
564- if r .CaCertDir == "" {
565- return "" , nil
566- }
567-
568- var certs []string
569- err := filepath .Walk (r .CaCertDir , func (path string , info os.FileInfo , err error ) error {
570- if info .IsDir () {
571- return nil
572- }
573- data , err := os .ReadFile (path )
574- if err != nil {
575- return err
576- }
577- certs = append (certs , string (data ))
578- return nil
579- })
580- if err != nil {
581- return "" , err
582- }
583- return strings .Join (certs , "\n " ), nil
584- }
585-
586562// SetupWithManager sets up the controller with the Manager.
587563func (r * ClusterExtensionReconciler ) SetupWithManager (mgr ctrl.Manager ) error {
588564 controller , err := ctrl .NewControllerManagedBy (mgr ).
0 commit comments