kubebuilder
kubebuilder copied to clipboard
Refactor `CronJob` and `MultiVersion` Sample Code to Align with `DeployImage` Plugin Scaffold Structure
What do you want to happen?
This issue proposes refactoring the CronJob and MultiVersion samples to follow the structure and best practices introduced by the DeployImage plugin, which includes scaffolding to manage resources defined via command-line inputs, such as images.
Objectives
The main goals for this refactoring include ensure:
- Align the structure of the
CronJobandMultiVersionexamples with the scaffolded layout used by theDeployImageplugin. - Apply best practices, such as fetching the resource before updates, to prevent reconciliation conflicts due to intermediate changes.
- Integrate status conditions to better track resource states. (see that we have indeed a task for that: https://github.com/kubernetes-sigs/kubebuilder/issues/4019)
- Ensure that test implementations mirror the
DeployImagescaffolded layout, with comprehensive tests for the controller logic.(see that we have indeed a task for that: https://github.com/kubernetes-sigs/kubebuilder/issues/4140) - Retain the original logic and functionality of the
CronJobandMultiVersionexamples. - Preserve the existing markers to ensure that documentation snippets are generated and rendered consistently in the docs.
Reference Materials
To align with DeployImage scaffolding, please review the following examples:
- Controller Implementation: busybox_controller.go
- Controller Test: busybox_controller_test.go
Additional Notes
All sample updates should be implemented to ensure they match the DeployImage plugin’s scaffold structure and best practices, while still fulfilling the unique requirements of each sample (i.e., CronJob and MultiVersion functionality).
Related tasks:
- https://github.com/kubernetes-sigs/kubebuilder/issues/4019
- https://github.com/kubernetes-sigs/kubebuilder/issues/4140
Example of Motivation: https://github.com/kubernetes-sigs/kubebuilder/discussions/4290
Updating the Documentation Samples
Please note that these sample files are auto-generated for the documentation. Any changes made to these samples will be reflected in the documentation only when running make generate-docs.
The sample generation process is managed through:
- Makefile configuration: See Makefile#L82-L84.
- Documentation generation scripts: Updates should be made within
Note: We can approach this refactoring with multiple smaller PRs or a single comprehensive one. For example, we could start by adding Status Conditions, then improve the tests, and so on.
Extra Labels
No response