Skip to content

feat(config,ncps): convert pkg/config to Ent and thread *database.Client through callers - #1210

Merged
kalbasit merged 1 commit into
mainfrom
feat-config-to-ent
May 23, 2026
Merged

kalbasit merged 1 commit into
mainfrom
feat-config-to-ent

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

§11.6 first batch: pkg/config now wraps *database.Client (Ent-backed) instead
of the legacy database.Querier. GetConfigByKey + SetConfig switch to the Ent
fluent API (ConfigEntry.Query/Create with OnConflictColumns upsert), and
ErrConfigNotFound is now derived from ent.IsNotFound.

All callers in pkg/ncps (serve.go, migrate_narinfo.go, migrate_nar_to_chunks.go,
fsck.go) are updated to pass *database.Client into config.New and through
getOrSetClusterUUID + detectExtraResourceAttrs.

Test factories in pkg/config and pkg/ncps now expose *database.Client so
configureCDCInDatabase / configureFsckCDCInDatabase can build a real config
service. config_test.go switches its raw config-row helpers to the Ent client
API as well.

Co-Authored-By: Claude Opus 4.7 [email protected]

@kalbasit

kalbasit commented May 21, 2026 •

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@kalbasit
kalbasit force-pushed the feat-config-to-ent branch from deba5d8 to 0eb50cd Compare May 22, 2026 23:28
@kalbasit
kalbasit force-pushed the feat-cache-pinned-orphan-narinfocdc-ent branch from 46a0899 to c666a31 Compare May 22, 2026 23:54
@kalbasit
kalbasit force-pushed the feat-config-to-ent branch from 0eb50cd to b6594a4 Compare May 22, 2026 23:54
@kalbasit
kalbasit force-pushed the feat-cache-pinned-orphan-narinfocdc-ent branch from c666a31 to e5ed9c3 Compare May 23, 2026 00:07
@kalbasit
kalbasit force-pushed the feat-config-to-ent branch 2 times, most recently from b6594a4 to 58a5d8d Compare May 23, 2026 00:07
@kalbasit
kalbasit force-pushed the feat-cache-pinned-orphan-narinfocdc-ent branch from e5ed9c3 to 3c96983 Compare May 23, 2026 00:35
@kalbasit
kalbasit force-pushed the feat-config-to-ent branch from 58a5d8d to c66e85f Compare May 23, 2026 00:35
@kalbasit
kalbasit force-pushed the feat-cache-pinned-orphan-narinfocdc-ent branch from 3c96983 to b08e715 Compare May 23, 2026 03:30
@kalbasit
kalbasit force-pushed the feat-config-to-ent branch from c66e85f to 7a1b13e Compare May 23, 2026 03:30
@kalbasit
kalbasit force-pushed the feat-cache-pinned-orphan-narinfocdc-ent branch from b08e715 to 4c96e3a Compare May 23, 2026 03:45
@kalbasit
kalbasit force-pushed the feat-config-to-ent branch from 7a1b13e to 17d8b92 Compare May 23, 2026 03:45
@kalbasit
kalbasit force-pushed the feat-cache-pinned-orphan-narinfocdc-ent branch from 4c96e3a to c87577e Compare May 23, 2026 03:57
@kalbasit
kalbasit force-pushed the feat-config-to-ent branch from 17d8b92 to 6bf8aba Compare May 23, 2026 03:57

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/ncps/fsck_test.go`:
- Line 35: The type alias fsckSetupFn has a long single-line return signature
that violates the lll rule; update its declaration (and the other long
signatures referenced around the file) to break the tuple return across multiple
lines for readability and linter compliance—for example, place each return type
on its own line and align the closing parenthesis and function type, adjusting
any matching function literals or usages (e.g., the implementations referenced
at lines around 490, 515, 530) so they use the same multiline signature
formatting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 25d089ea-06a1-49ad-846c-378e4408a2dd

📥 Commits

Reviewing files that changed from the base of the PR and between 7a1b13e and 6bf8aba.

📒 Files selected for processing (9)
  • pkg/cache/cache.go
  • pkg/config/config.go
  • pkg/config/config_test.go
  • pkg/ncps/fsck.go
  • pkg/ncps/fsck_test.go
  • pkg/ncps/migrate_nar_to_chunks.go
  • pkg/ncps/migrate_nar_to_chunks_test.go
  • pkg/ncps/migrate_narinfo.go
  • pkg/ncps/serve.go

Comment thread pkg/ncps/fsck_test.go Resolved
Base automatically changed from feat-cache-pinned-orphan-narinfocdc-ent to main May 23, 2026 04:10
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 23, 2026
…ent through callers

§11.6 first batch: pkg/config now wraps *database.Client (Ent-backed) instead
of the legacy database.Querier. GetConfigByKey + SetConfig switch to the Ent
fluent API (ConfigEntry.Query/Create with OnConflictColumns upsert), and
ErrConfigNotFound is now derived from ent.IsNotFound.

All callers in pkg/ncps (serve.go, migrate_narinfo.go, migrate_nar_to_chunks.go,
fsck.go) are updated to pass *database.Client into config.New and through
getOrSetClusterUUID + detectExtraResourceAttrs.

Test factories in pkg/config and pkg/ncps now expose *database.Client so
configureCDCInDatabase / configureFsckCDCInDatabase can build a real config
service. config_test.go switches its raw config-row helpers to the Ent client
API as well.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the feat-config-to-ent branch from 6bf8aba to cc40f62 Compare May 23, 2026 04:10
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels May 23, 2026
@kalbasit
kalbasit enabled auto-merge (squash) May 23, 2026 04:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/config/config.go`:
- Around line 12-15: The import grouping is incorrect: keep all
github.com/kalbasit/ncps/... imports in a single local-module group by moving
the entconfigentry alias import next to the other local imports (ent and
database) and remove the blank line separating them; update the import block in
pkg/config/config.go so entconfigentry, github.com/kalbasit/ncps/ent, and
github.com/kalbasit/ncps/pkg/database are contiguous, then run gofumpt/goimports
(or gci) to reformat and validate the import ordering.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4c552570-375b-4831-8f42-866d45bf78c7

📥 Commits

Reviewing files that changed from the base of the PR and between 6bf8aba and cc40f62.

📒 Files selected for processing (9)
  • pkg/cache/cache.go
  • pkg/config/config.go
  • pkg/config/config_test.go
  • pkg/ncps/fsck.go
  • pkg/ncps/fsck_test.go
  • pkg/ncps/migrate_nar_to_chunks.go
  • pkg/ncps/migrate_nar_to_chunks_test.go
  • pkg/ncps/migrate_narinfo.go
  • pkg/ncps/serve.go

Comment thread pkg/config/config.go Resolved
@codecov

codecov Bot commented May 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.68%. Comparing base (abbdbe8) to head (cc40f62).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1210   +/-   ##
=====================================
  Coverage   5.68%   5.68%           
=====================================
  Files          6       6           
  Lines        387     387           
=====================================
  Hits          22      22           
  Misses       361     361           
  Partials       4       4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalbasit
kalbasit merged commit d06c01b into main May 23, 2026
18 checks passed
@kalbasit
kalbasit deleted the feat-config-to-ent branch May 23, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code merge-stack size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant