villebro opened a new pull request, #136:
URL: https://github.com/apache/superset-kubernetes-operator/pull/136
## Summary
This is the first of three sequential, escalating-risk PRs from a codebase
idiomaticity sweep. It targets the **pure, controller-runtime-free packages**
(`internal/resolution/`, `internal/config/`), which are covered by extensive
unit + fuzz tests, so regression risk is minimal.
The packages had accumulated several blocks of copy-pasted logic differing
only in type or in a single field. This collapses them behind small generic
helpers so the intent is expressed once — making the merge and config-rendering
code easier to read and extend without per-type variants that can silently
drift apart. **All changes are behavior-preserving.**
## Details
- **`internal/resolution/merge.go`**: the six name/IP-keyed merge functions
(`MergeEnvVars`, `MergeVolumes`, `MergeVolumeMounts`, `MergeHostAliases`,
`MergeContainerPorts`, `MergeContainers`) now delegate to a single generic
`mergeByKey`; the three identical `safe*Template` helpers (plus the matching
`safe*Input` helpers in `resolver.go`) collapse into one generic `orEmpty`.
`MergeMaps` uses `maps.Copy` and drops a dead empty-result check (unreachable
once `size == 0` returns early).
- **`internal/config`**: a generic `setIf` collapses the ~20 repeated `if
spec.X != nil { r.X = *spec.X }` overrides across `gunicorn.go`, `celery.go`,
and `engine_options.go`; `writeConfigSection` deduplicates the two identical
config-block writers in `renderer.go`; `renderEngineOptions` is flattened with
an early-return guard; and the celery worker command uses an `appendIntFlag`
helper for its conditional flags.
Net ~137 fewer lines.
## Verification
- `make test-unit` passes unchanged — `internal/resolution` 100%,
`internal/config` 99.2% coverage.
- `make lint` → 0 issues.
- `make codegen` → no diff.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]