config

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config registers optional, reusable deployment flag groups with tinyflags. It never parses application flags or owns the application's top-level configuration.

Index

Constants

View Source
const (
	// SectionServer groups public and management HTTP server settings.
	SectionServer = "Server"
	// SectionDatabase groups database connection and pool settings.
	SectionDatabase = "Database"
	// SectionAuthentication groups deployment-level authentication overrides.
	SectionAuthentication = "Authentication"
	// SectionProxy groups trusted-proxy header settings.
	SectionProxy = "Trusted proxy"
	// SectionOIDC groups OIDC deployment secrets and overrides.
	SectionOIDC = "OIDC"
	// SectionTelemetry groups OpenTelemetry export flags.
	SectionTelemetry = "OpenTelemetry"
	// SectionLogging groups logs, metrics, and request diagnostics.
	SectionLogging = "Logging and diagnostics"
)

Variables

This section is empty.

Functions

func NewFlagSet

func NewFlagSet(name, envName, version string) *tinyflags.FlagSet

NewFlagSet configures the common CLI conventions while leaving parsing and section ordering to the application. The envName is the application name, not a full environment variable (for example "MOTUS").

func RegisterAuthentication

func RegisterAuthentication(tf *tinyflags.FlagSet, cfg *Authentication, opts AuthenticationOptions) func()

RegisterAuthentication registers common authentication override flags. Call the returned finalizer after parsing flags to preserve the distinction between an absent override and an explicit false value. It does not select an application's persisted authentication policy.

func RegisterLogFormat added in v0.4.0

func RegisterLogFormat(tf *tinyflags.FlagSet, format *logging.LogFormat) func()

RegisterLogFormat adds the shared log-format flag without server-specific logging flags.

func RegisterLogging

func RegisterLogging(tf *tinyflags.FlagSet, cfg *Logging) func()

RegisterLogging adds logging flags, returning a finalizer for the enum value.

func RegisterOIDC

func RegisterOIDC(tf *tinyflags.FlagSet, cfg *OIDC)

RegisterOIDC registers OIDC deployment settings with secret masking.

func RegisterObservability

func RegisterObservability(tf *tinyflags.FlagSet, cfg *Observability)

RegisterObservability adds optional metrics and diagnostics flags.

func RegisterOpenTelemetry

func RegisterOpenTelemetry(tf *tinyflags.FlagSet, cfg *OpenTelemetry, defaultServiceName string)

RegisterOpenTelemetry adds optional OTLP exporter flags.

func RegisterPostgres

func RegisterPostgres(tf *tinyflags.FlagSet, cfg *Postgres, opts PostgresOptions)

RegisterPostgres registers the database URL and common pool settings.

func RegisterProxy

func RegisterProxy(tf *tinyflags.FlagSet, cfg *Proxy)

RegisterProxy registers trusted-proxy identity header overrides.

func RegisterServer

func RegisterServer(tf *tinyflags.FlagSet, cfg *Server, opts ServerOptions) func()

RegisterServer adds server flags and returns a finalizer to call after Parse. The application remains responsible for prefix-aware handler mounting.

Types

type Authentication

type Authentication struct {
	// ModeOverride overrides database-managed auth policy only when non-nil.
	ModeOverride *auth.Mode
	// AllowRegistrationOverride overrides registration policy only when non-nil.
	AllowRegistrationOverride *bool
	// LocalLogin allows an application-managed recovery login alongside its selected mode.
	LocalLogin bool
	// EncryptionKey is a deployment key for application secrets.
	EncryptionKey string
	// SessionLifetime is the optional session duration selected by the application.
	SessionLifetime time.Duration
}

Authentication holds deployment-level recovery flags, not persisted auth policy.

type AuthenticationOptions

type AuthenticationOptions struct {
	// RegisterSessionLifetime adds --session-lifetime only when enabled.
	RegisterSessionLifetime bool
	// DefaultSessionLifetime defaults to 12 hours if no value is supplied.
	DefaultSessionLifetime time.Duration
}

AuthenticationOptions enables selected optional flags without imposing session policy.

type Logging

type Logging struct {
	// Format chooses JSON or structured text output.
	Format logging.LogFormat
	// Debug enables debug-level events.
	Debug bool
	// AccessLog enables per-request logging.
	AccessLog bool
}

Logging holds the shared application logging flag values.

type OIDC

type OIDC struct {
	// Issuer is the optional issuer override.
	Issuer string
	// ClientID is the optional client ID override.
	ClientID string
	// ClientSecret is the OIDC client secret.
	ClientSecret string
	// SessionSecret protects temporary login state and may be reused by application-managed sessions.
	SessionSecret string
	// GroupClaim is the optional external groups claim.
	GroupClaim string
	// AdminGroup is an optional external administrator group mapping input.
	AdminGroup string
}

OIDC holds deployment-managed OIDC secrets and optional runtime overrides.

type Observability

type Observability struct {
	// DisableMetrics disables metrics and HTTP instrumentation.
	DisableMetrics bool
	// PerformanceDiagnostics enables extra request and browser measurements.
	PerformanceDiagnostics bool
}

Observability holds optional application monitoring switches.

type OpenTelemetry

type OpenTelemetry struct {
	// ServiceName is the logical service name displayed in traces.
	ServiceName string
	// Endpoint is the OTLP gRPC collector address.
	Endpoint string
	// Insecure permits plaintext gRPC collector transport.
	Insecure bool
}

OpenTelemetry holds optional OTLP trace-export settings.

type Postgres

type Postgres struct {
	// URL is the database DSN; secrets must not be printed in plaintext.
	URL string
	// MaxConns is the maximum connection count; zero uses driver defaults.
	MaxConns int32
	// MinIdleConns is the idle connection minimum; zero uses driver defaults.
	MinIdleConns int32
}

Postgres holds application PostgreSQL deployment settings.

type PostgresOptions

type PostgresOptions struct {
	// OptionalURL allows the database URL to be omitted.
	OptionalURL bool
}

PostgresOptions permits services without mandatory databases to opt out of --database-url.

type Proxy

type Proxy struct {
	// TrustedCIDRs lists allowed immediate peers; a sole "*" explicitly trusts all peers.
	TrustedCIDRs []string
	// UsernameHeaders are the incoming username header names, in priority order.
	UsernameHeaders []string
	// EmailHeaders are the incoming email header names, in priority order.
	EmailHeaders []string
	// DisplayNameHeaders are the incoming display-name header names.
	DisplayNameHeaders []string
	// GroupHeaders are the group membership header names.
	GroupHeaders []string
	// AdminGroup is an optional application-specific group mapping input.
	AdminGroup string
}

Proxy contains parsed deployment flags; DeploymentOverrides identifies explicit values.

func (Proxy) DeploymentOverrides added in v0.3.0

func (cfg Proxy) DeploymentOverrides(overrides tinyflags.Overrides) proxy.Layer

DeploymentOverrides returns explicitly selected flag or environment settings. Values omitted from overrides are inherited from persisted settings and appkit defaults. A present key with an empty list intentionally clears that header list.

type Server

type Server struct {
	// RoutePrefix is the normalized application deployment prefix.
	RoutePrefix string
	// ListenAddress is the application TCP listen address.
	ListenAddress string
	// ManagementListenAddress is the management TCP listen address, when enabled.
	ManagementListenAddress string
	// PublicURL is the externally reachable application URL.
	PublicURL string
}

Server is shared deployment-level HTTP listener configuration.

type ServerOptions

type ServerOptions struct {
	// ListenAddress defaults to 127.0.0.1:8080 when nil.
	ListenAddress *net.TCPAddr
	// ManagementListenAddress defaults to 127.0.0.1:8081 when nil.
	ManagementListenAddress *net.TCPAddr
	// PublicURL defaults to http://localhost:8080 when empty.
	PublicURL string
	// WithoutManagement omits the management-listen-address flag.
	WithoutManagement bool
}

ServerOptions controls application-specific listener defaults and optional flags.

Jump to

Keyboard shortcuts

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