From 2f05069e011eddfc5d39b7c13bfcdcfd0ea5c9de Mon Sep 17 00:00:00 2001 From: Andy Kolibri Vendetti Date: Thu, 1 May 2025 19:39:58 +0500 Subject: [PATCH] linter fixes --- cmd/main.go | 4 ++-- .../deploymentdefaults_controller.go | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 7e82a14..0974cfe 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -204,8 +204,8 @@ func main() { } if err = (&controller.NodeTainterConfigReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), Recorder: mgr.GetEventRecorderFor("nodetainter-controller"), }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "NodeTainterConfig") diff --git a/internal/controller/deploymentdefaults_controller.go b/internal/controller/deploymentdefaults_controller.go index 98b4d44..0214cfe 100644 --- a/internal/controller/deploymentdefaults_controller.go +++ b/internal/controller/deploymentdefaults_controller.go @@ -80,15 +80,23 @@ func (r *DeploymentDefaultsReconciler) Reconcile(ctx context.Context, req ctrl.R defaultMemLim, errMemLim := parseQuantity(defaults.MemoryLimit) var parseErrors []string - if errCPUReq != nil { parseErrors = append(parseErrors, fmt.Sprintf("CPURequest: %v", errCPUReq)) } - if errMemReq != nil { parseErrors = append(parseErrors, fmt.Sprintf("MemoryRequest: %v", errMemReq)) } - if errCPULim != nil { parseErrors = append(parseErrors, fmt.Sprintf("CPULimit: %v", errCPULim)) } - if errMemLim != nil { parseErrors = append(parseErrors, fmt.Sprintf("MemoryLimit: %v", errMemLim)) } + if errCPUReq != nil { + parseErrors = append(parseErrors, fmt.Sprintf("CPURequest: %v", errCPUReq)) + } + if errMemReq != nil { + parseErrors = append(parseErrors, fmt.Sprintf("MemoryRequest: %v", errMemReq)) + } + if errCPULim != nil { + parseErrors = append(parseErrors, fmt.Sprintf("CPULimit: %v", errCPULim)) + } + if errMemLim != nil { + parseErrors = append(parseErrors, fmt.Sprintf("MemoryLimit: %v", errMemLim)) + } if len(parseErrors) > 0 { - errMsg := fmt.Sprintf("Invalid resource quantity format in NodeTainterConfig %s: %s", config.Name, strings.Join(parseErrors, "; ")) - log.Error(fmt.Errorf(errMsg), "Default resource parsing failed") - r.Recorder.Eventf(&deployment, corev1.EventTypeWarning, "ConfigError", "Invalid defaults in config %s: %s", config.Name, strings.Join(parseErrors, "; ")) + parsingError := fmt.Errorf("invalid resource quantity format in NodeTainterConfig %s: %s", config.Name, strings.Join(parseErrors, "; ")) + log.Error(parsingError, "Default resource parsing failed", "configName", config.Name, "parsingErrors", parseErrors) + r.Recorder.Eventf(&deployment, corev1.EventTypeWarning, "ConfigError", parsingError.Error()) return ctrl.Result{}, nil }