catalog

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package catalog defines Breadboard's infrastructure service types. Each entry is everything the engine knows about one type: image, listeners, server configuration with TLS on, secrets, health check, resource defaults, the env contract injected into apps, and learning notes.

Adding a service type means adding one entry file here and nothing else.

Index

Constants

View Source
const (
	TLSDir          = "/etc/bb/tls"
	CertFile        = TLSDir + "/tls.crt"
	KeyFile         = TLSDir + "/tls.key"
	KeystoreFile    = TLSDir + "/keystore.pem" // key followed by certificate, for servers that want one file
	CAFile          = "/etc/bb/ca.pem"
	TrustBundleFile = "/etc/bb/trust-bundle.pem"
	ConfigDir       = "/etc/bb/config"
)

Paths inside every container. The compose materializer mounts files here; entries refer to them in server configuration and health checks.

View Source
const (
	HAProxyMonitorPort = 8404
	HAProxyMonitorURI  = "/healthz"
	HAProxyStatsURI    = "/stats"
)

HAProxy's loopback-only monitor frontend: the health check reads HAProxyMonitorURI, and explorers read the stats page (append ;csv for CSV) through docker exec. Nothing outside the container reaches it.

View Source
const (
	// HostCertFile and HostKeyFile are where the router finds the host
	// certificate from the host CA. Only the router mounts them.
	HostCertFile = "/etc/bb/host/tls.crt"
	HostKeyFile  = "/etc/bb/host/tls.key"
	// HostRouterPort is the router's HTTPS entrypoint inside the
	// container, published on 127.0.0.1:<host port>.
	HostRouterPort = ProxyHTTPSPort
)

The host router (ADR-0017): the engine-owned Traefik service that makes a lab's host targets reachable from the host at https://<target>.<experiment>.localhost:<port>. It is the traefik entry's image, static configuration and health check with its own certificate store (the host certificate) and generated routes; a spec cannot replace them.

View Source
const (
	NginxStatusPort = 8404
	NginxHealthURI  = "/healthz"
	NginxStatusURI  = "/stub_status"
)

NGINX's loopback-only status server: the health check reads NginxHealthURI, and explorers read stub_status (NginxStatusURI) through docker exec. Nothing outside the container reaches it.

View Source
const (
	// OpenSearchHTTPPort is OpenSearch's HTTPS REST API port.
	OpenSearchHTTPPort = 9200
	// OpenSearchTransportPort is OpenSearch's internal transport port (bound to 127.0.0.1 only).
	OpenSearchTransportPort = 9300
)
View Source
const (
	PgBouncerPort = 6432
	// PgBouncerAuthFile is written at container start from the
	// environment (BB_PG_USER, BB_PG_PASSWORD), so the password never
	// lands in a generated file. Explorers read the admin console as that
	// user through docker exec, like the PgBouncer sidecar's.
	PgBouncerAuthFile = "/tmp/pgbouncer/userlist.txt"
)

PgBouncer infra: a connection pool shared by every app that uses it, in front of one Postgres service.

View Source
const (
	// ProxyHTTPSPort is the TLS L7 listener, with the proxy's own
	// certificate. Apps that use the proxy get <NAME>_URL pointing here.
	ProxyHTTPSPort = 8443
	// ProxyPassthroughPort is the TLS L4 listener, routed by SNI without
	// decrypting; present only when an upstream is passthrough. Apps get
	// <NAME>_PASSTHROUGH_ADDR pointing here.
	ProxyPassthroughPort = 9443
)

Ports every HTTP proxy listens on (the 8443/9443 convention).

View Source
const (
	// TraefikAPIPort is the loopback-only entrypoint "traefik": the API and
	// dashboard (for explorers, through docker exec) and /ping (for the
	// health check). Nothing outside the container reaches it.
	TraefikAPIPort = 8080

	// TraefikConsulCatalog is the config option naming the consul service
	// Traefik also discovers routes from (D-225). TraefikEnableTag is the
	// register tag that exposes a service there, since exposedByDefault
	// is off.
	TraefikConsulCatalog = "consul_catalog"
	TraefikEnableTag     = "traefik.enable=true"
)

Traefik as an infra proxy, configured by the file provider only: it never sees the Docker socket. The static config (entrypoints, the provider, ping, the API) is Breadboard's; the dynamic config (routers, middlewares, services, transports) is what file replaces.

Variables

This section is empty.

Functions

func Comment

func Comment(prefix, text string) string

Comment renders user-derived text (a tls.reason, …) as comment lines that cannot escape into the config around them: CR LF and lone CR become line breaks, every other control character (C0, DEL and C1), LS, PS and BOM becomes a space, and every line starts with prefix, the indentation plus the format's comment marker (" # " for HAProxy and NGINX, "# " in YAML such as Envoy's). Lines are joined with "\n", without a trailing one. Every proxy entry must render user text through it.

func EnvName

func EnvName(service string) string

EnvName turns a service name into a variable prefix: EDGE for edge, API_GATEWAY for api-gateway.

func HostNames

func HostNames(targets []HostTarget) []string

HostNames lists every host name of the targets, in route order: each target's name, then its instances' names.

func MergeOtelSignals added in v0.3.0

func MergeOtelSignals(a, b string) string

MergeOtelSignals returns the canonical comma-separated union of two signal lists, in logs,metrics,traces order.

func OtelSignals added in v0.3.0

func OtelSignals(raw string) (logs, metrics, traces bool)

OtelSignals reports which telemetry signals are enabled by an otel service's signals config option. An empty value defaults to all three signals.

func ParseOpenSearchIndices added in v0.3.0

func ParseOpenSearchIndices(raw string) ([]string, error)

ParseOpenSearchIndices validates and returns the normalized index names in config.indices (empty slice when unset).

func Types

func Types(id string) (spec.TypeInfo, bool)

Types adapts the catalog for spec validation.

Types

type Client

type Client struct {
	Service string
	FQDN    string
	Config  map[string]string
	Secret  func(key string) string
	// Plain is set when this edge is plaintext.
	Plain *Plain
	// Upstreams are the used proxy's backends, so its contract can say
	// how to reach passthrough routes.
	Upstreams []Upstream
}

Client is the input for rendering one app's env contract.

type ConfigOption

type ConfigOption struct {
	Key     string
	Default string
	Help    string
	// Validate rejects a bad value with a message for the user.
	Validate func(string) error
	// Service is set when the value names another service of the
	// experiment: the catalog type that service must have.
	Service string
}

ConfigOption is a type-specific `config` key a spec may set.

type Container

type Container struct {
	Entrypoint  []string
	Command     []string
	Environment []EnvVar
	Files       []File
	Health      Health
}

Container is a rendered service definition.

func HostRouter

func HostRouter(s Server) Container

HostRouter renders the host router's container: Traefik with the traefik entry's static configuration and health check, the host certificate as its default certificate, and one route per host name.

type Entry

type Entry struct {
	ID      string
	Title   string
	Summary string
	// Image is an exact version pin. This field is the source of truth for versions.
	Image     string
	Listeners []Listener
	Resources Resources
	Secrets   []Secret
	Config    []ConfigOption
	// DataPath is where the service's named data volume is mounted.
	DataPath string
	// Notes is the embedded learning-notes markdown.
	Notes string
	// Server renders the container definition.
	Server func(Server) Container
	// Client renders the env contract for one app that uses the service.
	Client func(Client) []EnvVar
	// Sidecar renders the agent that registers an app with this service, for
	// service registries. Nil means apps cannot register with it.
	Sidecar func(Sidecar) Container
	// Proxy is set for proxy types: services that take upstreams (proxy.go).
	Proxy *Proxy
}

Entry is one infrastructure service type.

func All

func All() []*Entry

All returns every entry, in display order.

func Lookup

func Lookup(id string) (*Entry, bool)

Lookup finds an entry by id.

func (*Entry) CheckConfig

func (e *Entry) CheckConfig(key, value string) error

CheckConfig validates one config key and value.

func (*Entry) ListenersFor

func (e *Entry) ListenersFor(ups []Upstream) []Listener

ListenersFor lists the entry's listeners as they run with these upstreams: an HTTP proxy adds its passthrough listener on 9443 when an upstream is passthrough.

func (*Entry) Render

func (e *Entry) Render(s Server) (Container, error)

Render renders the service's container: Server, with a proxy's file swapped in for its generated config and its static_file merged into its generated static configuration.

func (*Entry) ResolveConfig

func (e *Entry) ResolveConfig(cfg map[string]string) map[string]string

ResolveConfig applies defaults to a spec's config.

func (*Entry) SupportsPlaintext

func (e *Entry) SupportsPlaintext() bool

SupportsPlaintext reports whether any listener can run without TLS.

type EnvVar

type EnvVar struct {
	Name  string
	Value string
	// Secret marks values that embed a secret, so displays can mask them.
	Secret bool
}

EnvVar is one environment variable.

func ProxyClientEnv

func ProxyClientEnv(c Client) []EnvVar

ProxyClientEnv is the env contract of an HTTP proxy, named after the service so an app can use several proxies: <NAME>_URL=https://<fqdn>:8443, and <NAME>_PASSTHROUGH_ADDR=<fqdn>:9443 when an upstream is passthrough. The app trusts the proxy through SSL_CERT_FILE, like any service.

type File

type File struct {
	Name  string // written under the service's config directory
	Mount string // container path; empty means ConfigDir/Name
	Data  []byte
	Mode  uint32 // file mode; zero means 0644
}

File is generated configuration mounted read-only into the container.

func (File) MountPath

func (f File) MountPath() string

MountPath returns where the file appears in the container.

type Health

type Health struct {
	Test          []string
	Interval      time.Duration
	Timeout       time.Duration
	Retries       int
	StartPeriod   time.Duration
	StartInterval time.Duration
}

Health is a container health check. Literal dollar signs in Test are written $$ because compose interpolates the file.

type HostInstance

type HostInstance struct {
	// Service is the instance's service name (api-2, or api with one
	// replica).
	Service string
	// FQDN is the instance's own lab name, the router's dial address and,
	// for an instance route, the verified name.
	FQDN string
	// Name is the host name that reaches this instance alone
	// (<app>-<n>.<experiment>.localhost); empty for a target with one
	// instance.
	Name string
}

HostInstance is one instance of a host target.

type HostTarget

type HostTarget struct {
	// Target is the app or service in experiment.yaml.
	Target string
	// App marks an app target, which may run several replicas.
	App bool
	// Name is the host name: <target>.<experiment>.localhost.
	Name string
	// ServerName is the name the router verifies on every instance's lab
	// certificate (and sends as SNI): <target>.<domain>.
	ServerName string
	// Port is the TLS port on every instance: the app's host port, or the
	// infra service's first HTTPS listener.
	Port int
	// Instances are where the router sends requests, in instance order.
	Instances []HostInstance
}

HostTarget is one app or infra service the host router serves.

type Listener

type Listener struct {
	Name     string
	Protocol string
	Port     int
	// PlaintextPort is the port of the plaintext listener an edge can ask for
	// with tls.mode: off. Zero means the entry has none in v1.
	PlaintextPort int
}

Listener is a port the service accepts connections on.

func HTTPProxyListeners

func HTTPProxyListeners() []Listener

HTTPProxyListeners are the listeners of an HTTP proxy as edges see them: apps that use the proxy connect to its TLS L7 port. The passthrough port is added by the proxy's config when an upstream asks for it.

type Plain

type Plain struct {
	FQDN    string // the service's alias on the segment
	Address string // the service's static IP on the segment
	Subnet  string // the segment's CIDR
	Clients []string
	Reasons []string
}

Plain describes the private segment a plaintext listener lives on.

type Proxy

type Proxy struct {
	// Modes are the upstream TLS modes the proxy supports: spec.TLSOn
	// (re-encrypt), spec.TLSOff (terminate) and spec.TLSPassthrough.
	Modes []string
	// HTTP marks an L7 HTTP proxy: decrypted upstreams must speak HTTP.
	HTTP bool
	// Targets limits upstreams to these catalog types; nil allows apps and
	// any infra type.
	Targets []string
	// MinUpstreams is the number of upstreams the type needs to work at
	// all (pgbouncer: its one Postgres); zero means none are required.
	MinUpstreams int
	// MaxUpstreams caps the number of upstreams; zero means no cap.
	MaxUpstreams int
	// ConfigFile is the name (under ConfigDir) of the generated native
	// config that a spec's file replaces. Server must emit a File with it.
	ConfigFile string
	// StaticFile is the name (under ConfigDir) of the generated static
	// configuration that a spec's static_file extends; empty when the
	// type takes no static_file. MergeStatic renders it with
	// Server.UserStatic merged in, or refuses the user's file.
	StaticFile  string
	MergeStatic func(Server) ([]byte, error)
	// Unit names the part of the generated config that balances one
	// upstream (an HAProxy backend, an Envoy cluster, a Traefik service),
	// so explorers can tell which upstream a live counter belongs to; nil
	// when the proxy reports nothing per upstream.
	Unit func(Upstream) string
}

Proxy marks an entry as a proxy: a service with upstream edges to apps and other infra services, each with its own TLS mode. Validation reads it through spec.ProxyInfo; the compose materializer passes the entry the resolved upstreams in Server.Upstreams.

type Resources

type Resources struct {
	Memory string
	CPUs   string
}

Resources are default limits.

type Secret

type Secret struct {
	Key  string
	Kind SecretKind
	Help string
}

Secret is a generated value the service needs.

type SecretKind

type SecretKind int

SecretKind selects how a secret is generated.

const (
	// Password is 32 base32 characters (A-Z, 2-7): safe in URLs, shells, and compose files.
	Password SecretKind = iota
	// ClusterID is a 16-byte random value, base64url without padding (Kafka's format).
	ClusterID
	// GossipKey is a 32-byte random value, standard base64 (Consul's gossip encryption key).
	GossipKey
)

type Server

type Server struct {
	Name   string
	FQDN   string
	Domain string
	Config map[string]string // every option, defaults applied
	// Secret returns a reference to one of this service's secrets: the value
	// itself, or a ${VAR} reference resolved from a .env file.
	Secret func(key string) string
	// Plain is set when at least one edge asked for plaintext.
	Plain *Plain
	// Upstreams are a proxy's resolved backends, in spec order.
	Upstreams []Upstream
	// UserConfig is the content of a proxy's file, which replaces the
	// generated config file (Proxy.ConfigFile); nil without one. Render
	// swaps it in, so entries need not handle it.
	UserConfig []byte
	// UserStatic is a proxy's static_file, merged into its generated
	// static configuration (Proxy.StaticFile); nil without one. Render
	// merges it, so entries need not handle it in Server.
	UserStatic *UserFile
	// HostTargets are what the host router serves; set only for the host
	// router, which renders with HostRouter.
	HostTargets []HostTarget
}

Server is the input for rendering a service's container.

type Sidecar

type Sidecar struct {
	App      string // the app's service name, used as the agent's node name
	AppFQDN  string
	Registry string // FQDN of the registry server the agent joins
	// Secret returns a reference to one of the registry service's secrets.
	Secret func(key string) string
	// What to register.
	Service string
	Port    int
	Check   string // HTTPS check path; empty means a TCP check
	Tags    []string
}

Sidecar is the input for rendering an app's registration agent. The agent shares the app's network namespace, so it has the app's address and uses the app's certificate.

type Upstream

type Upstream struct {
	// Name is the route name: requests to /<Name>/ reach it when the proxy
	// has several L7 upstreams.
	Name string
	// Service is the target's name in experiment.yaml (an app or a service).
	Service string
	// App marks an app target, which may run several replicas.
	App bool
	// Mode is spec.TLSOn, spec.TLSOff or spec.TLSPassthrough.
	Mode string
	// Reason is why a terminate hop is plaintext.
	Reason string
	// Host is a DNS name that resolves to every instance on the hop's
	// network: the target's shared FQDN, or its segment alias
	// (<target>.plain.<domain>) for a terminate hop. Proxies with DNS
	// discovery (HAProxy server-template, Envoy STRICT_DNS, NGINX resolve)
	// use it.
	Host string
	// Servers are each instance's own name on the hop's network: every
	// replica's FQDN (or segment alias for terminate), in instance order.
	// Proxies without DNS multi-A discovery (Traefik) list these.
	Servers []string
	// ServerName is the name on the target's certificate: the TLS SNI and
	// verified name for re-encrypt, and the SNI clients send for
	// passthrough. It is the shared FQDN, which every replica's
	// certificate carries.
	ServerName string
	// Port is the target port: its TLS port, or for terminate its
	// plaintext port.
	Port int
	// Config is an infra target's resolved config (defaults applied); nil
	// for an app. A pooler reads the database and role it serves here.
	Config map[string]string
	// Secret returns a reference to one of an infra target's secrets, like
	// Server.Secret; nil for an app, and until the upstream is rendered
	// (WithSecrets).
	Secret func(key string) string
}

Upstream is one resolved backend of a proxy, ready to render.

func L7

func L7(ups []Upstream) []Upstream

L7 returns the upstreams the proxy decrypts (re-encrypt and terminate), in spec order. With one, it receives every request; with several, each gets its /<Name>/ prefix (stripped before forwarding) and the first is also the default route.

func Passthroughs

func Passthroughs(ups []Upstream) []Upstream

Passthroughs returns the passthrough upstreams, routed by SNI on ProxyPassthroughPort.

func WithSecrets

func WithSecrets(ups []Upstream, ref func(service string) func(key string) string) []Upstream

WithSecrets returns a copy of ups whose infra targets carry their secret references from ref, for an entry that hands a target's credentials on (PgBouncer logs in to Postgres as the app role).

func (Upstream) Addr

func (u Upstream) Addr() string

Addr is Host:Port.

func (Upstream) Passthrough

func (u Upstream) Passthrough() bool

Passthrough reports whether the proxy forwards the client's TLS session to this upstream untouched.

func (Upstream) Prefix

func (u Upstream) Prefix() string

Prefix is the upstream's path prefix with several L7 upstreams: /<Name>/.

type UserFile

type UserFile struct {
	Path string // as written in experiment.yaml
	Data []byte
}

UserFile is a user-owned file named in experiment.yaml.

Directories

Path Synopsis
Package sidecar is the sidecar catalog: container types that run inside an app's pod, sharing its network namespace (same address, same localhost) and a directory with it.
Package sidecar is the sidecar catalog: container types that run inside an app's pod, sharing its network namespace (same address, same localhost) and a directory with it.

Jump to

Keyboard shortcuts

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