refactor: introduce Client type, remove TUI from library, eliminate init() side effects#361
Open
refactor: introduce Client type, remove TUI from library, eliminate init() side effects#361
Conversation
2199ce7 to
cde3419
Compare
Break config->dbc import cycle by moving ToPackageInfo() helper to cmd/dbc, allowing the dbc package to import config without circular dependency. Add thin Client wrappers for GetConfig, ListInstalled, GetDriver, CreateManifest.
- Delete delegates.go (moved to cmd/dbc in T3) - Delete file_progress_model.go (moved to cmd/dbc in T3) - Dependency tree now CLEAN: zero charm.land packages in library - Library consumers no longer pull bubbletea/lipgloss/bubbles - All tests pass (6 packages) - Build succeeds with no errors Fixes: Library API refactor goal of clean dependency tree for consumers
- Fix infinite recursion in tui_driver_list.go String() method by converting to underlying semver.Version type - Remove dead code from drivers.go: package-level registries variable, getDriverListFromIndex function, and getDrivers sync.OnceValues - Remove DBC_BASE_URL override block from ensureSetup() since registries is now dead - Update GetDriverList() to respect DBC_BASE_URL environment variable by passing WithBaseURL option to NewClient - Remove unused registryErrors fields from docs.go and info.go structs - Add doc comments to all exported Client API functions and methods - Remove unused yaml import from drivers.go
… defer and composite literal
…e before RemoveAll
… overwrite in test, add sync.Once to getDriverRegistry lazy init
…xt for retry, send fatal errors to stderr
… client init with sync.Once in initDBCClient
…is visible on subsequent calls
… via buildLegacyReq closure
…t the retry request
…arch coupling to TestMain
…InstallTestServer
…equest in uaRoundTripper before mutating headers
…ring in parse error message
cde3419 to
fcb2c19
Compare
…ocsUrl to DocsURL
…est error, fix temp dir leak and double-close
…ir on create failure
…itize PR title input
…ase, close body before non-200 return in fetch
… empty PkgInfo, hint --pre for prerelease versions
… filter condition
…eturns VersionInfo, deduplicate test boilerplate
…test helpers, add deprecation tags
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.
Summary
This branch refactors the
dbcpackage from a package-global,init()-heavy design to a clean library API:Clienttype with functional options (WithHTTPClient,WithRegistries,WithBaseURL,WithUserAgent,WithCredential,WithAuthFromFilesystem) replacing package-level singletonsdbcandconfigpackages —import "github.com/columnar-tech/dbc"now pulls zero bubbletea/lipgloss/bubbles transitive deps; widgets moved tocmd/dbcinit()side effects eliminated — no disk writes, nohttp.DefaultClientmutation at import time; lazysync.Once-based setup only triggered on first network callGetDriverList,DefaultClient) with forwarding shims for backward compatibility; CLI migrated to useClientinternallyNew Client API
Testing
All tests pass (
go test ./...). Branch reviewed and passed by automated code review (27 commits, roborev job 1027).