metadata

package
v0.510.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

Metadata Interface Module

Shared helpers for metadata-aware and offline interface adapters.

Files

File Responsibility
connection.go Validates direct connection inputs, resolves passwords, and expands ~ paths for transport adapters
connection_test.go Verifies shared validation and password-resolution behavior
existence.go Shared offline existence caveat (ExistenceNotCheckedNote, OfflineExistenceUnproven) for CLI, HTTP, and MCP context

Exports

  • ConnectionInput — includes separate database/schema fields and connect_timeout for metadata connection selection
  • ErrorKind
  • ConnectionInputError
  • ResolveConnectionOptions
  • IsConnectionInputError(err)
  • ValidateConnectionInput(input) — validates connection shape including connect_timeout when present
  • ResolvePassword(input, options)
  • ParseConnectTimeout(input) — parses ConnectionInput.ConnectTimeout into time.Duration
  • ExpandHome(path)
  • ExistenceNotCheckedNote
  • OfflineExistenceUnproven()

Notes

  • This package owns direct-connection validation and secret resolution shared by transport adapters.
  • It also owns the offline existence caveat string and unproven values so CLI, HTTP, and MCP do not fork that contract.
  • It does not load transport-specific connection references or assemble adapter-specific connection state.
  • MCP and future metadata-aware adapters should depend on this package instead of duplicating host, socket, and password handling.

Dependencies

  • Upstream: transport adapters under internal/interfaces
  • Downstream: MCP direct-connection resolution and future metadata-aware adapters

Update Rule

  • If exports, behavior, or dependencies change, update this file in the same change.

Documentation

Overview

Package metadata exposes shared helpers for metadata-aware and offline interface adapters. input: transport-layer connection inputs, secret lookup sources, and offline-audit context needs output: normalized connection helpers, including database/catalog selection, plus the shared offline existence caveat for interface adapters pos: shared helper boundary used by CLI, HTTP, and MCP transports note: if this file changes, update this header and module README.md.

Package metadata exposes shared helpers for metadata-aware and offline interface adapters. input: transport-layer connection inputs and offline-audit context needs output: connection helpers plus the shared offline existence caveat for CLI, HTTP, and MCP pos: shared interface-adapter helpers used when a transport did not attach a snapshot note: if this file changes, update this header and module README.md.

Index

Constants

View Source
const ExistenceNotCheckedNote = "existence not checked (no database connection)"

ExistenceNotCheckedNote is the offline limitation on CLI, HTTP, and MCP context when the adapter did not attach a table snapshot.

Variables

This section is empty.

Functions

func ExpandHome

func ExpandHome(path string) (string, error)

ExpandHome expands a leading ~ in path values.

func IsConnectionInputError

func IsConnectionInputError(err error) bool

IsConnectionInputError reports whether err is a shared direct-connection input failure.

func OfflineExistenceUnproven added in v0.490.0

func OfflineExistenceUnproven() []string

OfflineExistenceUnproven lists schema facts the offline path did not prove.

func ParseConnectTimeout added in v0.63.0

func ParseConnectTimeout(input ConnectionInput) (time.Duration, bool, error)

ParseConnectTimeout parses the ConnectTimeout field from a ConnectionInput. Empty/zero returns (0, false, nil). Invalid/negative durations return a ConnectionInputError.

func ResolvePassword

func ResolvePassword(input ConnectionInput, options ResolveConnectionOptions) (string, error)

ResolvePassword resolves a password from direct, env, or file sources.

func ValidateConnectionInput

func ValidateConnectionInput(input ConnectionInput) error

ValidateConnectionInput validates direct connection input shape and transport constraints.

Types

type ConnectionInput

type ConnectionInput struct {
	Host           string `json:"host,omitempty" yaml:"host"`
	Port           int    `json:"port,omitempty"`
	Socket         string `json:"socket,omitempty" yaml:"socket"`
	User           string `json:"user,omitempty" yaml:"user"`
	Database       string `json:"database,omitempty" yaml:"database"`
	Schema         string `json:"schema,omitempty" yaml:"schema"`
	Dialect        string `json:"dialect,omitempty" yaml:"dialect"`
	Password       string `json:"password,omitempty" yaml:"password"`
	PasswordEnv    string `json:"password_env,omitempty" yaml:"password_env"`
	PasswordFile   string `json:"password_file,omitempty" yaml:"password_file"`
	ConnectTimeout string `json:"connect_timeout,omitempty" yaml:"connect_timeout"`
}

ConnectionInput describes one direct metadata-aware connection input.

type ConnectionInputError

type ConnectionInputError struct {
	Kind    ErrorKind
	Message string
	Err     error
}

ConnectionInputError preserves the user-facing message while exposing adapter-safe classification.

func (*ConnectionInputError) Error

func (e *ConnectionInputError) Error() string

func (*ConnectionInputError) Unwrap

func (e *ConnectionInputError) Unwrap() error

type ErrorKind

type ErrorKind string

ErrorKind classifies shared direct-connection input failures.

const (
	ErrorKindValidation     ErrorKind = "validation"
	ErrorKindPasswordSource ErrorKind = "password_source"
	ErrorKindPasswordLookup ErrorKind = "password_lookup"
)

type ResolveConnectionOptions

type ResolveConnectionOptions struct {
	LookupEnv func(string) (string, bool)
	ReadFile  func(string) ([]byte, error)
}

ResolveConnectionOptions configures shared connection helper dependencies.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL