github.com/ferryproxy/api@v0.4.2/controllers/traffic/routepolicy_controller.go (about) 1 /* 2 Copyright 2022 FerryProxy 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 traffic 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 trafficv1alpha2 "github.com/ferryproxy/api/apis/traffic/v1alpha2" 28 ) 29 30 // RoutePolicyReconciler reconciles a RoutePolicy object 31 type RoutePolicyReconciler struct { 32 client.Client 33 Scheme *runtime.Scheme 34 } 35 36 //+kubebuilder:rbac:groups=traffic.ferryproxy.io,resources=routepolicies,verbs=get;list;watch;create;update;patch;delete 37 //+kubebuilder:rbac:groups=traffic.ferryproxy.io,resources=routepolicies/status,verbs=get;update;patch 38 //+kubebuilder:rbac:groups=traffic.ferryproxy.io,resources=routepolicies/finalizers,verbs=update 39 40 // Reconcile is part of the main kubernetes reconciliation loop which aims to 41 // move the current state of the cluster closer to the desired state. 42 // TODO(user): Modify the Reconcile function to compare the state specified by 43 // the RoutePolicy object against the actual cluster state, and then 44 // perform operations to make the cluster state reflect the state specified by 45 // the user. 46 // 47 // For more details, check Reconcile and its Result here: 48 // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.12.1/pkg/reconcile 49 func (r *RoutePolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { 50 _ = log.FromContext(ctx) 51 52 // TODO(user): your logic here 53 54 return ctrl.Result{}, nil 55 } 56 57 // SetupWithManager sets up the controller with the Manager. 58 func (r *RoutePolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { 59 return ctrl.NewControllerManagedBy(mgr). 60 For(&trafficv1alpha2.RoutePolicy{}). 61 Complete(r) 62 }