feat(inventory): add connection-resolver contract and static backend#341
Draft
aparajon wants to merge 1 commit into
Draft
feat(inventory): add connection-resolver contract and static backend#341aparajon wants to merge 1 commit into
aparajon wants to merge 1 commit into
Conversation
Add pkg/inventory: the connection-resolver seam that answers "how do I connect to a target?" (target -> DSN + engine metadata). Ships the contract (Request/Target) plus a static, config-driven backend. This is distinct from pkg/routing.Resolver, which answers "where does work go?" — inventory carries no routing or execution-namespace concerns; MySQL schema names come from schema files at execution time, not from the target. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Introduces a new pkg/inventory leaf package that defines an inventory “connection resolver” contract (target → DSN + metadata) and provides a static, config-backed implementation intended as an initial backend for the data plane.
Changes:
- Added an
inventory.Resolverinterface withRequest/Targettypes to represent target resolution results. - Implemented
StaticResolverthat resolves targets from a YAML-configurable map, including secret reference resolution and MySQL DSN validation. - Added unit tests covering happy paths, metadata cloning, file/env secret references, and validation errors.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/inventory/target.go | Defines the inventory resolver contract (Request, Target, Resolver). |
| pkg/inventory/static.go | Adds a static, config-driven resolver implementation with DSN resolution and MySQL validation. |
| pkg/inventory/static_test.go | Adds tests for the static resolver behavior and validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+39
to
+51
| for target, entry := range config.Targets { | ||
| if target == "" { | ||
| return nil, fmt.Errorf("static target resolver contains an empty target key") | ||
| } | ||
| if err := validateStaticTarget(target, entry); err != nil { | ||
| return nil, err | ||
| } | ||
| targets[target] = StaticTarget{ | ||
| DatabaseType: entry.DatabaseType, | ||
| DSN: entry.DSN, | ||
| Metadata: maps.Clone(entry.Metadata), | ||
| } | ||
| } |
Comment on lines
+70
to
+78
| dsn, err := secrets.Resolve(entry.DSN, "") | ||
| if err != nil { | ||
| return nil, fmt.Errorf("resolve DSN for target %q: %w", req.Target, err) | ||
| } | ||
| if dsn == "" { | ||
| return nil, fmt.Errorf("target %q resolved an empty DSN", req.Target) | ||
| } | ||
| if err := validateResolvedStaticTargetDSN(req.Target, entry.DatabaseType, dsn); err != nil { | ||
| return nil, err |
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.
Why
The data plane needs a reusable way to answer "how do I connect to this target?" (target → DSN + engine metadata) that deployments can start with as static config and later back with a dynamic inventory source.
What
pkg/inventory: the connection-resolver contract (Request/Target) plus a static, config-driven backend.pkg/routing.Resolver, which answers "where does work go?". Inventory carries no routing decisions and no execution-namespace concerns — MySQL schema names come from schema files at execution time, not from the target.Risk
Low — additive, new package, not wired into any default path. This is a leaf of the larger data-plane routing work in #339.
🤖 Generated with Claude Code