Use existing util helpers when updating the Makefile for SSA

Author: camilamacedo86Created Jul 3, 2026Updated Jul 22, 2026

Summary

addApplyConfigGenToMakefile currently edits the generated Makefile using manual file operations (os.Stat, os.ReadFile, strings.Replace, and os.WriteFile) together with a //nolint:gosec directive.

Kubebuilder already provides helper functions such as util.HasFileContentWith and util.ReplaceInFile for this type of update.

Expected behavior

The Makefile update should use the existing utility helpers instead of manual file handling while keeping the current behavior.

If the expected replacement cannot be applied, the function should return an error instead of silently leaving the Makefile unchanged.

Tasks

  • Rewrite addApplyConfigGenToMakefile to use util.HasFileContentWith and util.ReplaceInFile.
  • Remove the manual file handling and the //nolint:gosec directive.
  • Return an error if the expected help-comment replacement cannot be applied.

Source: kubernetes-sigs/kubebuilder