Skip to content

Commit

Permalink
Shorten UpdateNodeLabelsAndRecordEvents function in nmc_reconciler.go
Browse files Browse the repository at this point in the history
Today, the UpdateNodeLabelsAndRecordEvents function has around 100 lines of code. This commit aims to enhance its readability and maintainability by using helper functions, thereby reducing its total length.
Additionally, adding unit tests that covers the new helper functions.
  • Loading branch information
TomerNewman committed Jul 3, 2024
1 parent 9c3f7c8 commit 8601713
Show file tree
Hide file tree
Showing 7 changed files with 973 additions and 87 deletions.
3 changes: 2 additions & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func main() {
buildHelperAPI := build.NewHelper()
nodeAPI := node.NewNode(client)
kernelAPI := module.NewKernelMapper(buildHelperAPI, sign.NewSignerHelper())
lph := controllers.NewLabelPreparationHelper()

dpc := controllers.NewDevicePluginReconciler(
client,
Expand Down Expand Up @@ -149,7 +150,7 @@ func main() {

eventRecorder := mgr.GetEventRecorderFor("kmm")

if err = controllers.NewNMCReconciler(client, scheme, workerImage, &cfg.Worker, eventRecorder, nodeAPI).SetupWithManager(ctx, mgr); err != nil {
if err = controllers.NewNMCReconciler(client, scheme, workerImage, &cfg.Worker, eventRecorder, nodeAPI, lph).SetupWithManager(ctx, mgr); err != nil {
cmd.FatalError(setupLogger, err, "unable to create controller", "name", controllers.NodeModulesConfigReconcilerName)
}

Expand Down
109 changes: 102 additions & 7 deletions internal/controllers/mock_nmc_reconciler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8601713

Please sign in to comment.