cmd/k8s-operator: rename 'l' variables (#17700)

Single letter 'l' variables can eventually become confusing when
they're rendered in some fonts that make them similar to 1 or I.

Updates #cleanup

Signed-off-by: Fernando Serboncini <fserb@tailscale.com>
pull/17703/head
Fernando Serboncini 1 month ago committed by GitHub
parent 06b092388e
commit da90e3d8f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -636,7 +636,7 @@ func runReconcilers(opts reconcilerOpts) {
recorder: eventRecorder, recorder: eventRecorder,
tsNamespace: opts.tailscaleNamespace, tsNamespace: opts.tailscaleNamespace,
Client: mgr.GetClient(), Client: mgr.GetClient(),
l: opts.log.Named("recorder-reconciler"), log: opts.log.Named("recorder-reconciler"),
clock: tstime.DefaultClock{}, clock: tstime.DefaultClock{},
tsClient: opts.tsClient, tsClient: opts.tsClient,
loginServer: opts.loginServer, loginServer: opts.loginServer,
@ -691,7 +691,7 @@ func runReconcilers(opts reconcilerOpts) {
Complete(&ProxyGroupReconciler{ Complete(&ProxyGroupReconciler{
recorder: eventRecorder, recorder: eventRecorder,
Client: mgr.GetClient(), Client: mgr.GetClient(),
l: opts.log.Named("proxygroup-reconciler"), log: opts.log.Named("proxygroup-reconciler"),
clock: tstime.DefaultClock{}, clock: tstime.DefaultClock{},
tsClient: opts.tsClient, tsClient: opts.tsClient,

@ -80,7 +80,7 @@ var (
// ProxyGroupReconciler ensures cluster resources for a ProxyGroup definition. // ProxyGroupReconciler ensures cluster resources for a ProxyGroup definition.
type ProxyGroupReconciler struct { type ProxyGroupReconciler struct {
client.Client client.Client
l *zap.SugaredLogger log *zap.SugaredLogger
recorder record.EventRecorder recorder record.EventRecorder
clock tstime.Clock clock tstime.Clock
tsClient tsClient tsClient tsClient
@ -101,7 +101,7 @@ type ProxyGroupReconciler struct {
} }
func (r *ProxyGroupReconciler) logger(name string) *zap.SugaredLogger { func (r *ProxyGroupReconciler) logger(name string) *zap.SugaredLogger {
return r.l.With("ProxyGroup", name) return r.log.With("ProxyGroup", name)
} }
func (r *ProxyGroupReconciler) Reconcile(ctx context.Context, req reconcile.Request) (_ reconcile.Result, err error) { func (r *ProxyGroupReconciler) Reconcile(ctx context.Context, req reconcile.Request) (_ reconcile.Result, err error) {

@ -670,7 +670,7 @@ func TestProxyGroupWithStaticEndpoints(t *testing.T) {
t.Logf("created node %q with data", n.name) t.Logf("created node %q with data", n.name)
} }
reconciler.l = zl.Sugar().With("TestName", tt.name).With("Reconcile", i) reconciler.log = zl.Sugar().With("TestName", tt.name).With("Reconcile", i)
pg.Spec.Replicas = r.replicas pg.Spec.Replicas = r.replicas
pc.Spec.StaticEndpoints = r.staticEndpointConfig pc.Spec.StaticEndpoints = r.staticEndpointConfig
@ -784,7 +784,7 @@ func TestProxyGroupWithStaticEndpoints(t *testing.T) {
Client: fc, Client: fc,
tsClient: tsClient, tsClient: tsClient,
recorder: fr, recorder: fr,
l: zl.Sugar().With("TestName", tt.name).With("Reconcile", "cleanup"), log: zl.Sugar().With("TestName", tt.name).With("Reconcile", "cleanup"),
clock: cl, clock: cl,
} }
@ -845,7 +845,7 @@ func TestProxyGroup(t *testing.T) {
Client: fc, Client: fc,
tsClient: tsClient, tsClient: tsClient,
recorder: fr, recorder: fr,
l: zl.Sugar(), log: zl.Sugar(),
clock: cl, clock: cl,
} }
crd := &apiextensionsv1.CustomResourceDefinition{ObjectMeta: metav1.ObjectMeta{Name: serviceMonitorCRD}} crd := &apiextensionsv1.CustomResourceDefinition{ObjectMeta: metav1.ObjectMeta{Name: serviceMonitorCRD}}
@ -1049,7 +1049,7 @@ func TestProxyGroupTypes(t *testing.T) {
tsNamespace: tsNamespace, tsNamespace: tsNamespace,
tsProxyImage: testProxyImage, tsProxyImage: testProxyImage,
Client: fc, Client: fc,
l: zl.Sugar(), log: zl.Sugar(),
tsClient: &fakeTSClient{}, tsClient: &fakeTSClient{},
clock: tstest.NewClock(tstest.ClockOpts{}), clock: tstest.NewClock(tstest.ClockOpts{}),
} }
@ -1289,24 +1289,24 @@ func TestKubeAPIServerStatusConditionFlow(t *testing.T) {
tsNamespace: tsNamespace, tsNamespace: tsNamespace,
tsProxyImage: testProxyImage, tsProxyImage: testProxyImage,
Client: fc, Client: fc,
l: zap.Must(zap.NewDevelopment()).Sugar(), log: zap.Must(zap.NewDevelopment()).Sugar(),
tsClient: &fakeTSClient{}, tsClient: &fakeTSClient{},
clock: tstest.NewClock(tstest.ClockOpts{}), clock: tstest.NewClock(tstest.ClockOpts{}),
} }
expectReconciled(t, r, "", pg.Name) expectReconciled(t, r, "", pg.Name)
pg.ObjectMeta.Finalizers = append(pg.ObjectMeta.Finalizers, FinalizerName) pg.ObjectMeta.Finalizers = append(pg.ObjectMeta.Finalizers, FinalizerName)
tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupAvailable, metav1.ConditionFalse, reasonProxyGroupCreating, "", 0, r.clock, r.l) tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupAvailable, metav1.ConditionFalse, reasonProxyGroupCreating, "", 0, r.clock, r.log)
tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupReady, metav1.ConditionFalse, reasonProxyGroupCreating, "", 1, r.clock, r.l) tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupReady, metav1.ConditionFalse, reasonProxyGroupCreating, "", 1, r.clock, r.log)
expectEqual(t, fc, pg, omitPGStatusConditionMessages) expectEqual(t, fc, pg, omitPGStatusConditionMessages)
// Set kube-apiserver valid. // Set kube-apiserver valid.
mustUpdateStatus(t, fc, "", pg.Name, func(p *tsapi.ProxyGroup) { mustUpdateStatus(t, fc, "", pg.Name, func(p *tsapi.ProxyGroup) {
tsoperator.SetProxyGroupCondition(p, tsapi.KubeAPIServerProxyValid, metav1.ConditionTrue, reasonKubeAPIServerProxyValid, "", 1, r.clock, r.l) tsoperator.SetProxyGroupCondition(p, tsapi.KubeAPIServerProxyValid, metav1.ConditionTrue, reasonKubeAPIServerProxyValid, "", 1, r.clock, r.log)
}) })
expectReconciled(t, r, "", pg.Name) expectReconciled(t, r, "", pg.Name)
tsoperator.SetProxyGroupCondition(pg, tsapi.KubeAPIServerProxyValid, metav1.ConditionTrue, reasonKubeAPIServerProxyValid, "", 1, r.clock, r.l) tsoperator.SetProxyGroupCondition(pg, tsapi.KubeAPIServerProxyValid, metav1.ConditionTrue, reasonKubeAPIServerProxyValid, "", 1, r.clock, r.log)
tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupReady, metav1.ConditionFalse, reasonProxyGroupCreating, "", 1, r.clock, r.l) tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupReady, metav1.ConditionFalse, reasonProxyGroupCreating, "", 1, r.clock, r.log)
expectEqual(t, fc, pg, omitPGStatusConditionMessages) expectEqual(t, fc, pg, omitPGStatusConditionMessages)
// Set available. // Set available.
@ -1318,17 +1318,17 @@ func TestKubeAPIServerStatusConditionFlow(t *testing.T) {
TailnetIPs: []string{"1.2.3.4", "::1"}, TailnetIPs: []string{"1.2.3.4", "::1"},
}, },
} }
tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupAvailable, metav1.ConditionTrue, reasonProxyGroupAvailable, "", 0, r.clock, r.l) tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupAvailable, metav1.ConditionTrue, reasonProxyGroupAvailable, "", 0, r.clock, r.log)
tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupReady, metav1.ConditionFalse, reasonProxyGroupCreating, "", 1, r.clock, r.l) tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupReady, metav1.ConditionFalse, reasonProxyGroupCreating, "", 1, r.clock, r.log)
expectEqual(t, fc, pg, omitPGStatusConditionMessages) expectEqual(t, fc, pg, omitPGStatusConditionMessages)
// Set kube-apiserver configured. // Set kube-apiserver configured.
mustUpdateStatus(t, fc, "", pg.Name, func(p *tsapi.ProxyGroup) { mustUpdateStatus(t, fc, "", pg.Name, func(p *tsapi.ProxyGroup) {
tsoperator.SetProxyGroupCondition(p, tsapi.KubeAPIServerProxyConfigured, metav1.ConditionTrue, reasonKubeAPIServerProxyConfigured, "", 1, r.clock, r.l) tsoperator.SetProxyGroupCondition(p, tsapi.KubeAPIServerProxyConfigured, metav1.ConditionTrue, reasonKubeAPIServerProxyConfigured, "", 1, r.clock, r.log)
}) })
expectReconciled(t, r, "", pg.Name) expectReconciled(t, r, "", pg.Name)
tsoperator.SetProxyGroupCondition(pg, tsapi.KubeAPIServerProxyConfigured, metav1.ConditionTrue, reasonKubeAPIServerProxyConfigured, "", 1, r.clock, r.l) tsoperator.SetProxyGroupCondition(pg, tsapi.KubeAPIServerProxyConfigured, metav1.ConditionTrue, reasonKubeAPIServerProxyConfigured, "", 1, r.clock, r.log)
tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupReady, metav1.ConditionTrue, reasonProxyGroupReady, "", 1, r.clock, r.l) tsoperator.SetProxyGroupCondition(pg, tsapi.ProxyGroupReady, metav1.ConditionTrue, reasonProxyGroupReady, "", 1, r.clock, r.log)
expectEqual(t, fc, pg, omitPGStatusConditionMessages) expectEqual(t, fc, pg, omitPGStatusConditionMessages)
} }
@ -1342,7 +1342,7 @@ func TestKubeAPIServerType_DoesNotOverwriteServicesConfig(t *testing.T) {
tsNamespace: tsNamespace, tsNamespace: tsNamespace,
tsProxyImage: testProxyImage, tsProxyImage: testProxyImage,
Client: fc, Client: fc,
l: zap.Must(zap.NewDevelopment()).Sugar(), log: zap.Must(zap.NewDevelopment()).Sugar(),
tsClient: &fakeTSClient{}, tsClient: &fakeTSClient{},
clock: tstest.NewClock(tstest.ClockOpts{}), clock: tstest.NewClock(tstest.ClockOpts{}),
} }
@ -1427,7 +1427,7 @@ func TestIngressAdvertiseServicesConfigPreserved(t *testing.T) {
tsNamespace: tsNamespace, tsNamespace: tsNamespace,
tsProxyImage: testProxyImage, tsProxyImage: testProxyImage,
Client: fc, Client: fc,
l: zap.Must(zap.NewDevelopment()).Sugar(), log: zap.Must(zap.NewDevelopment()).Sugar(),
tsClient: &fakeTSClient{}, tsClient: &fakeTSClient{},
clock: tstest.NewClock(tstest.ClockOpts{}), clock: tstest.NewClock(tstest.ClockOpts{}),
} }
@ -1902,7 +1902,7 @@ func TestProxyGroupLetsEncryptStaging(t *testing.T) {
defaultProxyClass: tt.defaultProxyClass, defaultProxyClass: tt.defaultProxyClass,
Client: fc, Client: fc,
tsClient: &fakeTSClient{}, tsClient: &fakeTSClient{},
l: zl.Sugar(), log: zl.Sugar(),
clock: cl, clock: cl,
} }

@ -54,7 +54,7 @@ var gaugeRecorderResources = clientmetric.NewGauge(kubetypes.MetricRecorderCount
// Recorder CRs. // Recorder CRs.
type RecorderReconciler struct { type RecorderReconciler struct {
client.Client client.Client
l *zap.SugaredLogger log *zap.SugaredLogger
recorder record.EventRecorder recorder record.EventRecorder
clock tstime.Clock clock tstime.Clock
tsNamespace string tsNamespace string
@ -66,7 +66,7 @@ type RecorderReconciler struct {
} }
func (r *RecorderReconciler) logger(name string) *zap.SugaredLogger { func (r *RecorderReconciler) logger(name string) *zap.SugaredLogger {
return r.l.With("Recorder", name) return r.log.With("Recorder", name)
} }
func (r *RecorderReconciler) Reconcile(ctx context.Context, req reconcile.Request) (_ reconcile.Result, err error) { func (r *RecorderReconciler) Reconcile(ctx context.Context, req reconcile.Request) (_ reconcile.Result, err error) {

@ -52,7 +52,7 @@ func TestRecorder(t *testing.T) {
Client: fc, Client: fc,
tsClient: tsClient, tsClient: tsClient,
recorder: fr, recorder: fr,
l: zl.Sugar(), log: zl.Sugar(),
clock: cl, clock: cl,
loginServer: tsLoginServer, loginServer: tsLoginServer,
} }

Loading…
Cancel
Save