@@ -100,7 +100,7 @@ func (r *GlanceAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
100100
101101 // Fetch the GlanceAPI instance
102102 instance := & glancev1.GlanceAPI {}
103- err := r .Client . Get (ctx , req .NamespacedName , instance )
103+ err := r .Get (ctx , req .NamespacedName , instance )
104104 if err != nil {
105105 if k8s_errors .IsNotFound (err ) {
106106 // Request object not found, could have been deleted after reconcile request.
@@ -273,16 +273,16 @@ func (r *GlanceAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
273273
274274 // Watch for changes to any CustomServiceConfigSecrets. Global secrets
275275 svcSecretFn := func (_ context.Context , o client.Object ) []reconcile.Request {
276- var namespace string = o .GetNamespace ()
277- var secretName string = o .GetName ()
276+ var namespace = o .GetNamespace ()
277+ var secretName = o .GetName ()
278278 result := []reconcile.Request {}
279279
280280 // get all API CRs
281281 apis := & glancev1.GlanceAPIList {}
282282 listOpts := []client.ListOption {
283283 client .InNamespace (namespace ),
284284 }
285- if err := r .Client . List (context .Background (), apis , listOpts ... ); err != nil {
285+ if err := r .List (context .Background (), apis , listOpts ... ); err != nil {
286286 Log .Error (err , "Unable to retrieve API CRs %v" )
287287 return nil
288288 }
@@ -313,7 +313,7 @@ func (r *GlanceAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
313313 listOpts := []client.ListOption {
314314 client .InNamespace (o .GetNamespace ()),
315315 }
316- if err := r .Client . List (context .Background (), glanceAPIs , listOpts ... ); err != nil {
316+ if err := r .List (context .Background (), glanceAPIs , listOpts ... ); err != nil {
317317 Log .Error (err , "Unable to retrieve GlanceAPI CRs %w" )
318318 return nil
319319 }
@@ -341,7 +341,7 @@ func (r *GlanceAPIReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
341341 listOpts := []client.ListOption {
342342 client .InNamespace (o .GetNamespace ()),
343343 }
344- if err := r .Client . List (context .Background (), glanceAPIs , listOpts ... ); err != nil {
344+ if err := r .List (context .Background (), glanceAPIs , listOpts ... ); err != nil {
345345 Log .Error (err , "Unable to retrieve GlanceAPI CRs %w" )
346346 return nil
347347 }
@@ -742,8 +742,8 @@ func (r *GlanceAPIReconciler) reconcileNormal(
742742 // iterate over availableBackends for backend specific cases
743743 for i := 0 ; i < len (availableBackends ); i ++ {
744744 backendToken := strings .SplitN (availableBackends [i ], ":" , 2 )
745- switch {
746- case backendToken [ 1 ] == "cinder" :
745+ switch backendToken [ 1 ] {
746+ case "cinder" :
747747 cinderList := & cinderv1.CinderList {}
748748 err := r .List (ctx , cinderList , client .InNamespace (instance .Namespace ))
749749 if err != nil {
@@ -775,7 +775,7 @@ func (r *GlanceAPIReconciler) reconcileNormal(
775775 // We see at least a Cinder CR in the namespace, unblock glance
776776 // deployment
777777 privileged = true
778- case backendToken [ 1 ] == "rbd" :
778+ case "rbd" :
779779 // enable image conversion by default
780780 Log .Info ("Ceph config detected: enable image conversion by default" )
781781 imageConv = true
@@ -804,7 +804,7 @@ func (r *GlanceAPIReconciler) reconcileNormal(
804804 condition .TLSInputReadyCondition ,
805805 condition .RequestedReason ,
806806 condition .SeverityInfo ,
807- fmt . Sprintf ( condition .TLSInputReadyWaitingMessage , instance .Spec .TLS .CaBundleSecretName ) ))
807+ condition .TLSInputReadyWaitingMessage , instance .Spec .TLS .CaBundleSecretName ))
808808 return ctrl.Result {}, nil
809809 }
810810 instance .Status .Conditions .Set (condition .FalseCondition (
@@ -828,7 +828,7 @@ func (r *GlanceAPIReconciler) reconcileNormal(
828828 condition .TLSInputReadyCondition ,
829829 condition .RequestedReason ,
830830 condition .SeverityInfo ,
831- fmt . Sprintf ( condition .TLSInputReadyWaitingMessage , err .Error () )))
831+ condition .TLSInputReadyWaitingMessage , err .Error ()))
832832 return ctrl.Result {}, nil
833833 }
834834 instance .Status .Conditions .Set (condition .FalseCondition (
@@ -900,7 +900,7 @@ func (r *GlanceAPIReconciler) reconcileNormal(
900900 return glance .ResultRequeue , err
901901 }
902902
903- configVars [glance .KeystoneEndpoint ] = env .SetValue (instance .ObjectMeta . Annotations [glance .KeystoneEndpoint ])
903+ configVars [glance .KeystoneEndpoint ] = env .SetValue (instance .Annotations [glance .KeystoneEndpoint ])
904904 //
905905 // normal reconcile tasks
906906 //
@@ -1032,7 +1032,7 @@ func (r *GlanceAPIReconciler) reconcileNormal(
10321032 if networkReady {
10331033 instance .Status .Conditions .MarkTrue (condition .NetworkAttachmentsReadyCondition , condition .NetworkAttachmentsReadyMessage )
10341034 } else {
1035- err := fmt .Errorf ("not all pods have interfaces with ips as configured in NetworkAttachments : %s" , instance .Spec .NetworkAttachments )
1035+ err := fmt .Errorf ("%w : %s" , ErrNetworkAttachmentConfig , instance .Spec .NetworkAttachments )
10361036 instance .Status .Conditions .Set (condition .FalseCondition (
10371037 condition .NetworkAttachmentsReadyCondition ,
10381038 condition .ErrorReason ,
@@ -1134,7 +1134,7 @@ func (r *GlanceAPIReconciler) generateServiceConfig(
11341134 }
11351135
11361136 var tlsCfg * tls.Service
1137- if instance .Spec .TLS .Ca . CaBundleSecretName != "" {
1137+ if instance .Spec .TLS .CaBundleSecretName != "" {
11381138 tlsCfg = & tls.Service {}
11391139 }
11401140 // 02-config.conf
@@ -1369,8 +1369,8 @@ func (r *GlanceAPIReconciler) ensureKeystoneEndpoints(
13691369
13701370 // If the parent controller didn't set the annotation, the current glanceAPIs
13711371 // shouldn't register the endpoints in keystone
1372- if len (instance .ObjectMeta . Annotations ) == 0 ||
1373- instance .ObjectMeta . Annotations [glance .KeystoneEndpoint ] != "true" {
1372+ if len (instance .Annotations ) == 0 ||
1373+ instance .Annotations [glance .KeystoneEndpoint ] != "true" {
13741374 // Mark the KeystoneEndpointReadyCondition as True because there's nothing
13751375 // to do here
13761376 instance .Status .Conditions .MarkTrue (
@@ -1461,7 +1461,7 @@ func (r *GlanceAPIReconciler) ensureImageCacheJob(
14611461 }
14621462 cachePVCs , _ := GetPvcListWithLabel (ctx , h , instance .Namespace , serviceLabels )
14631463 for _ , vc := range cachePVCs .Items {
1464- var pvcName string = vc .GetName ()
1464+ var pvcName = vc .GetName ()
14651465 cacheAnnotations := vc .GetAnnotations ()
14661466 if _ , ok := cacheAnnotations ["image-cache" ]; ok {
14671467 cronSpec := glance.CronJobSpec {
@@ -1516,10 +1516,10 @@ func (r *GlanceAPIReconciler) cleanupImageCacheJob(
15161516 for _ , vc := range cachePVCs .Items {
15171517 cacheAnnotations := vc .GetAnnotations ()
15181518 if _ , ok := cacheAnnotations ["image-cache" ]; ok {
1519- var pvcName string = vc .GetName ()
1519+ var pvcName = vc .GetName ()
15201520 // Get the pod (by name) associated to the current pvc
15211521 var pod corev1.Pod
1522- if err := r .Client . Get (ctx , types.NamespacedName {
1522+ if err := r .Get (ctx , types.NamespacedName {
15231523 Name : strings .TrimPrefix (pvcName , "glance-cache-" ),
15241524 Namespace : instance .Namespace ,
15251525 }, & pod ); err != nil && k8s_errors .IsNotFound (err ) || instance .Spec .ImageCache .Size == "" {
@@ -1553,7 +1553,7 @@ func (r *GlanceAPIReconciler) deleteJob(
15531553 // For each imageCache we have both cleaner and pruner cronJobs to check and
15541554 // cleanup if the conditions are met
15551555 for _ , cj := range []glance.CronJobType {glance .CachePruner , glance .CacheCleaner } {
1556- if err = r .Client . Get (
1556+ if err = r .Get (
15571557 ctx ,
15581558 types.NamespacedName {
15591559 Name : fmt .Sprintf ("%s-%s" , pvcName , cj ),
@@ -1626,9 +1626,9 @@ func (r *GlanceAPIReconciler) glanceAPIRefresh(
16261626 }
16271627 return err
16281628 }
1629- err = r .Client . Delete (ctx , sts )
1629+ err = r .Delete (ctx , sts )
16301630 if err != nil && ! k8s_errors .IsNotFound (err ) {
1631- err = fmt .Errorf ("Error deleting %s: %w" , instance .Name , err )
1631+ err = fmt .Errorf ("error deleting %s: %w" , instance .Name , err )
16321632 return err
16331633 }
16341634 return nil
0 commit comments