config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DeploymentProfileLocal keeps developer and worktree defaults usable.
	DeploymentProfileLocal = "local"
	// DeploymentProfileStaging enables non-local startup safety checks for staging.
	DeploymentProfileStaging = "staging"
	// DeploymentProfileProduction enables non-local startup safety checks for production.
	DeploymentProfileProduction = "production"
	// DeploymentProfileSelfHosted retains production protections with private operator origins.
	DeploymentProfileSelfHosted = "self-hosted"
)

Variables

This section is empty.

Functions

func ExtractFlagArgs

func ExtractFlagArgs(cfg any, args []string) ([]string, []string, error)

ExtractFlagArgs separates shared config flags from command-specific arguments.

func IsLocalDevelopmentHost

func IsLocalDevelopmentHost(host string) bool

IsLocalDevelopmentHost reports whether a host is only suitable for local development.

func IsNonLocalDeploymentProfile

func IsNonLocalDeploymentProfile(profile string) bool

IsNonLocalDeploymentProfile reports whether startup must enforce deployment safety checks.

func LoadInto

func LoadInto(path string, cfg any) error

LoadInto reads and parses a configuration file into cfg with this precedence: 1. Command-line flags (highest priority) 2. Environment variables 3. TOML config file 4. Default values (lowest priority)

func LoadIntoWithArgs

func LoadIntoWithArgs(path string, cfg any, args []string) error

LoadIntoWithArgs reads and parses a configuration file using an isolated flag set.

func ValidateDeploymentHTTPSURL

func ValidateDeploymentHTTPSURL(profile, value, field string) (*url.URL, error)

ValidateDeploymentHTTPSURL permits private operator origins only in self-hosted deployments.

func ValidateDeploymentPostgres

func ValidateDeploymentPostgres(profile, host, user, password, sslMode string) error

ValidateDeploymentPostgres enforces database settings for a deployment profile.

func ValidateDeploymentProfile

func ValidateDeploymentProfile(profile *string) error

ValidateDeploymentProfile normalizes and validates the deployment safety profile.

func ValidateHTTPOrigin

func ValidateHTTPOrigin(value, field string) (*url.URL, error)

ValidateHTTPOrigin trims and validates an HTTP or HTTPS origin value.

func ValidateHTTPURL

func ValidateHTTPURL(value, field string) (*url.URL, error)

ValidateHTTPURL trims and validates an absolute HTTP or HTTPS URL.

func ValidateNonLocalHTTPURL

func ValidateNonLocalHTTPURL(value, field string) (*url.URL, error)

ValidateNonLocalHTTPURL rejects local hosts while allowing HTTP service URLs.

func ValidateNonLocalHost

func ValidateNonLocalHost(host, field string) error

ValidateNonLocalHost rejects localhost, loopback, and wildcard host values.

func ValidateNonLocalPostgres

func ValidateNonLocalPostgres(host, user, password, sslMode string) error

ValidateNonLocalPostgres enforces database settings required outside local development.

func ValidateProxyConfig

func ValidateProxyConfig(
	tomlName string,
	proxyHeader *string,
	trustedProxies []string,
	setTrustedProxy func(i int, value string),
) error

ValidateProxyConfig trims and validates a process-specific proxy header/trusted proxy pair.

func ValidatePublicHTTPSURL

func ValidatePublicHTTPSURL(value, field string) (*url.URL, error)

ValidatePublicHTTPSURL enforces an HTTPS URL with a non-local host for non-local profiles.

func ValidateRuntime

func ValidateRuntime(
	logLevel string,
	logEnvironment string,
	tracing *TracingConfig,
	metrics *MetricsConfig,
) error

ValidateRuntime validates process-shared logging, tracing, and metrics settings.

Types

type DatabaseConfig

type DatabaseConfig struct {
	Host              string `toml:"host"                env:"DB_HOST"                flag:"db-host"                desc:"Database host"`
	Port              int    `toml:"port"                env:"DB_PORT"                flag:"db-port"                desc:"Database port"`
	User              string `toml:"user"                env:"DB_USER"                flag:"db-user"                desc:"Database user"`
	Password          string `toml:"password"            env:"DB_PASSWORD"            flag:"db-password"            desc:"Database password"`
	Database          string `toml:"database"            env:"DB_DATABASE"            flag:"db-database"            desc:"Database name"`
	SSLMode           string `toml:"ssl_mode"            env:"DB_SSL_MODE"            flag:"db-ssl-mode"            desc:"Database SSL mode"`
	SSLRootCert       string `` /* 127-byte string literal not displayed */
	MaxConns          int    `toml:"max_conns"           env:"DB_MAX_CONNS"           flag:"db-max-conns"           desc:"Database max connections"`
	MinConns          int    `toml:"min_conns"           env:"DB_MIN_CONNS"           flag:"db-min-conns"           desc:"Database min connections"`
	MaxConnLifetime   int    `` /* 135-byte string literal not displayed */
	MaxConnIdleTime   int    `` /* 136-byte string literal not displayed */
	HealthCheckPeriod int    `` /* 131-byte string literal not displayed */
}

DatabaseConfig contains shared PostgreSQL connection configuration.

func DefaultDatabaseConfig

func DefaultDatabaseConfig() DatabaseConfig

DefaultDatabaseConfig returns the local PostgreSQL defaults shared by Braidplane processes.

func (*DatabaseConfig) ConnectionString

func (d *DatabaseConfig) ConnectionString() string

ConnectionString returns the PostgreSQL connection string in URL format with all pool settings.

func (*DatabaseConfig) ConnectionURL

func (d *DatabaseConfig) ConnectionURL() string

ConnectionURL returns the PostgreSQL connection URL without pool-specific parameters.

type DeploymentConfig

type DeploymentConfig struct {
	Profile string `` /* 140-byte string literal not displayed */
}

DeploymentConfig contains process deployment safety profile configuration.

type Duration

type Duration time.Duration

Duration is a config-native duration value that parses consistently from TOML, env vars, and command-line flags using Go duration syntax such as "30s" or "1m".

func NewDuration

func NewDuration(value time.Duration) Duration

func (Duration) Milliseconds

func (d Duration) Milliseconds() int64

func (Duration) Seconds

func (d Duration) Seconds() float64

func (*Duration) Set

func (d *Duration) Set(value string) error

func (Duration) String

func (d Duration) String() string

func (Duration) TimeDuration

func (d Duration) TimeDuration() time.Duration

func (*Duration) UnmarshalTOML

func (d *Duration) UnmarshalTOML(value any) error

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

type MetricsConfig

type MetricsConfig struct {
	Enabled bool   `toml:"enabled" env:"METRICS_ENABLED" flag:"metrics-enabled" desc:"Expose Prometheus-compatible metrics endpoint"`
	Path    string `toml:"path"    env:"METRICS_PATH"    flag:"metrics-path"    desc:"Prometheus-compatible metrics endpoint path"`
}

MetricsConfig contains Prometheus-compatible metrics exposure configuration.

type ProofConfig

type ProofConfig struct {
	GitChecksEnabled bool `` /* 158-byte string literal not displayed */
}

ProofConfig controls publication of Braidplane Proof results.

type SMTP

type SMTP struct {
	Host           string `` /* 126-byte string literal not displayed */
	User           string `toml:"user"                 env:"SMTP_USER"                 flag:"smtp-user"                 desc:"SMTP username"`
	Password       string `toml:"password"             env:"SMTP_PASSWORD"             flag:"smtp-password"             desc:"SMTP password"`
	CACert         string `` /* 133-byte string literal not displayed */
	CACertFile     string `` /* 146-byte string literal not displayed */
	Insecure       bool   `` /* 138-byte string literal not displayed */
	NoReplyAddress string `toml:"no_reply_address"     env:"SMTP_NO_REPLY_ADDRESS"     flag:"smtp-no-reply-address"     desc:"No-reply email address"`
}

SMTP contains SMTP server configuration.

func (SMTP) ToTLSConfig

func (w SMTP) ToTLSConfig() TLSConfig

ToTLSConfig converts SMTP config to TLSConfig.

func (SMTP) ValidateCredentials

func (s SMTP) ValidateCredentials() error

ValidateCredentials rejects partial SMTP authentication rather than silently using anonymous delivery.

type TLSConfig

type TLSConfig struct {
	Insecure   bool
	CACert     string
	CACertFile string
}

TLSConfig represents TLS configuration.

type TracingConfig

type TracingConfig struct {
	OTLPTracesEndpoint string  `` /* 166-byte string literal not displayed */
	SamplingRatio      float64 `` /* 145-byte string literal not displayed */
}

TracingConfig contains OpenTelemetry trace export and sampling configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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