From 5331e88dd9297fb1e52f1b98ee165a1b2cfa4ea2 Mon Sep 17 00:00:00 2001 From: prafull01 Date: Fri, 25 Sep 2020 02:49:52 +0530 Subject: [PATCH] :sparkles: Added the changes for include finalizer as a default controller markers --- .../templates/config/controller/controller.go | 1 + .../config/rbac/role.yaml | 42 +++++++++++++++++++ .../controllers/crew/captain_controller.go | 1 + .../healthcheckpolicy_controller.go | 1 + .../sea-creatures/kraken_controller.go | 1 + .../sea-creatures/leviathan_controller.go | 1 + .../controllers/ship/cruiser_controller.go | 1 + .../controllers/ship/destroyer_controller.go | 1 + .../controllers/ship/frigate_controller.go | 1 + testdata/project-v3/config/rbac/role.yaml | 18 ++++++++ .../controllers/admiral_controller.go | 1 + .../controllers/captain_controller.go | 1 + .../controllers/firstmate_controller.go | 1 + 13 files changed, 71 insertions(+) diff --git a/pkg/plugin/v3/scaffolds/internal/templates/config/controller/controller.go b/pkg/plugin/v3/scaffolds/internal/templates/config/controller/controller.go index 7b46e5d7ce0..b61a7303d84 100644 --- a/pkg/plugin/v3/scaffolds/internal/templates/config/controller/controller.go +++ b/pkg/plugin/v3/scaffolds/internal/templates/config/controller/controller.go @@ -75,6 +75,7 @@ type {{ .Resource.Kind }}Reconciler struct { // +kubebuilder:rbac:groups={{ .Resource.Domain }},resources={{ .Resource.Plural }},verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups={{ .Resource.Domain }},resources={{ .Resource.Plural }}/status,verbs=get;update;patch +// +kubebuilder:rbac:groups={{ .Resource.Domain }},resources={{ .Resource.Plural }}/finalizers,verbs=update func (r *{{ .Resource.Kind }}Reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3-multigroup/config/rbac/role.yaml b/testdata/project-v3-multigroup/config/rbac/role.yaml index d1cb5d78124..1d74a6db024 100644 --- a/testdata/project-v3-multigroup/config/rbac/role.yaml +++ b/testdata/project-v3-multigroup/config/rbac/role.yaml @@ -18,6 +18,12 @@ rules: - patch - update - watch +- apiGroups: + - crew.testproject.org + resources: + - captains/finalizers + verbs: + - update - apiGroups: - crew.testproject.org resources: @@ -38,6 +44,12 @@ rules: - patch - update - watch +- apiGroups: + - foo.policy.testproject.org + resources: + - healthcheckpolicies/finalizers + verbs: + - update - apiGroups: - foo.policy.testproject.org resources: @@ -58,6 +70,12 @@ rules: - patch - update - watch +- apiGroups: + - sea-creatures.testproject.org + resources: + - krakens/finalizers + verbs: + - update - apiGroups: - sea-creatures.testproject.org resources: @@ -78,6 +96,12 @@ rules: - patch - update - watch +- apiGroups: + - sea-creatures.testproject.org + resources: + - leviathans/finalizers + verbs: + - update - apiGroups: - sea-creatures.testproject.org resources: @@ -98,6 +122,12 @@ rules: - patch - update - watch +- apiGroups: + - ship.testproject.org + resources: + - cruisers/finalizers + verbs: + - update - apiGroups: - ship.testproject.org resources: @@ -118,6 +148,12 @@ rules: - patch - update - watch +- apiGroups: + - ship.testproject.org + resources: + - destroyers/finalizers + verbs: + - update - apiGroups: - ship.testproject.org resources: @@ -138,6 +174,12 @@ rules: - patch - update - watch +- apiGroups: + - ship.testproject.org + resources: + - frigates/finalizers + verbs: + - update - apiGroups: - ship.testproject.org resources: diff --git a/testdata/project-v3-multigroup/controllers/crew/captain_controller.go b/testdata/project-v3-multigroup/controllers/crew/captain_controller.go index 4ece0a54d13..9441e8c5e90 100644 --- a/testdata/project-v3-multigroup/controllers/crew/captain_controller.go +++ b/testdata/project-v3-multigroup/controllers/crew/captain_controller.go @@ -36,6 +36,7 @@ type CaptainReconciler struct { // +kubebuilder:rbac:groups=crew.testproject.org,resources=captains,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=crew.testproject.org,resources=captains/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=crew.testproject.org,resources=captains/finalizers,verbs=update func (r *CaptainReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3-multigroup/controllers/foo.policy/healthcheckpolicy_controller.go b/testdata/project-v3-multigroup/controllers/foo.policy/healthcheckpolicy_controller.go index c05f36b3e64..a26d9c16cfb 100644 --- a/testdata/project-v3-multigroup/controllers/foo.policy/healthcheckpolicy_controller.go +++ b/testdata/project-v3-multigroup/controllers/foo.policy/healthcheckpolicy_controller.go @@ -36,6 +36,7 @@ type HealthCheckPolicyReconciler struct { // +kubebuilder:rbac:groups=foo.policy.testproject.org,resources=healthcheckpolicies,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=foo.policy.testproject.org,resources=healthcheckpolicies/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=foo.policy.testproject.org,resources=healthcheckpolicies/finalizers,verbs=update func (r *HealthCheckPolicyReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3-multigroup/controllers/sea-creatures/kraken_controller.go b/testdata/project-v3-multigroup/controllers/sea-creatures/kraken_controller.go index c16cd4177a8..96b7d0daf1f 100644 --- a/testdata/project-v3-multigroup/controllers/sea-creatures/kraken_controller.go +++ b/testdata/project-v3-multigroup/controllers/sea-creatures/kraken_controller.go @@ -36,6 +36,7 @@ type KrakenReconciler struct { // +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=krakens,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=krakens/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=krakens/finalizers,verbs=update func (r *KrakenReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3-multigroup/controllers/sea-creatures/leviathan_controller.go b/testdata/project-v3-multigroup/controllers/sea-creatures/leviathan_controller.go index d857c2d3c2b..58cde56537d 100644 --- a/testdata/project-v3-multigroup/controllers/sea-creatures/leviathan_controller.go +++ b/testdata/project-v3-multigroup/controllers/sea-creatures/leviathan_controller.go @@ -36,6 +36,7 @@ type LeviathanReconciler struct { // +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=leviathans,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=leviathans/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=sea-creatures.testproject.org,resources=leviathans/finalizers,verbs=update func (r *LeviathanReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3-multigroup/controllers/ship/cruiser_controller.go b/testdata/project-v3-multigroup/controllers/ship/cruiser_controller.go index 95f3d21d489..e58bba9b13a 100644 --- a/testdata/project-v3-multigroup/controllers/ship/cruiser_controller.go +++ b/testdata/project-v3-multigroup/controllers/ship/cruiser_controller.go @@ -36,6 +36,7 @@ type CruiserReconciler struct { // +kubebuilder:rbac:groups=ship.testproject.org,resources=cruisers,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=ship.testproject.org,resources=cruisers/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=ship.testproject.org,resources=cruisers/finalizers,verbs=update func (r *CruiserReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3-multigroup/controllers/ship/destroyer_controller.go b/testdata/project-v3-multigroup/controllers/ship/destroyer_controller.go index b41c07cb745..45f58f26876 100644 --- a/testdata/project-v3-multigroup/controllers/ship/destroyer_controller.go +++ b/testdata/project-v3-multigroup/controllers/ship/destroyer_controller.go @@ -36,6 +36,7 @@ type DestroyerReconciler struct { // +kubebuilder:rbac:groups=ship.testproject.org,resources=destroyers,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=ship.testproject.org,resources=destroyers/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=ship.testproject.org,resources=destroyers/finalizers,verbs=update func (r *DestroyerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3-multigroup/controllers/ship/frigate_controller.go b/testdata/project-v3-multigroup/controllers/ship/frigate_controller.go index cac7fe7bb79..5671d311a84 100644 --- a/testdata/project-v3-multigroup/controllers/ship/frigate_controller.go +++ b/testdata/project-v3-multigroup/controllers/ship/frigate_controller.go @@ -36,6 +36,7 @@ type FrigateReconciler struct { // +kubebuilder:rbac:groups=ship.testproject.org,resources=frigates,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=ship.testproject.org,resources=frigates/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=ship.testproject.org,resources=frigates/finalizers,verbs=update func (r *FrigateReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3/config/rbac/role.yaml b/testdata/project-v3/config/rbac/role.yaml index a1cd43c89d2..7afe06fb451 100644 --- a/testdata/project-v3/config/rbac/role.yaml +++ b/testdata/project-v3/config/rbac/role.yaml @@ -18,6 +18,12 @@ rules: - patch - update - watch +- apiGroups: + - crew.testproject.org + resources: + - admirals/finalizers + verbs: + - update - apiGroups: - crew.testproject.org resources: @@ -38,6 +44,12 @@ rules: - patch - update - watch +- apiGroups: + - crew.testproject.org + resources: + - captains/finalizers + verbs: + - update - apiGroups: - crew.testproject.org resources: @@ -58,6 +70,12 @@ rules: - patch - update - watch +- apiGroups: + - crew.testproject.org + resources: + - firstmates/finalizers + verbs: + - update - apiGroups: - crew.testproject.org resources: diff --git a/testdata/project-v3/controllers/admiral_controller.go b/testdata/project-v3/controllers/admiral_controller.go index 86cb7edc171..6c927c61f93 100644 --- a/testdata/project-v3/controllers/admiral_controller.go +++ b/testdata/project-v3/controllers/admiral_controller.go @@ -36,6 +36,7 @@ type AdmiralReconciler struct { // +kubebuilder:rbac:groups=crew.testproject.org,resources=admirals,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=crew.testproject.org,resources=admirals/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=crew.testproject.org,resources=admirals/finalizers,verbs=update func (r *AdmiralReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3/controllers/captain_controller.go b/testdata/project-v3/controllers/captain_controller.go index 95f8c136470..8e484f58b40 100644 --- a/testdata/project-v3/controllers/captain_controller.go +++ b/testdata/project-v3/controllers/captain_controller.go @@ -36,6 +36,7 @@ type CaptainReconciler struct { // +kubebuilder:rbac:groups=crew.testproject.org,resources=captains,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=crew.testproject.org,resources=captains/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=crew.testproject.org,resources=captains/finalizers,verbs=update func (r *CaptainReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background() diff --git a/testdata/project-v3/controllers/firstmate_controller.go b/testdata/project-v3/controllers/firstmate_controller.go index 3c9c7e3642c..8cf3a548858 100644 --- a/testdata/project-v3/controllers/firstmate_controller.go +++ b/testdata/project-v3/controllers/firstmate_controller.go @@ -36,6 +36,7 @@ type FirstMateReconciler struct { // +kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates/finalizers,verbs=update func (r *FirstMateReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { _ = context.Background()