config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TLSOff      TLSMode = "off"
	TLSOptional TLSMode = "optional"
	TLSRequire  TLSMode = "require"

	PostgresTLSOff      = TLSOff
	PostgresTLSOptional = TLSOptional
	PostgresTLSRequire  = TLSRequire
)
View Source
const (
	MongoProvisionDatabase = "database"
	MongoProvisionStatic   = "static"
)
View Source
const (
	MongoTopologyReplicaSet = "replicaset"
	MongoTopologySharded    = "sharded"
	MongoTopologyStandalone = "standalone"
)

Variables

This section is empty.

Functions

func AllowRawSQLResolved added in v0.5.0

func AllowRawSQLResolved(listener *PostgresAdmin, global *ProvisioningConfig) bool

AllowRawSQLResolved returns whether raw SQL is allowed for this listener, resolving per-listener → global → default (true).

Types

type BackendPair added in v0.5.3

type BackendPair struct {
	Listen    string
	Backend   string
	Advertise string
}

BackendPair holds a resolved listen address and backend address.

type Config

type Config struct {
	LogLevel     string                   `toml:"log_level"`
	Tailscale    tsconfig.TailscaleConfig `toml:"tailscale"`
	Redis        RedisConfig              `toml:"redis"`
	Revalidation RevalidationConfig       `toml:"revalidation"`
	Defaults     DefaultsConfig           `toml:"defaults"`
	Metrics      metrics.Config           `toml:"metrics"`
	Provisioning ProvisioningConfig       `toml:"provisioning"`
	Listeners    []ListenerConfig         `toml:"listeners"`
}

func Load

func Load(path string) (*Config, error)

Load reads and parses a TOML config file, expanding environment variables in string values using ${VAR} syntax.

type DefaultLimitsConfig

type DefaultLimitsConfig struct {
	MaxConnsTotal int `toml:"max_conns_total"`
}

type DefaultsConfig

type DefaultsConfig struct {
	Limits DefaultLimitsConfig `toml:"limits"`
}

type ListenerConfig

type ListenerConfig struct {
	Name                string         `toml:"name"`
	Listen              string         `toml:"listen"`
	Mode                string         `toml:"mode"`
	Backend             string         `toml:"backend"`
	ProvisionBackend    string         `toml:"provision_backend"`
	Advertise           string         `toml:"advertise"`
	BackendViaTailscale bool           `toml:"backend_via_tailscale"`
	BackendTLS          bool           `toml:"tls"`
	ProvisionTLS        *bool          `toml:"provision_tls"`
	PostgresTLSMode     string         `toml:"tls_mode"`
	UseTailscaleTLS     *bool          `toml:"use_tailscale_tls"`
	CertFile            string         `toml:"cert_file"`
	KeyFile             string         `toml:"key_file"`
	Service             string         `toml:"service"`
	Postgres            *PostgresAdmin `toml:"postgres"`
	MongoDB             *MongoDBAdmin  `toml:"mongodb"`
	PortMap             map[int]int    `toml:"-"`
	RawPortMap          map[string]int `toml:"port_map,omitempty"`
}

func (ListenerConfig) EffectivePostgresTLSMode added in v0.6.3

func (l ListenerConfig) EffectivePostgresTLSMode() PostgresTLSMode

func (ListenerConfig) EffectiveProvisionBackend added in v0.7.0

func (l ListenerConfig) EffectiveProvisionBackend(sessionBackend string) string

EffectiveProvisionBackend returns the database endpoint used for PostgreSQL role provisioning. Keeping it separate from Backend lets a session pass through a read-only protocol proxy while administrative SQL goes directly to the database. Existing listeners retain their current behavior when the override is absent.

func (ListenerConfig) EffectiveProvisionTLS added in v0.7.0

func (l ListenerConfig) EffectiveProvisionTLS() bool

EffectiveProvisionTLS returns the backend TLS setting used for PostgreSQL role provisioning. A pointer distinguishes an explicit false override from the backward-compatible default inherited from BackendTLS.

func (ListenerConfig) EffectiveTLSMode added in v0.6.4

func (l ListenerConfig) EffectiveTLSMode() TLSMode

func (ListenerConfig) EffectiveUseTailscaleTLS added in v0.6.3

func (l ListenerConfig) EffectiveUseTailscaleTLS() bool

func (*ListenerConfig) ExpandedBackends added in v0.5.3

func (l *ListenerConfig) ExpandedBackends() []BackendPair

ExpandedBackends returns (listenAddr, backendAddr) pairs. For single-port listeners, returns one pair using Listen and Backend directly. For multi-port listeners (PortMap set), returns one pair per mapping, sorted by listen port for deterministic ordering.

func (*ListenerConfig) ListenPort

func (l *ListenerConfig) ListenPort() (uint16, error)

ListenPort extracts the numeric port from the Listen address (e.g. ":5432" → 5432).

type MongoDBAdmin added in v0.6.3

type MongoDBAdmin struct {
	AdminUser string `toml:"admin_user"`
	// AdminPassword is a secret and must never be serialized off-process. See PostgresAdmin.
	AdminPassword string          `toml:"admin_password" json:"-"`
	AuthDatabase  string          `toml:"auth_database"` // usually "admin"
	UserPrefix    string          `toml:"user_prefix"`
	UserTTL       string          `toml:"user_ttl"`
	ServiceName   string          `toml:"service_name"` // peer.service override for OTel (default: listener name)
	Topology      string          `toml:"topology"`     // "replicaset" (default), "sharded", or "standalone"
	ReplicaSet    string          `toml:"replica_set"`  // optional replica set name for admin provisioning
	SRV           string          `toml:"srv"`          // optional MongoDB SRV name for backend discovery
	SRVMaxMembers int             `toml:"srv_max_members"`
	Provision     *MongoProvision `toml:"provision"`
	Members       []MongoDBMember `toml:"members"`
}

MongoDBAdmin holds admin credentials for MongoDB user provisioning.

func (*MongoDBAdmin) EffectiveAuthDatabase added in v0.6.5

func (m *MongoDBAdmin) EffectiveAuthDatabase() string

func (*MongoDBAdmin) EffectiveProvisionMode added in v0.6.5

func (m *MongoDBAdmin) EffectiveProvisionMode() string

func (*MongoDBAdmin) EffectiveTopology added in v0.7.0

func (m *MongoDBAdmin) EffectiveTopology() string

EffectiveTopology returns the configured cluster topology, lower-cased and defaulting to "replicaset" (which also covers standalone via the provisioner's single-seed directConnection behavior) when unset.

func (*MongoDBAdmin) HasSRV added in v0.6.4

func (m *MongoDBAdmin) HasSRV() bool

func (*MongoDBAdmin) IsSharded added in v0.7.0

func (m *MongoDBAdmin) IsSharded() bool

IsSharded reports whether the listener targets a sharded cluster (mongos routers) rather than a replica set or standalone server.

func (*MongoDBAdmin) UserTTLDuration added in v0.6.3

func (m *MongoDBAdmin) UserTTLDuration() time.Duration

type MongoDBMember added in v0.6.3

type MongoDBMember struct {
	Backend   string `toml:"backend"`   // backend address as MongoDB advertises it, e.g. mongo1:27017
	Listen    string `toml:"listen"`    // Waypoint bind address for this member, e.g. :27017
	Advertise string `toml:"advertise"` // client-visible proxy address, e.g. waypoint-db:27017
}

MongoDBMember maps one replica set member to a Waypoint listener.

type MongoProvision added in v0.6.5

type MongoProvision struct {
	Mode        string            `toml:"mode"`
	StaticUsers []MongoStaticUser `toml:"static_users"`
}

MongoProvision selects how a MongoDB listener obtains backend credentials.

type MongoStaticRole added in v0.6.5

type MongoStaticRole struct {
	Role string `toml:"role"`
	DB   string `toml:"db"`
}

MongoStaticRole describes one backend role assignment for static user matching.

type MongoStaticUser added in v0.6.5

type MongoStaticUser struct {
	Name     string `toml:"name"`
	Username string `toml:"username"`
	// Password is a secret and must never be serialized off-process. See PostgresAdmin.
	Password     string            `toml:"password" json:"-"`
	AuthDatabase string            `toml:"auth_database"`
	Database     string            `toml:"database"`
	Permissions  []string          `toml:"permissions"`
	Roles        []MongoStaticRole `toml:"roles"`
}

MongoStaticUser maps an ACL role set to an existing MongoDB/Atlas user.

type PostgresAdmin

type PostgresAdmin struct {
	AdminUser string `toml:"admin_user"`
	// AdminPassword is a secret and must never be serialized off-process
	// (e.g. into the Redis heartbeat). json:"-" guards against accidental marshaling.
	AdminPassword string `toml:"admin_password" json:"-"`
	AdminDatabase string `toml:"admin_database"`
	UserPrefix    string `toml:"user_prefix"`
	UserTTL       string `toml:"user_ttl"`
	AllowRawSQL   *bool  `toml:"allow_raw_sql"` // nil = use global
	ServiceName   string `toml:"service_name"`  // peer.service override for OTel (default: listener name)
}

func (*PostgresAdmin) UserTTLDuration

func (p *PostgresAdmin) UserTTLDuration() time.Duration

type PostgresTLSMode added in v0.6.3

type PostgresTLSMode = TLSMode

type ProvisioningConfig added in v0.5.0

type ProvisioningConfig struct {
	AllowRawSQL *bool `toml:"allow_raw_sql"` // nil = true (default)
}

type RedisConfig

type RedisConfig struct {
	Address     string `toml:"address"`
	Password    string `toml:"password"`
	DB          int    `toml:"db"`
	TLS         bool   `toml:"tls"`
	KeyPrefix   string `toml:"key_prefix"`
	ServiceName string `toml:"service_name"` // peer.service for OTel traces (default: "redis")
}

type RevalidationConfig

type RevalidationConfig struct {
	Interval string `toml:"interval"`
}

func (RevalidationConfig) IntervalDuration

func (r RevalidationConfig) IntervalDuration() time.Duration

type TLSMode added in v0.6.4

type TLSMode string

Jump to

Keyboard shortcuts

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