WIP 🐛 fix(helm/v2-alpha): Respect --force for default ServiceMonitor file#5726
WIP 🐛 fix(helm/v2-alpha): Respect --force for default ServiceMonitor file#5726camilamacedo86 wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR updates the Kubebuilder helm/v2-alpha plugin so the default fallback ServiceMonitor template respects the --force flag (preserving user modifications during chart regeneration unless --force is used), aligning its behavior with the existing NetworkPolicy fallback handling.
Changes:
- Update the ServiceMonitor fallback template to skip overwriting existing files unless
--forceis set. - Extend integration coverage to validate
--forcebehavior for the fallback ServiceMonitor file. - Add unit tests and refresh CLI/docs text describing preserved/regenerated files.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/plugins/optional/helm/v2alpha/scaffolds/test/force_integration_test.go | Extends integration tests to ensure the fallback ServiceMonitor file is preserved without --force and overwritten with --force. |
| pkg/plugins/optional/helm/v2alpha/scaffolds/internal/templates/chart-templates/servicemonitor.go | Changes default ServiceMonitor fallback behavior to SkipFile unless Force is true. |
| pkg/plugins/optional/helm/v2alpha/scaffolds/internal/templates/chart-templates/servicemonitor_test.go | Adds unit tests verifying IfExistsAction is set correctly based on Force. |
| pkg/plugins/optional/helm/v2alpha/edit.go | Updates edit command help text to document preserved files and include the fallback ServiceMonitor path. |
| pkg/plugins/optional/helm/v2alpha/edit_test.go | Updates tests to assert the updated help/usage strings mention the fallback ServiceMonitor path. |
| docs/book/src/plugins/available/helm-v2-alpha.md | Updates plugin documentation to reflect preserved files and the fallback ServiceMonitor location. |
| ├── monitoring/ | ||
| │ └── servicemonitor.yaml | ||
| │ └── servicemonitor.yaml # When kustomize output provides a ServiceMonitor | ||
| ├── prometheus/ | ||
| │ └── controller-manager-metrics-monitor.yaml # Default fallback when kustomize output does not | ||
| ├── network-policy/ |
| fs.BoolVar(&p.force, "force", false, | ||
| "If set, regenerate preserved files except Chart.yaml (values.yaml, NOTES.txt, _helpers.tpl, "+ | ||
| ".helmignore, test-chart.yml, network-policy/allow-metrics-traffic.yaml, "+ | ||
| "network-policy/allow-webhook-traffic.yaml, "+ | ||
| "prometheus/controller-manager-metrics-monitor.yaml)") |
Wire the ServiceMonitor scaffold Force flag to SkipFile/OverwriteFile so prometheus/controller-manager-metrics-monitor.yaml is preserved without --force. Co-authored-by: Cursor <cursoragent@cursor.com>
9b5b2e1 to
9cc0b51
Compare
|
Ensures that ServiceMonitor templates follow the same behavior of Network Policies (introduced
Follow-up to #5708) which either is added when not found, preserving user customizations during chart regeneration instead of overwriting them.