Documentation
¶
Overview ¶
Package connectors manages connector instances: persistent, named configurations for accessing an external system (vision document, section 7.3). A connector is not an action — it only holds configuration and secret references; using it to actually do something is a later phase's job (see ADR-0020 for what this package deliberately does not do yet).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyExists = errors.New("connector already exists")
ErrAlreadyExists is returned by Create when a connector with the given id already exists.
var ErrInvalidConnector = errors.New("invalid connector")
ErrInvalidConnector is wrapped by every error Create returns for a caller-fixable problem (an empty id/type, a type no installed plugin declares, an unsupported secret reference type) — as opposed to a persistence failure. internal/api's connector handlers use it to answer 400 instead of 500, the same role workflow.ErrInvalidInputs plays for handleRunWorkflow.
var ErrNotFound = errors.New("connector not found")
ErrNotFound is returned by Get and Delete when no connector with the given id has been recorded.
Functions ¶
Types ¶
type Connector ¶
type Connector struct {
ID string
Type string
// Config holds non-secret settings (host, port, base URL, ...).
Config map[string]any
// SecretRefs holds logical references to secret values, by logical
// name — never a secret's actual value (ADR-0009, ADR-0020).
SecretRefs map[string]secrets.Reference
CreatedAt time.Time
}
Connector is one persistent, named configuration for accessing an external system, as recorded in the database.
func Create ¶
func Create(ctx context.Context, db *sql.DB, id, connectorType string, config map[string]any, secretRefs map[string]secrets.Reference, knownTypes map[string]struct{}) (*Connector, error)
Create records a new connector. It returns ErrAlreadyExists if id is already in use, and an error if any of secretRefs uses an unsupported reference type (see secrets.ValidateType) — caught here rather than only the first time something tries to resolve it.
knownTypes is the set of connector type identifiers currently installed plugins contribute; the caller (internal/cli, internal/api) is responsible for fetching it from the plugin catalog (plugins.KnownConnectorTypes), keeping this package free of any process dependency — the same split workflow.Validate uses for knownActions.
type ResolvedConnector ¶
ResolvedConnector carries one connector's non-secret config and its secret references already resolved to values, ready to hand to a plugin for one action call. It is assembled by Resolve and never persisted — callers must never write it back to the database or echo Secrets into an action's output, which would land resolved secret values in run history in the clear (see ADR-0021).
func Resolve ¶
func Resolve(ctx context.Context, db *sql.DB, id string, store secrets.Store) (*ResolvedConnector, error)
Resolve loads connector id and resolves every one of its secret references through store, returning a ResolvedConnector ready to pass to an action call. It returns ErrNotFound if no such connector exists, or an error naming the secret whose resolution failed.