|
| 1 | +/* |
| 2 | +Copyright 2024 The Kubernetes authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package controller |
| 18 | + |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + |
| 22 | + "k8s.io/apimachinery/pkg/runtime" |
| 23 | + ctrl "sigs.k8s.io/controller-runtime" |
| 24 | + "sigs.k8s.io/controller-runtime/pkg/client" |
| 25 | + "sigs.k8s.io/controller-runtime/pkg/log" |
| 26 | +) |
| 27 | + |
| 28 | +// ConfigMapReconciler reconciles a ConfigMap object |
| 29 | +type ConfigMapReconciler struct { |
| 30 | + client.Client |
| 31 | + Scheme *runtime.Scheme |
| 32 | +} |
| 33 | + |
| 34 | +// +kubebuilder:rbac:groups=testproject.org,resources=configmaps,verbs=get;list;watch;create;update;patch;delete |
| 35 | +// +kubebuilder:rbac:groups=testproject.org,resources=configmaps/status,verbs=get;update;patch |
| 36 | +// +kubebuilder:rbac:groups=testproject.org,resources=configmaps/finalizers,verbs=update |
| 37 | + |
| 38 | +// Reconcile is part of the main kubernetes reconciliation loop which aims to |
| 39 | +// move the current state of the cluster closer to the desired state. |
| 40 | +// TODO(user): Modify the Reconcile function to compare the state specified by |
| 41 | +// the ConfigMap object against the actual cluster state, and then |
| 42 | +// perform operations to make the cluster state reflect the state specified by |
| 43 | +// the user. |
| 44 | +// |
| 45 | +// For more details, check Reconcile and its Result here: |
| 46 | +// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile |
| 47 | +func (r *ConfigMapReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { |
| 48 | + _ = log.FromContext(ctx) |
| 49 | + |
| 50 | + // TODO(user): your logic here |
| 51 | + |
| 52 | + return ctrl.Result{}, nil |
| 53 | +} |
| 54 | + |
| 55 | +// SetupWithManager sets up the controller with the Manager. |
| 56 | +func (r *ConfigMapReconciler) SetupWithManager(mgr ctrl.Manager) error { |
| 57 | + return ctrl.NewControllerManagedBy(mgr). |
| 58 | + // Uncomment the following line adding a pointer to an instance of the controlled resource as an argument |
| 59 | + // For(). |
| 60 | + Named("configmap"). |
| 61 | + Complete(r) |
| 62 | +} |
0 commit comments