Skip to content

refactor(resources): consolidate deployment helpers and remove duplication - #10

Merged
birdmanmandbir merged 2 commits into
mainfrom
refactor/consolidate-deployment-helpers
Jan 3, 2026
Merged

refactor(resources): consolidate deployment helpers and remove duplication#10
birdmanmandbir merged 2 commits into
mainfrom
refactor/consolidate-deployment-helpers

Conversation

@birdmanmandbir

Copy link
Copy Markdown
Contributor

Summary

  • Deduplicate KongConfigMapName function (was defined in both configmaps/ and deployments/)
  • Add ReloaderAnnotation constant to replace hardcoded strings
  • Extract common deployment patterns into helpers:
    • BuildHTTPProbe/BuildLivenessProbe/BuildReadinessProbe for probe configuration
    • NormalizeReplicas for default replica handling
    • AddImagePullSecrets for image pull secret configuration
  • Add generic reconcileServiceComponent helper to controller
  • Refactor 4 service reconcilers to use the generic helper

Changes

Metric Before After Change
Go code lines 3,763 3,702 -61
Insertions - 296 -
Deletions - 318 -

Test plan

  • go build ./... passes
  • go test ./pkg/... -v passes

…ation

- Add common/names.go with centralized KongConfigMapName (was duplicated)
- Add ReloaderAnnotation constant to common/labels.go
- Create deployments/helpers.go with:
  - ProbeConfig type and BuildHTTPProbe/BuildLivenessProbe/BuildReadinessProbe
  - NormalizeReplicas, AddImagePullSecrets, BuildDatabaseEnv helpers
- Update all deployment builders to use new helpers
- Add generic reconcileServiceComponent helper to controller
- Refactor 4 service reconcilers (Auth, Rest, Studio, Meta) to use helper

Co-Authored-By: Claude <noreply@anthropic.com>
@birdmanmandbir
birdmanmandbir force-pushed the refactor/consolidate-deployment-helpers branch from 39e3353 to aee2e40 Compare January 3, 2026 05:23
- Add newServiceReconcileConfig constructor to enforce required fields at
  compile time instead of runtime validation
- Use BuildDatabaseEnv helper in auth.go and rest.go to reduce duplication
- Add doc comments to ProbeConfig fields with typical value ranges
@birdmanmandbir
birdmanmandbir merged commit f285687 into main Jan 3, 2026
3 checks passed
@birdmanmandbir
birdmanmandbir deleted the refactor/consolidate-deployment-helpers branch January 3, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant