Skip to content

refactor: builder.go 거대 파일 리소스 concern 별 분리 (역할/책임 분리)#383

Merged
KeiaiLab-PHIL merged 2 commits into
mainfrom
refactor/split-builder-hpa
Jun 30, 2026
Merged

refactor: builder.go 거대 파일 리소스 concern 별 분리 (역할/책임 분리)#383
KeiaiLab-PHIL merged 2 commits into
mainfrom
refactor/split-builder-hpa

Conversation

@KeiaiLab-PHIL

Copy link
Copy Markdown
Contributor

요약

2593 LOC 단일 builder.go 를 응집 리소스 그룹별 파일로 분리 — 순수 함수 재배치(같은 package, 로직/시그니처 변경 0). builder.go: 2593 → 2013 LOC.

신규 파일 LOC func concern
builder_hpa.go 154 11 HPA 빌더 + Is*Active/Deliberate 가드 + metric
builder_backup.go 271 4 Backup/Restore Job + CronJob + script
builder_policy.go 204 7 PDB + NetworkPolicy (RS + sharded)

직전 분석이 지적한 builder.go 거대 파일(9+ 리소스 종류 단일 파일) 역할/책임 분리.

검증

gofmt 0 / goimports / go build OK / vet clean / golangci-lint 0 issues /
go test resources ok / controller envtest 전체 suite ok (19.6s)

후속

service/tls/configmap 빌더(builder.go 내 산재)도 동일 패턴 분리 가능. 본 PR 은 연속 블록(backup/policy/hpa)만 — 저위험 우선.

🤖 Generated with Claude Code

KeiaiLab-PHIL and others added 2 commits June 30, 2026 11:36
2593 LOC 단일 builder.go 를 응집 리소스 그룹별 파일로 분리. 순수 함수 재배치
(같은 package, 로직/시그니처 변경 0). builder.go: 2593 → 2013 LOC.

- builder_hpa.go    (154 LOC, 11 func): HPA 빌더 + Is*Active/Deliberate 가드 + metric.
- builder_backup.go (271 LOC,  4 func): Backup/Restore Job + CronJob + script.
- builder_policy.go (204 LOC,  7 func): PDB + NetworkPolicy (RS + sharded).

검증: gofmt 0 / goimports / go build OK / go vet clean / golangci-lint 0 issues /
go test resources ok / KUBEBUILDER_ASSETS=… controller envtest 전체 suite ok (19.6s).

후속: service/tls/configmap 빌더(builder.go 내 산재)도 동일 패턴 분리 가능
(이번 PR 은 연속 블록 backup/policy/hpa 만 — 저위험).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: phil <phil@keiailab.com>
builder.go 분리로 "MONGODB_URI" env 이름 리터럴이 package-wide 4회로 goconst
threshold 초과 → envMongoDBURI 상수로 통일 (builder.go ×2 + builder_backup.go ×2).

검증: gofmt 0 / go build OK / vet clean / golangci-lint 0 issues / resources test ok.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: phil <phil@keiailab.com>
@KeiaiLab-PHIL KeiaiLab-PHIL merged commit d413485 into main Jun 30, 2026
10 checks passed
@KeiaiLab-PHIL KeiaiLab-PHIL deleted the refactor/split-builder-hpa branch June 30, 2026 02:53
KeiaiLab-PHIL added a commit that referenced this pull request Jun 30, 2026
builder.go(2017→1837 LOC)에서 TLS + ConfigMap 빌더를 응집 파일로 추가 분리
(순수 재배치, 로직/시그니처 변경 0). hpa/backup/policy(1차, #383)에 이어 누적
builder.go 2705→1837 LOC (-32%, 6 concern 파일).

- builder_tls.go      (121 LOC): PEM merge init container + TLS volume/mount/args.
- builder_configmap.go ( 89 LOC): MongoDB/Custom/cfg/shard scripts ConfigMap.

공유 const(MongoTLSMountPath/PEMPath, scriptReadiness 등) + script helper 는
builder.go 잔류(같은 package 참조).

검증: gofmt 0 / go build OK / vet clean / golangci-lint 0 issues / resources test ok /
KUBEBUILDER_ASSETS=… controller envtest 전체 suite ok.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: phil <phil@keiailab.com>
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