Skip to content

refactor(service): split generator.go by object kind and shorten the long builders - #320

Merged
Saremox merged 6 commits into
mainfrom
claude/quality-r6-generator
Oct 16, 2026
Merged

Saremox merged 6 commits into
mainfrom
claude/quality-r6-generator

Conversation

@Saremox

@Saremox Saremox commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Changes proposed on the PR:

  • Split generator.go (1597 lines) into generator_service.go, generator_configmap.go, generator_statefulset.go, generator_deployment.go and generator_exporter.go. The declarations move unchanged, so each file has one object kind.
  • Split generateRedisStatefulSet (202 lines) and generateSentinelDeployment (179 lines) into builders for the pod spec, the containers and the probes. Each function is then below 80 lines.
  • Move the Sentinel part of shutdown.sh and ready.sh to constants. The script text stays byte-identical.
  • Share one builder for the Redis master and replica Services, to remove a dupl clone.

Tests: TestGeneratedObjectsGolden passes with unchanged golden files. The unit tests of operator/redisfailover/service pass, 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, createSentinelExporterContainer and getContainersWithRedisEnv append 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

… 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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T09:45:35.770722Z 5870d3d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.04306% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...rator/redisfailover/service/generator_configmap.go 91.83% 4 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@Saremox
Saremox merged commit b5ce12f into main Oct 16, 2026
17 checks passed
@Saremox
Saremox deleted the claude/quality-r6-generator branch October 16, 2026 12:10
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.

2 participants