diff --git a/controllers/backplaneconfig_controller.go b/controllers/backplaneconfig_controller.go index 09f0346d..be0f8755 100644 --- a/controllers/backplaneconfig_controller.go +++ b/controllers/backplaneconfig_controller.go @@ -69,14 +69,15 @@ import ( // MultiClusterEngineReconciler reconciles a MultiClusterEngine object type MultiClusterEngineReconciler struct { - Client client.Client - UncachedClient client.Client - CacheSpec CacheSpec - Scheme *runtime.Scheme - Images map[string]string - StatusManager *status.StatusTracker - Log logr.Logger - UpgradeableCond utils.Condition + Client client.Client + UncachedClient client.Client + CacheSpec CacheSpec + Scheme *runtime.Scheme + Images map[string]string + StatusManager *status.StatusTracker + Log logr.Logger + UpgradeableCond utils.Condition + DeprecatedSpecFields map[string]bool } const ( @@ -182,6 +183,9 @@ func (r *MultiClusterEngineReconciler) Reconcile(ctx context.Context, req ctrl.R backplaneConfig.Status.Conditions = status.FilterOutConditionWithSubString(backplaneConfig.Status.Conditions, backplanev1.MultiClusterEngineComponentFailure) + // Check if any deprecated fields are present within the backplaneConfig spec. + r.CheckDeprecatedFieldUsage(backplaneConfig) + // reset status manager r.StatusManager.Reset("") for _, c := range backplaneConfig.Status.Conditions { @@ -1655,6 +1659,24 @@ func (r *MultiClusterEngineReconciler) StopScheduleOperatorControllerResync() { } } +func (r *MultiClusterEngineReconciler) CheckDeprecatedFieldUsage(m *backplanev1.MultiClusterEngine) { + deprecatedSpecFields := []struct { + name string + isPresent bool + }{} + + if r.DeprecatedSpecFields == nil { + r.DeprecatedSpecFields = make(map[string]bool) + } + + for _, f := range deprecatedSpecFields { + if f.isPresent && !r.DeprecatedSpecFields[f.name] { + r.Log.Info(fmt.Sprintf("Warning: %s field usage is deprecated in operator.", f.name)) + r.DeprecatedSpecFields[f.name] = true + } + } +} + func ensureCRD(ctx context.Context, c client.Client, crd *unstructured.Unstructured) error { existingCRD := &unstructured.Unstructured{} existingCRD.SetGroupVersionKind(crd.GroupVersionKind())