connectors

package
v0.3.1 Latest Latest
Warning

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

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

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

View Source
var ErrAlreadyExists = errors.New("connector already exists")

ErrAlreadyExists is returned by Create when a connector with the given id already exists.

View Source
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.

View Source
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

func Delete

func Delete(ctx context.Context, db *sql.DB, id string) error

Delete removes a connector. It returns ErrNotFound if no connector with that id has been recorded.

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.

func Get

func Get(ctx context.Context, db *sql.DB, id string) (*Connector, error)

Get returns one connector by id. It returns ErrNotFound if no connector with that id has been recorded.

func List

func List(ctx context.Context, db *sql.DB) ([]Connector, error)

List returns every recorded connector, ordered by id.

type ResolvedConnector

type ResolvedConnector struct {
	Type    string
	Config  map[string]any
	Secrets map[string]any
}

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.

Jump to

Keyboard shortcuts

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