@@ -20,7 +20,8 @@ import (
2020 "context"
2121 "github.com/go-logr/logr"
2222 "github.com/pkg/errors"
23- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+ "golang.org/x/text/cases"
24+ "golang.org/x/text/language"
2425 "k8s.io/apimachinery/pkg/runtime"
2526 "k8s.io/client-go/tools/record"
2627 ctrl "sigs.k8s.io/controller-runtime"
7778// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete
7879// +kubebuilder:rbac:groups=core,resources=events,verbs=create;patch
7980// +kubebuilder:rbac:groups=networking.k8s.io,resources=ingresses,verbs=get;list;watch;create;update;patch;delete
80- //+kubebuilder:rbac:groups=batch,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete
81+ // +kubebuilder:rbac:groups=batch,resources=cronjobs,verbs=get;list;watch;create;update;patch;delete
8182
8283// Reconcile is part of the main kubernetes reconciliation loop which aims to
8384// move the current state of the cluster closer to the desired state.
@@ -159,6 +160,10 @@ func (r *TypesenseClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req
159160 terminationGracePeriodSeconds := * sts .Spec .Template .Spec .TerminationGracePeriodSeconds
160161 delayPerReplicaPeriodSeconds := int64 (ts .Spec .Replicas )
161162
163+ toTitle := func (s string ) string {
164+ return cases .Title (language .Und , cases .NoLower ).String (s )
165+ }
166+
162167 if * updated {
163168 condition , size , err := r .ReconcileQuorum (ctx , ts , * sts )
164169 if err != nil {
@@ -174,7 +179,7 @@ func (r *TypesenseClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req
174179 return ctrl.Result {}, cerr
175180 }
176181
177- r .Recorder .Eventf (& ts , "Warning" , string (condition ), err .Error ())
182+ r .Recorder .Eventf (& ts , "Warning" , string (condition ), toTitle ( err .Error () ))
178183
179184 if size != 0 {
180185 delayPerReplicaPeriodSeconds = int64 (size )
@@ -192,22 +197,20 @@ func (r *TypesenseClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req
192197 return ctrl.Result {}, cerr
193198 }
194199
195- r .Recorder .Eventf (& ts , "Warning" , string (condition ), err .Error ())
200+ r .Recorder .Eventf (& ts , "Warning" , string (condition ), toTitle ( err .Error () ))
196201
197202 if size != 0 {
198203 delayPerReplicaPeriodSeconds = int64 (size )
199204 }
200205 } else {
201- c := ts .Status .Conditions [0 ]
206+ // c := ts.Status.Conditions[0]
202207
203208 cerr := r .setConditionReady (ctx , & ts , string (condition ))
204209 if cerr != nil {
205210 return ctrl.Result {}, cerr
206211 }
207212
208- if c .Status != metav1 .ConditionTrue {
209- r .Recorder .Eventf (& ts , "Normal" , string (condition ), "quorum is ready" )
210- }
213+ r .Recorder .Eventf (& ts , "Normal" , string (condition ), toTitle ("quorum is ready" ))
211214
212215 delayPerReplicaPeriodSeconds = int64 (1 )
213216 }
0 commit comments