Basic code for main and controller.
[ric-plt/ric-dep.git] / depRicKubernetesOperator / internal / controller / ricplatform_controller.go
1 /*
2 ==================================================================================
3
4         Copyright (c) 2023 Samsung
5
6          Licensed under the Apache License, Version 2.0 (the "License");
7          you may not use this file except in compliance with the License.
8          You may obtain a copy of the License at
9
10              http://www.apache.org/licenses/LICENSE-2.0
11
12          Unless required by applicable law or agreed to in writing, software
13          distributed under the License is distributed on an "AS IS" BASIS,
14          WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15          See the License for the specific language governing permissions and
16          limitations under the License.
17
18          This source code is part of the near-RT RIC (RAN Intelligent Controller)
19          platform project (RICP).
20
21 ==================================================================================
22 */
23 package controller
24
25 import (
26         "context"
27
28         "k8s.io/apimachinery/pkg/runtime"
29         ctrl "sigs.k8s.io/controller-runtime"
30         "sigs.k8s.io/controller-runtime/pkg/client"
31
32         ricdeployv1 "ricdeploy/api/v1"
33 )
34
35 // RicPlatformReconciler reconciles a RicPlatform object
36 type RicPlatformReconciler struct {
37         client.Client
38         Scheme *runtime.Scheme
39 }
40
41 //+kubebuilder:rbac:groups=ricdeploy.ricplt.com,resources=ricplatforms,verbs=get;list;watch;create;update;patch;delete
42 //+kubebuilder:rbac:groups=ricdeploy.ricplt.com,resources=ricplatforms/status,verbs=get;update;patch
43 //+kubebuilder:rbac:groups=ricdeploy.ricplt.com,resources=ricplatforms/finalizers,verbs=update
44
45 // Reconcile is part of the main kubernetes reconciliation loop which aims to
46 // move the current state of the cluster closer to the desired state.
47 // TODO(user): Modify the Reconcile function to compare the state specified by
48 // the RicPlatform object against the actual cluster state, and then
49 // perform operations to make the cluster state reflect the state specified by
50 // the user.
51 //
52 // For more details, check Reconcile and its Result here:
53 // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.15.0/pkg/reconcile
54 func (r *RicPlatformReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
55
56         // TODO(user): your logic here
57         return ctrl.Result{}, nil
58 }
59
60 // SetupWithManager sets up the controller with the Manager.
61 func (r *RicPlatformReconciler) SetupWithManager(mgr ctrl.Manager) error {
62         return ctrl.NewControllerManagedBy(mgr).
63                 For(&ricdeployv1.RicPlatform{}).
64                 Complete(r)
65 }