Repository navigation
refactor(service): split generator.go by object kind and shorten the long builders - #320
Merged
Merged
Conversation
… Services generateRedisMasterService and generateRedisSlaveService were a dupl clone of 32 lines each (cyclomatic 1). Both call generateRedisRoleService with their name and role label. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
generateRedisShutdownConfigMap: 149 -> 29 lines, cyclomatic 2 -> 2. The script text and its comment move unchanged to redisShutdownFailoverScript, so shutdown.sh stays byte-identical. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
generateRedisReadinessConfigMap: 88 -> 20 lines, cyclomatic 1 -> 1. The script text moves unchanged to redisReadinessScript, so ready.sh stays byte-identical. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
generateRedisStatefulSet: 202 -> 44 lines, cyclomatic 10 -> 1, cognitive 12 -> 0. The pod spec, the Redis container, the probes, the volume claim template and the auth checksum each get a builder. startupScriptProbe holds the startup probe that the Sentinel builder also uses. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
generateSentinelDeployment: 179 -> 30 lines, cyclomatic 9 -> 1, cognitive 10 -> 0. The pod spec, the config copy container, the Sentinel container and the probes each get a builder. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
generator.go: 1622 -> 226 lines. The declarations move unchanged to generator_service.go (135), generator_configmap.go (368), generator_statefulset.go (495), generator_deployment.go (275) and generator_exporter.go (169). The shared const block and the shared pod helpers stay in generator.go. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed on the PR:
generateRedisStatefulSet(202 lines) andgenerateSentinelDeployment(179 lines) into builders for the pod spec, the containers and the probes. Each function is then below 80 lines.shutdown.shandready.shto constants. The script text stays byte-identical.Tests:
TestGeneratedObjectsGoldenpasses with unchanged golden files. The unit tests ofoperator/redisfailover/servicepass, also with-race -count=3. A scratch harness compared the JSON of all 12 generated objects (and the input after the calls) for 6062 RedisFailover variants (30 option toggles: all on, all off, each single toggle, each all-but-one, 6000 random masks) on main and on this branch: the output is byte-identical after every commit. No test was added, because the refactor does not change behavior and each changed function was already at 100% coverage. Not tested: a cluster run.Found and not changed:
createRedisExporterContainer,createSentinelExporterContainerandgetContainersWithRedisEnvappend to slices from the user's spec. With spare capacity, the append can write into the backing array of the RedisFailover. The harness shows that the output does not change.🤖 Generated with Claude Code
https://claude.ai/code/session_01G4mmyo3sqLwf23m5FE2nBE
Generated by Claude Code