github.com/k8snetworkplumbingwg/sriov-network-operator@v1.2.1-0.20240408194816-2d2e5a45d453/controllers/sriovnetwork_controller.go (about) 1 /* 2 Copyright 2021. 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 controllers 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 26 sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1" 27 ) 28 29 // SriovNetworkReconciler reconciles a SriovNetwork object 30 type SriovNetworkReconciler struct { 31 client.Client 32 Scheme *runtime.Scheme 33 genericReconciler *genericNetworkReconciler 34 } 35 36 //+kubebuilder:rbac:groups=sriovnetwork.openshift.io,resources=sriovnetworks,verbs=get;list;watch;create;update;patch;delete 37 //+kubebuilder:rbac:groups=sriovnetwork.openshift.io,resources=sriovnetworks/status,verbs=get;update;patch 38 //+kubebuilder:rbac:groups=sriovnetwork.openshift.io,resources=sriovnetworks/finalizers,verbs=update 39 40 // Reconcile loop for SriovNetwork CRs 41 func (r *SriovNetworkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { 42 return r.genericReconciler.Reconcile(ctx, req) 43 } 44 45 // return name of the controller 46 func (r *SriovNetworkReconciler) Name() string { 47 return "SriovNetwork" 48 } 49 50 // return empty instance of the SriovIBNetwork CR 51 func (r *SriovNetworkReconciler) GetObject() networkCRInstance { 52 return &sriovnetworkv1.SriovNetwork{} 53 } 54 55 // return empty list of the SriovIBNetwork CRs 56 func (r *SriovNetworkReconciler) GetObjectList() client.ObjectList { 57 return &sriovnetworkv1.SriovNetworkList{} 58 } 59 60 // SetupWithManager sets up the controller with the Manager. 61 func (r *SriovNetworkReconciler) SetupWithManager(mgr ctrl.Manager) error { 62 r.genericReconciler = newGenericNetworkReconciler(r.Client, r.Scheme, r) 63 return r.genericReconciler.SetupWithManager(mgr) 64 }