@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17+ // Package operator contains the OpenStack operator controller implementation
1718package operator
1819
1920import (
@@ -133,12 +134,12 @@ func (r *OpenStackReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
133134
134135 // Fetch the OpenStack instance
135136 instanceList := & operatorv1beta1.OpenStackList {}
136- err := r .Client . List (ctx , instanceList , & client.ListOptions {})
137+ err := r .List (ctx , instanceList , & client.ListOptions {})
137138 if err != nil {
138139 return ctrl.Result {}, errors .Wrap (err , "failed listing all OpenStack instances" )
139140 }
140141 instance := & operatorv1beta1.OpenStack {}
141- err = r .Client . Get (ctx , req .NamespacedName , instance )
142+ err = r .Get (ctx , req .NamespacedName , instance )
142143 if err != nil {
143144 if apierrors .IsNotFound (err ) {
144145 // Request object not found, could have been deleted after reconcile req.
@@ -229,7 +230,7 @@ func (r *OpenStackReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
229230 }
230231 if instanceList .Items [0 ].Name != req .Name {
231232 Log .Info ("Ignoring OpenStack.operator.openstack.org because one already exists and does not match existing name" )
232- err = r .Client . Delete (ctx , instance , & client.DeleteOptions {})
233+ err = r .Delete (ctx , instance , & client.DeleteOptions {})
233234 if err != nil {
234235 instance .Status .Conditions .Set (condition .FalseCondition (
235236 operatorv1beta1 .OpenStackOperatorReadyCondition ,
@@ -363,7 +364,7 @@ func (r *OpenStackReconciler) reconcileDelete(ctx context.Context, instance *ope
363364func (r * OpenStackReconciler ) countDeployments (ctx context.Context , instance * operatorv1beta1.OpenStack ) (int , []string , error ) {
364365 deployments := & appsv1.DeploymentList {}
365366 pending := []string {}
366- err := r .Client . List (ctx , deployments , & client.ListOptions {Namespace : instance .Namespace })
367+ err := r .List (ctx , deployments , & client.ListOptions {Namespace : instance .Namespace })
367368 if err != nil {
368369 return 0 , pending , err
369370 }
@@ -409,7 +410,7 @@ func (r *OpenStackReconciler) checkServiceEndpoints(ctx context.Context, instanc
409410 Log := r .GetLogger (ctx )
410411
411412 endpointSliceList := & discoveryv1.EndpointSliceList {}
412- err := r .Client . List (ctx , endpointSliceList , & client.ListOptions {Namespace : instance .Namespace })
413+ err := r .List (ctx , endpointSliceList , & client.ListOptions {Namespace : instance .Namespace })
413414 if err != nil {
414415 if apierrors .IsNotFound (err ) {
415416 Log .Info ("Webhook endpoint not found. Requeuing..." )
@@ -755,14 +756,14 @@ func (r *OpenStackReconciler) cleanupObsoleteResources(ctx context.Context, inst
755756
756757 csvList := & uns.UnstructuredList {}
757758 csvList .SetGroupVersionKind (csvGVR .GroupVersion ().WithKind ("ClusterServiceVersion" ))
758- err := r .Client . List (ctx , csvList , & client.ListOptions {Namespace : instance .Namespace })
759+ err := r .List (ctx , csvList , & client.ListOptions {Namespace : instance .Namespace })
759760 if err != nil {
760761 return err
761762 }
762763 for _ , csv := range csvList .Items {
763764 Log .Info ("Found CSV" , "name" , csv .GetName ())
764765 if isServiceOperatorResource (csv .GetName ()) {
765- err = r .Client . Delete (ctx , & csv )
766+ err = r .Delete (ctx , & csv )
766767 if err != nil {
767768 if apierrors .IsNotFound (err ) {
768769 Log .Info ("CSV not found on delete. Continuing..." , "name" , csv .GetName ())
@@ -776,14 +777,14 @@ func (r *OpenStackReconciler) cleanupObsoleteResources(ctx context.Context, inst
776777
777778 subscriptionList := & uns.UnstructuredList {}
778779 subscriptionList .SetGroupVersionKind (subscriptionGVR .GroupVersion ().WithKind ("Subscription" ))
779- err = r .Client . List (ctx , subscriptionList , & client.ListOptions {Namespace : instance .Namespace })
780+ err = r .List (ctx , subscriptionList , & client.ListOptions {Namespace : instance .Namespace })
780781 if err != nil {
781782 return err
782783 }
783784 for _ , subscription := range subscriptionList .Items {
784785 Log .Info ("Found Subscription" , "name" , subscription .GetName ())
785786 if isServiceOperatorResource (subscription .GetName ()) {
786- err = r .Client . Delete (ctx , & subscription )
787+ err = r .Delete (ctx , & subscription )
787788 if err != nil {
788789 if apierrors .IsNotFound (err ) {
789790 Log .Info ("Subscription not found on delete. Continuing..." , "name" , subscription .GetName ())
@@ -800,7 +801,7 @@ func (r *OpenStackReconciler) cleanupObsoleteResources(ctx context.Context, inst
800801 installPlanList := & uns.UnstructuredList {}
801802 installPlanList .SetGroupVersionKind (installPlanGVR .GroupVersion ().WithKind ("InstallPlan" ))
802803
803- err = r .Client . List (ctx , installPlanList , & client.ListOptions {Namespace : instance .Namespace })
804+ err = r .List (ctx , installPlanList , & client.ListOptions {Namespace : instance .Namespace })
804805 if err != nil {
805806 return err
806807 }
@@ -814,7 +815,7 @@ func (r *OpenStackReconciler) cleanupObsoleteResources(ctx context.Context, inst
814815 if found {
815816 // just checking for the first one should be sufficient
816817 if isServiceOperatorResource (csvNames [0 ].(string )) {
817- err = r .Client . Delete (ctx , & installPlan )
818+ err = r .Delete (ctx , & installPlan )
818819 if err != nil {
819820 if apierrors .IsNotFound (err ) {
820821 Log .Info ("Installplane not found on delete. Continuing..." , "name" , installPlan .GetName ())
@@ -848,7 +849,7 @@ func (r *OpenStackReconciler) postCleanupObsoleteResources(ctx context.Context,
848849 // 4) installPlan from old service operators removed
849850 operatorList := & uns.UnstructuredList {}
850851 operatorList .SetGroupVersionKind (operatorGVR .GroupVersion ().WithKind ("Operator" ))
851- err := r .Client . List (ctx , operatorList , & client.ListOptions {Namespace : instance .Namespace })
852+ err := r .List (ctx , operatorList , & client.ListOptions {Namespace : instance .Namespace })
852853 if err != nil {
853854 return err
854855 }
@@ -894,7 +895,7 @@ func (r *OpenStackReconciler) postCleanupObsoleteResources(ctx context.Context,
894895 // references from CRD's should be removed before this function is called
895896 // but this is a safeguard as we do not want to delete them
896897 if refData ["kind" ].(string ) != "CustomResourceDefinition" {
897- err = r .Client . Delete (ctx , & obj )
898+ err = r .Delete (ctx , & obj )
898899 if err != nil {
899900 if apierrors .IsNotFound (err ) {
900901 Log .Info ("Object not found on delete. Continuing..." , "name" , obj .GetName ())
@@ -908,7 +909,7 @@ func (r *OpenStackReconciler) postCleanupObsoleteResources(ctx context.Context,
908909 return fmt .Errorf ("Requeuing/Found references for operator name: %s, refs: %v" , operator .GetName (), refs )
909910 }
910911 // no refs found so we should be able to successfully delete the operator
911- err = r .Client . Delete (ctx , & operator )
912+ err = r .Delete (ctx , & operator )
912913 if err != nil {
913914 return err
914915 }
0 commit comments