metadata

package
v0.110.0 Latest Latest
Warning

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

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

README

Metadata Interface Module

Shared direct-connection helpers for metadata-aware 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

Exports

  • ConnectionInput — includes connect_timeout field for metadata connection timeout
  • 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)

Notes

  • This package owns direct-connection validation and secret resolution shared by transport adapters.
  • 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 direct-connection helpers for metadata-aware interface adapters. input: transport-layer connection inputs and secret lookup sources output: normalized validation and password resolution helpers for interface adapters pos: shared connection helper boundary used by MCP and future metadata-aware transports note: if this file changes, update this header and module README.md.

Index

Constants

This section is empty.

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 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"`
	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