Skip to content

Commit 3d91e5c

Browse files
committed
rename v2 MCP resource in controller
1 parent 66d04cd commit 3d91e5c

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

internal/controllers/managedcontrolplane/clusters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
libutils "github.com/openmcp-project/openmcp-operator/lib/utils"
1919
)
2020

21-
func (r *ManagedControlPlaneReconciler) deleteRelatedClusterRequests(ctx context.Context, mcp *corev2alpha1.ManagedControlPlane) (sets.Set[string], errutils.ReasonableError) {
21+
func (r *ManagedControlPlaneReconciler) deleteRelatedClusterRequests(ctx context.Context, mcp *corev2alpha1.ManagedControlPlaneV2) (sets.Set[string], errutils.ReasonableError) {
2222
log := logging.FromContextOrPanic(ctx)
2323

2424
// delete depending cluster requests, if any

internal/controllers/managedcontrolplane/controller.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type ManagedControlPlaneReconciler struct {
6565

6666
var _ reconcile.Reconciler = &ManagedControlPlaneReconciler{}
6767

68-
type ReconcileResult = ctrlutils.ReconcileResult[*corev2alpha1.ManagedControlPlane]
68+
type ReconcileResult = ctrlutils.ReconcileResult[*corev2alpha1.ManagedControlPlaneV2]
6969

7070
func (r *ManagedControlPlaneReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
7171
log := logging.FromContextOrPanic(ctx).WithName(ControllerName)
@@ -74,9 +74,9 @@ func (r *ManagedControlPlaneReconciler) Reconcile(ctx context.Context, req recon
7474
rr := r.reconcile(ctx, req)
7575

7676
// status update
77-
return ctrlutils.NewOpenMCPStatusUpdaterBuilder[*corev2alpha1.ManagedControlPlane]().
77+
return ctrlutils.NewOpenMCPStatusUpdaterBuilder[*corev2alpha1.ManagedControlPlaneV2]().
7878
WithNestedStruct("Status").
79-
WithPhaseUpdateFunc(func(obj *corev2alpha1.ManagedControlPlane, rr ctrlutils.ReconcileResult[*corev2alpha1.ManagedControlPlane]) (string, error) {
79+
WithPhaseUpdateFunc(func(obj *corev2alpha1.ManagedControlPlaneV2, rr ctrlutils.ReconcileResult[*corev2alpha1.ManagedControlPlaneV2]) (string, error) {
8080
if rr.Object != nil {
8181
if !rr.Object.DeletionTimestamp.IsZero() {
8282
return commonapi.StatusPhaseTerminating, nil
@@ -97,7 +97,7 @@ func (r *ManagedControlPlaneReconciler) Reconcile(ctx context.Context, req recon
9797
func (r *ManagedControlPlaneReconciler) reconcile(ctx context.Context, req reconcile.Request) ReconcileResult {
9898
log := logging.FromContextOrPanic(ctx)
9999
// get ManagedControlPlane resource
100-
mcp := &corev2alpha1.ManagedControlPlane{}
100+
mcp := &corev2alpha1.ManagedControlPlaneV2{}
101101
if err := r.OnboardingCluster.Client().Get(ctx, req.NamespacedName, mcp); err != nil {
102102
if apierrors.IsNotFound(err) {
103103
log.Info("Resource not found")
@@ -138,12 +138,12 @@ func (r *ManagedControlPlaneReconciler) SetupWithManager(mgr ctrl.Manager) error
138138
return ctrl.NewControllerManagedBy(mgr).
139139
Named(strings.ToLower(ControllerName)).
140140
// watch ManagedControlPlane resources on the Onboarding cluster
141-
WatchesRawSource(source.Kind(r.OnboardingCluster.Cluster().GetCache(), &corev2alpha1.ManagedControlPlane{}, handler.TypedEnqueueRequestsFromMapFunc(func(ctx context.Context, obj *corev2alpha1.ManagedControlPlane) []ctrl.Request {
141+
WatchesRawSource(source.Kind(r.OnboardingCluster.Cluster().GetCache(), &corev2alpha1.ManagedControlPlaneV2{}, handler.TypedEnqueueRequestsFromMapFunc(func(ctx context.Context, obj *corev2alpha1.ManagedControlPlaneV2) []ctrl.Request {
142142
if obj == nil {
143143
return nil
144144
}
145145
return []ctrl.Request{testutils.RequestFromObject(obj)}
146-
}), ctrlutils.ToTypedPredicate[*corev2alpha1.ManagedControlPlane](predicate.And(
146+
}), ctrlutils.ToTypedPredicate[*corev2alpha1.ManagedControlPlaneV2](predicate.And(
147147
predicate.Or(
148148
predicate.GenerationChangedPredicate{},
149149
ctrlutils.DeletionTimestampChangedPredicate{},
@@ -157,7 +157,7 @@ func (r *ManagedControlPlaneReconciler) SetupWithManager(mgr ctrl.Manager) error
157157
Complete(r)
158158
}
159159

160-
func (r *ManagedControlPlaneReconciler) handleCreateOrUpdate(ctx context.Context, mcp *corev2alpha1.ManagedControlPlane) ReconcileResult {
160+
func (r *ManagedControlPlaneReconciler) handleCreateOrUpdate(ctx context.Context, mcp *corev2alpha1.ManagedControlPlaneV2) ReconcileResult {
161161
log := logging.FromContextOrPanic(ctx)
162162
log.Info("Handling creation or update of ManagedControlPlane resource")
163163

@@ -238,7 +238,7 @@ func (r *ManagedControlPlaneReconciler) handleCreateOrUpdate(ctx context.Context
238238
return rr
239239
}
240240

241-
func (r *ManagedControlPlaneReconciler) handleDelete(ctx context.Context, mcp *corev2alpha1.ManagedControlPlane) ReconcileResult {
241+
func (r *ManagedControlPlaneReconciler) handleDelete(ctx context.Context, mcp *corev2alpha1.ManagedControlPlaneV2) ReconcileResult {
242242
log := logging.FromContextOrPanic(ctx)
243243
log.Info("Handling deletion of ManagedControlPlane resource")
244244

internal/controllers/managedcontrolplane/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var _ = Describe("ManagedControlPlane Controller", func() {
8585
It("should correctly handle the creation, update, and deletion flow for MCP resources", func() {
8686
rec, env := defaultTestSetup("testdata", "test-01")
8787

88-
mcp := &corev2alpha1.ManagedControlPlane{}
88+
mcp := &corev2alpha1.ManagedControlPlaneV2{}
8989
mcp.SetName("mcp-01")
9090
mcp.SetNamespace("test")
9191
Expect(env.Client(onboarding).Get(env.Ctx, client.ObjectKeyFromObject(mcp), mcp)).To(Succeed())

internal/controllers/managedcontrolplane/services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
// deleteDependingServices deletes service resources that belong to service providers which have a 'services.openmcp.cloud/<name>' finalizer on the ManagedControlPlane.
2222
// It returns a set of service provider names for which still resources exist (should be in deletion by the time this function returns) and the total number of resources that are still left.
2323
// Deletion of the MCP should wait until the set is empty and the count is zero.
24-
func (r *ManagedControlPlaneReconciler) deleteDependingServices(ctx context.Context, mcp *corev2alpha1.ManagedControlPlane) (map[string][]*unstructured.Unstructured, errutils.ReasonableError) {
24+
func (r *ManagedControlPlaneReconciler) deleteDependingServices(ctx context.Context, mcp *corev2alpha1.ManagedControlPlaneV2) (map[string][]*unstructured.Unstructured, errutils.ReasonableError) {
2525
log := logging.FromContextOrPanic(ctx)
2626

2727
// delete depending service resources, if any

0 commit comments

Comments
 (0)