refactor(project): move dump logic into internal packages - #1358
Open
Soner (shyim) wants to merge 1 commit into
Open
refactor(project): move dump logic into internal packages#1358Soner (shyim) wants to merge 1 commit into
Soner (shyim) wants to merge 1 commit into
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Soner (shyim)
force-pushed
the
refactor/dump-command
branch
from
August 12, 2026 06:22
e448a2b to
58e7f96
Compare
Soner (shyim)
marked this pull request as ready for review
August 12, 2026 06:25
Tomasz Turkowski (tturkowski)
approved these changes
Aug 12, 2026
The dump command's RunE held nearly all logic inline: DB opening, config mutation, --limit parsing, output/compression writer setup and error rewriting. Move the orchestration into shop.DumpDatabase with an options struct and the compression/output handling into mysqldump (typed Compression string with ParseCompression, OpenOutput), following the thin-command convention used by project sbom and project create. Behavior changes: the sql.DB, the output file and the compressor are now always closed (previously leaked), and an unknown --compression value is now an error instead of silently producing an uncompressed dump. Also removes the unused mysqldump.Config. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Soner (shyim)
force-pushed
the
refactor/dump-command
branch
from
August 13, 2026 08:52
58e7f96 to
23d4ef3
Compare
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.
What changed?
Refactors the
project dumpcommand:cmd/project/project_dump.goheld nearly all logic inline in itsRunE(255 lines). The logic now lives in internal packages, following the thin-command convention used byproject sbomandproject create:internal/shop/dump.go— newshop.DumpDatabase(ctx, sqlCfg, cfg, opts)entry point with aDumpDatabaseOptionsstruct. Owns config mutation (--clean/--anonymize/--limitoverrides/faker normalization), theConfigDump→mysqldump.Dumpermapping, and the dump run.internal/mysqldump/output.go— new typedCompressionstring (CompressionNone/CompressionGzip/CompressionZstd) withParseCompressionfor the flag boundary, andOpenOutput, which layers the compressor over the output file behind a singleio.WriteCloser(replaces the previousw.(*zstd.Encoder)/w.(*gzip.Writer)type assertions).cmd/project/project_dump.goshrinks to 151 lines;RunEis now flag reading plus one delegation call. Only genuine CLI concerns remain: flag registration, connection resolution, and the interactive password prompt.mysqldump.Config/NewConfig/ConnectionString(dead code).Deliberate behavior changes:
*sql.DB, the output file, and the compression writer are now always closed, including on error paths. Previously all three leaked, and a failed compressor flush could silently truncate a dump —Closeerrors are now reported.--compressionvalue is now a hard error (unsupported compression "bogus" (supported: gzip, zstd)); previously it silently produced an uncompressed dump without a suffix.CLI flags and their behavior are otherwise unchanged.
Why?
The repo convention is thin cobra wrappers delegating to internal packages (no cobra imports under
internal/). Having the dump orchestration inline made it untestable without cobra scaffolding and mixed CLI concerns with dump logic. The move also surfaced and fixed the resource-leak bugs listed above.How was this tested?
internal/mysqldump/output_test.go(compression parsing, gzip/zstd round-trips, stdout never closed) andinternal/shop/dump_test.go(limit-override parsing and validation, YAMLorder_bypreserved when--limitoverridesrows).assembleConnectionURItests pass unchanged.go test ./...andgolangci-lint runpass; manually verified--compression bogusnow errors.Related issue or discussion
Stacked on #1357.
🤖 Generated with Claude Code