Skip to content

feat(inventory): add connection-resolver contract and static backend#341

Draft
aparajon wants to merge 1 commit into
mainfrom
aparajon/inventory-static
Draft

feat(inventory): add connection-resolver contract and static backend#341
aparajon wants to merge 1 commit into
mainfrom
aparajon/inventory-static

Conversation

@aparajon

Copy link
Copy Markdown
Collaborator

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

  • Add pkg/inventory: the connection-resolver contract (Request/Target) plus a static, config-driven backend.
  • Kept deliberately distinct from 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

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>
Copilot AI review requested due to automatic review settings June 14, 2026 22:58

Copilot AI 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.

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.Resolver interface with Request/Target types to represent target resolution results.
  • Implemented StaticResolver that 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 thread pkg/inventory/static.go
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 thread pkg/inventory/static.go
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
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.

2 participants