Skip to content

Commit 28fedfd

Browse files
author
Danil-Grigorev
committed
Add internal controllers to public controller/alias.go
This change adds existing internal controller implementations into the `controller/alias.go` file. This is an initial step towards addressing issue #798, which aims to provide a public API for CAPI Operator providers. The current controller implementation is internal, and this change is a step towards organizing the internal structure, potentially in preparation for exposing parts of it or providing extension points for custom providers. Signed-off-by: Danil-Grigorev <[email protected]>
1 parent 4164a5f commit 28fedfd

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

controller/alias.go

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,52 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
/*
18+
Package controller provides aliases for internal controller types and functions
19+
to allow external users to interact with the core controller logic.
20+
*/
1721
package controller
1822

19-
import providercontroller "sigs.k8s.io/cluster-api-operator/internal/controller"
23+
import (
24+
"context"
25+
26+
"k8s.io/client-go/rest"
27+
internalcontroller "sigs.k8s.io/cluster-api-operator/internal/controller"
28+
"sigs.k8s.io/cluster-api-operator/internal/controller/genericprovider"
29+
internalhealthcheck "sigs.k8s.io/cluster-api-operator/internal/controller/healthcheck"
30+
ctrl "sigs.k8s.io/controller-runtime"
31+
"sigs.k8s.io/controller-runtime/pkg/client"
32+
"sigs.k8s.io/controller-runtime/pkg/controller"
33+
)
34+
35+
// GenericProviderReconciler wraps the internal GenericProviderReconciler.
36+
type GenericProviderReconciler struct {
37+
Provider genericprovider.GenericProvider
38+
ProviderList genericprovider.GenericProviderList
39+
Client client.Client
40+
Config *rest.Config
41+
WatchConfigSecretChanges bool
42+
}
43+
44+
// SetupWithManager sets up the GenericProviderReconciler with the Manager.
45+
func (r *GenericProviderReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
46+
return (&internalcontroller.GenericProviderReconciler{
47+
Provider: r.Provider,
48+
ProviderList: r.ProviderList,
49+
Client: r.Client,
50+
Config: r.Config,
51+
WatchConfigSecretChanges: r.WatchConfigSecretChanges,
52+
}).SetupWithManager(ctx, mgr, options)
53+
}
54+
55+
// ProviderHealthCheckReconciler wraps the internal ProviderHealthCheckReconciler.
56+
type ProviderHealthCheckReconciler struct {
57+
Client client.Client
58+
}
2059

21-
type GenericProviderReconciler = providercontroller.GenericProviderReconciler
60+
// SetupWithManager sets up the health check controllers with the Manager.
61+
func (r *ProviderHealthCheckReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
62+
return (&internalhealthcheck.ProviderHealthCheckReconciler{
63+
Client: r.Client,
64+
}).SetupWithManager(mgr, options)
65+
}

0 commit comments

Comments
 (0)