Skip to content

Commit 0e162b2

Browse files
committed
logs: remove/replace WithName
1 parent edbd00c commit 0e162b2

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

controllers/bucket_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const bucketFinalizer = "s3.onyxia.sh/finalizer"
5858
// For more details, check Reconcile and its Result here:
5959
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
6060
func (r *BucketReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
61-
logger := log.FromContext(ctx).WithName("bcktCtrl")
61+
logger := log.FromContext(ctx)
6262

6363
// Checking for bucket resource existence
6464
bucketResource := &s3v1alpha1.Bucket{}
@@ -244,7 +244,7 @@ func (r *BucketReconciler) finalizeBucket(bucketResource *s3v1alpha1.Bucket) err
244244
}
245245

246246
func (r *BucketReconciler) SetBucketStatusConditionAndUpdate(ctx context.Context, bucketResource *s3v1alpha1.Bucket, conditionType string, status metav1.ConditionStatus, reason string, message string, srcError error) (ctrl.Result, error) {
247-
logger := log.FromContext(ctx).WithName("bcktCtrl")
247+
logger := log.FromContext(ctx)
248248

249249
// We moved away from meta.SetStatusCondition, as the implementation did not allow for updating
250250
// lastTransitionTime if a Condition (as identified by Reason instead of Type) was previously

controllers/path_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const pathFinalizer = "s3.onyxia.sh/finalizer"
5858
// For more details, check Reconcile and its Result here:
5959
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
6060
func (r *PathReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
61-
logger := log.FromContext(ctx).WithName("pathCtrl")
61+
logger := log.FromContext(ctx)
6262

6363
// Checking for path resource existence
6464
pathResource := &s3v1alpha1.Path{}
@@ -184,7 +184,7 @@ func (r *PathReconciler) SetupWithManager(mgr ctrl.Manager) error {
184184
}
185185

186186
func (r *PathReconciler) finalizePath(pathResource *s3v1alpha1.Path) error {
187-
logger := log.Log.WithName("finalize")
187+
logger := log.Log.WithValues("controller", "path")
188188
if r.PathDeletion {
189189
var failedPaths []string = make([]string, 0)
190190
for _, path := range pathResource.Spec.Paths {
@@ -210,7 +210,7 @@ func (r *PathReconciler) finalizePath(pathResource *s3v1alpha1.Path) error {
210210
}
211211

212212
func (r *PathReconciler) SetPathStatusConditionAndUpdate(ctx context.Context, pathResource *s3v1alpha1.Path, conditionType string, status metav1.ConditionStatus, reason string, message string, srcError error) (ctrl.Result, error) {
213-
logger := log.FromContext(ctx).WithName("pathCtrl")
213+
logger := log.FromContext(ctx)
214214

215215
// We moved away from meta.SetStatusCondition, as the implementation did not allow for updating
216216
// lastTransitionTime if a Condition (as identified by Reason instead of Type) was previously

controllers/policy_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const policyFinalizer = "s3.onyxia.sh/finalizer"
6161
// For more details, check Reconcile and its Result here:
6262
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
6363
func (r *PolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
64-
logger := log.FromContext(ctx).WithName("plcyCtrl")
64+
logger := log.FromContext(ctx)
6565

6666
// Checking for policy resource existence
6767
policyResource := &s3v1alpha1.Policy{}
@@ -218,7 +218,7 @@ func (r *PolicyReconciler) finalizePolicy(policyResource *s3v1alpha1.Policy) err
218218
}
219219

220220
func (r *PolicyReconciler) SetPolicyStatusConditionAndUpdate(ctx context.Context, policyResource *s3v1alpha1.Policy, conditionType string, status metav1.ConditionStatus, reason string, message string, srcError error) (ctrl.Result, error) {
221-
logger := log.FromContext(ctx).WithName("plcyCtrl")
221+
logger := log.FromContext(ctx)
222222

223223
// We moved away from meta.SetStatusCondition, as the implementation did not allow for updating
224224
// lastTransitionTime if a Condition (as identified by Reason instead of Type) was previously

controllers/s3/factory/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
var (
12-
s3Logger = ctrl.Log.WithName("s3Client")
12+
s3Logger = ctrl.Log.WithValues("logger", "s3client")
1313
)
1414

1515
type S3Client interface {

controllers/user_controller.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const (
6767
// For more details, check Reconcile and its Result here:
6868
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
6969
func (r *S3UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
70-
logger := log.FromContext(ctx).WithName("userCtrl")
70+
logger := log.FromContext(ctx)
7171

7272
// Checking for userResource existence
7373
userResource := &s3v1alpha1.S3User{}
@@ -120,7 +120,7 @@ func (r *S3UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
120120
}
121121

122122
func (r *S3UserReconciler) handleS3ExistingUser(ctx context.Context, userResource *s3v1alpha1.S3User) (reconcile.Result, error) {
123-
logger := log.FromContext(ctx).WithName("userCtrl")
123+
logger := log.FromContext(ctx)
124124

125125
// --- Begin Secret management section
126126

@@ -239,7 +239,7 @@ func (r *S3UserReconciler) handleS3ExistingUser(ctx context.Context, userResourc
239239
}
240240

241241
func (r *S3UserReconciler) handleS3NewUser(ctx context.Context, userResource *s3v1alpha1.S3User) (reconcile.Result, error) {
242-
logger := log.FromContext(ctx).WithName("userCtrl")
242+
logger := log.FromContext(ctx)
243243

244244
// Generating a random secret key
245245
secretKey, err := password.Generate(20, true, false, true)
@@ -357,7 +357,7 @@ func (r *S3UserReconciler) handleS3NewUser(ctx context.Context, userResource *s3
357357
}
358358

359359
func (r *S3UserReconciler) addPoliciesToUser(ctx context.Context, userResource *s3v1alpha1.S3User) error {
360-
logger := log.FromContext(ctx).WithName("userCtrl")
360+
logger := log.FromContext(ctx)
361361
policies := userResource.Spec.Policies
362362
if policies != nil {
363363
err := r.S3Client.AddPoliciesToUser(userResource.Spec.AccessKey, policies)
@@ -370,7 +370,7 @@ func (r *S3UserReconciler) addPoliciesToUser(ctx context.Context, userResource *
370370
}
371371

372372
func (r *S3UserReconciler) handleS3UserDeletion(ctx context.Context, userResource *s3v1alpha1.S3User) (reconcile.Result, error) {
373-
logger := log.FromContext(ctx).WithName("userCtrl")
373+
logger := log.FromContext(ctx)
374374

375375
if controllerutil.ContainsFinalizer(userResource, userFinalizer) {
376376
// Run finalization logic for S3UserFinalizer. If the finalization logic fails, don't remove the finalizer so that we can retry during the next reconciliation.
@@ -397,7 +397,7 @@ func (r *S3UserReconciler) handleS3UserDeletion(ctx context.Context, userResourc
397397
}
398398

399399
func (r *S3UserReconciler) getUserSecret(ctx context.Context, userResource *s3v1alpha1.S3User) (corev1.Secret, error) {
400-
logger := log.FromContext(ctx).WithName("userCtrl")
400+
logger := log.FromContext(ctx)
401401

402402
// Listing every secrets in the S3User's namespace, as a first step
403403
// to get the actual secret matching the S3User proper.
@@ -443,7 +443,7 @@ func (r *S3UserReconciler) getUserSecret(ctx context.Context, userResource *s3v1
443443
}
444444

445445
func (r *S3UserReconciler) deleteSecret(ctx context.Context, secret *corev1.Secret) {
446-
logger := log.FromContext(ctx).WithName("userCtrl")
446+
logger := log.FromContext(ctx)
447447
err := r.Delete(ctx, secret)
448448
if err != nil {
449449
logger.Error(err, "an error occurred while deleting a secret")
@@ -492,7 +492,7 @@ func (r *S3UserReconciler) SetupWithManager(mgr ctrl.Manager) error {
492492
}
493493

494494
func (r *S3UserReconciler) setS3UserStatusConditionAndUpdate(ctx context.Context, userResource *s3v1alpha1.S3User, conditionType string, status metav1.ConditionStatus, reason string, message string, srcError error) (ctrl.Result, error) {
495-
logger := log.FromContext(ctx).WithName("userCtrl")
495+
logger := log.FromContext(ctx)
496496

497497
// We moved away from meta.SetStatusCondition, as the implementation did not allow for updating
498498
// lastTransitionTime if a Condition (as identified by Reason instead of Type) was previously
@@ -524,7 +524,7 @@ func (r *S3UserReconciler) finalizeS3User(userResource *s3v1alpha1.S3User) error
524524
// newSecretForCR returns a secret with the same name/namespace as the CR.
525525
// The secret will include all labels and annotations from the CR.
526526
func (r *S3UserReconciler) newSecretForCR(ctx context.Context, userResource *s3v1alpha1.S3User, data map[string][]byte) (*corev1.Secret, error) {
527-
logger := log.FromContext(ctx).WithName("userCtrl")
527+
logger := log.FromContext(ctx)
528528

529529
labels := map[string]string{}
530530
for k, v := range userResource.ObjectMeta.Labels {

0 commit comments

Comments
 (0)