Documentation
¶
Overview ¶
Package config provides configuration management for Starport. It supports loading configuration from environment variables and .env files, with comprehensive validation and hot reload capabilities for rate limiting rules.
Index ¶
- Constants
- Variables
- func OperatorError(err error) error
- func Redacted(cfg *Config) map[string]any
- type AuthMode
- type BadgerConfig
- type CacheConfig
- type CatalogConfig
- type Config
- func (c *Config) AuthModeSource() authmode.Source
- func (c *Config) ConfigureDevelopmentRuntime()
- func (c *Config) EnableProvider(providerID catalogs.ProviderID)
- func (c *Config) ResolveProviderRuntime(ctx context.Context, provider catalogs.Provider, explicit ProviderConfig, ...) (ProviderConfig, bool, error)
- func (c *Config) ResolveProviderSet(ctx context.Context, providers catalogs.ProvidersReader, ...) (ProvidersConfig, error)
- func (c *Config) ResolveProviderSetLocalIsolated(ctx context.Context, providers catalogs.ProvidersReader, ...) (ProvidersConfig, []ProviderResolutionFailure, error)
- func (c *Config) ResolveProviders(ctx context.Context, providers catalogs.ProvidersReader) error
- func (c *Config) Validate() error
- func (c *Config) ValidateProviderCredentialContracts(providers []catalogs.Provider) error
- type ConsoleConfig
- type CredentialReference
- type CredentialSourcesConfig
- type FilesConfig
- type IdentityConfig
- type JobsConfig
- type Loader
- func (l *Loader) Load(ctx context.Context, overrides ...Override) (*Config, error)
- func (l *Loader) LoadDevelopment(ctx context.Context, overrides ...Override) (*Config, error)
- func (l *Loader) WithEnvFiles(files ...string) *Loader
- func (l *Loader) WithEnvironment(values map[string]string) *Loader
- func (l *Loader) WithPaths(paths Paths) *Loader
- type LoggingConfig
- type OAuthApplicationConfig
- type OAuthIdentityConfig
- type ObjectStoreConfig
- type Override
- type Paths
- type ProviderConfig
- type ProviderEntry
- type ProviderResolutionFailure
- type ProvidersConfig
- type RateLimitingConfig
- type SQLConfig
- type SQLMySQLConfig
- type SQLPostgresConfig
- type SQLiteConfig
- type SecurityConfig
- type ServerConfig
- type StorageConfig
- type ValkeyConfig
- type WorkOSIdentityConfig
Constants ¶
const ( // AuthModeRequired refuses every request that carries no valid gateway // API key. It is the default, and the zero value resolves to it. AuthModeRequired = authmode.Required // AuthModeDisabled serves every request without checking for a key. The // key check does not run at all, so a request carrying a key is treated // exactly like one that carries none. AuthModeDisabled = authmode.Disabled )
const ( // BlobBackendFilesystem stores file bytes under a directory on this node. BlobBackendFilesystem = "filesystem" // BlobBackendObjectStore stores file bytes in an S3-compatible object // store. One client reaches AWS S3, Cloudflare R2, MinIO, and Backblaze B2. BlobBackendObjectStore = "objectstore" )
The blob backends an operator can select. The words match the ones internal/blob reports from Store.Backend, so a startup line and a configuration file spell the same thing.
const ( DefaultRetention = 30 * 24 * time.Hour DefaultSweepInterval = time.Hour )
DefaultRetention is the window an absent setting selects, and DefaultSweepInterval is how often the reclaim pass runs.
const ( // DefaultAssetRetention is a day. It is short beside the file store's month // on purpose: a generated video is an answer a caller collects rather than a // document it keeps, and both provider families publish their own links with // windows measured in hours. DefaultAssetRetention = 24 * time.Hour // DefaultMaxAssetBytes is 256 MiB. DefaultMaxAssetBytes int64 = 256 << 20 // DefaultJobSweepInterval is how often the reclaim pass runs. DefaultJobSweepInterval = time.Hour )
The windows and bounds an absent setting selects.
const DefaultMaxRequestSize int64 = 33554432
DefaultMaxRequestSize is the largest request body the gateway reads, in bytes. A caller attaches media as base64 inside the JSON body, and base64 grows a payload by a third, so the limit has to hold the grown form. The largest media file the provider APIs commonly accept is a 25 MB audio file, which reaches about 33,333,336 bytes as base64. This value clears that with room for the surrounding request.
The tag on MaxRequestSize repeats the number because a struct tag holds a literal. TestBodyLimitDefaultMatchesItsConstant proves the two agree.
const DefaultMaxUploadBytes int64 = 512 << 20
DefaultMaxUploadBytes is the upload bound an absent setting selects. It matches the cap OpenAI publishes, so an SDK that already refuses a larger file refuses it before the request leaves the client.
Variables ¶
var ( // ErrCredentialAliasCollision reports an ambiguous catalog-derived // environment name. Validation completes before any value lookup. ErrCredentialAliasCollision = errors.New("provider credential environment alias is ambiguous") )
var ErrIncompleteBlobConfig = errors.New("config: the object store configuration is incomplete")
ErrIncompleteBlobConfig reports an object store selection that names too little to reach a bucket.
An incomplete selection refuses startup rather than falling back to the filesystem. A deployment that asked for a shared store and silently got a per-node directory would serve a file on one node and a not-found result on the next, and nothing in the request path would say why.
Functions ¶
func OperatorError ¶ added in v1.0.1
OperatorError returns an error that is safe to show without configured values. It preserves the original error for programmatic inspection.
Types ¶
type AuthMode ¶ added in v1.1.0
AuthMode selects whether a request must carry a gateway API key.
The type is an alias and not a second spelling. A configuration value, a command-line flag, and the console switch all state the same decision, and internal/authmode owns it so the three cannot drift apart.
type BadgerConfig ¶
type BadgerConfig struct {
Path string `env:"PATH,overwrite"`
SyncWrites bool `env:"SYNC_WRITES,default=false"`
Compression string `env:"COMPRESSION,default=snappy"`
GCInterval time.Duration `env:"GC_INTERVAL,default=5m"`
GCDiscardRatio float64 `env:"GC_DISCARD_RATIO,default=0.5"`
// contains filtered or unexported fields
}
BadgerConfig defines Badger DB settings
func (*BadgerConfig) Validate ¶
func (c *BadgerConfig) Validate() error
Validate validates BadgerConfig
type CacheConfig ¶
type CacheConfig struct {
Enabled bool `env:"ENABLED,default=true"`
}
CacheConfig defines cache settings
type CatalogConfig ¶
type CatalogConfig struct {
WorkspacePath string `env:"WORKSPACE_PATH"`
RefreshOnStart bool `env:"REFRESH_ON_START,default=false"`
RefreshInterval time.Duration `env:"REFRESH_INTERVAL,default=0s"`
RefreshTimeout time.Duration `env:"REFRESH_TIMEOUT,default=2m"`
RemoteURL string `env:"REMOTE_URL" redact:"url"`
RemoteAPIKey string `env:"REMOTE_API_KEY" secret:"true"`
RemoteActivationInterval time.Duration `env:"REMOTE_ACTIVATION_INTERVAL,default=250ms"`
}
CatalogConfig selects local Starmap acquisition or one verified remote Starmap publication source. Acquisition credentials remain in Starmap's provider environment contract.
func (*CatalogConfig) Validate ¶
func (c *CatalogConfig) Validate() error
Validate validates Starmap catalog acquisition settings.
type Config ¶
type Config struct {
Server ServerConfig `env:",prefix=SERVER_"`
Storage StorageConfig `env:",prefix=STORAGE_"`
Catalog CatalogConfig `env:",prefix=CATALOG_"`
CredentialSources CredentialSourcesConfig `env:",prefix=CREDENTIAL_SOURCES_"`
Providers ProvidersConfig
RateLimiting RateLimitingConfig `env:",prefix=RATE_LIMITING_"`
Security SecurityConfig `env:",prefix=SECURITY_"`
Logging LoggingConfig `env:",prefix=LOGGING_"`
Cache CacheConfig `env:",prefix=CACHE_"`
Files FilesConfig `env:",prefix=FILES_"`
Jobs JobsConfig `env:",prefix=JOBS_"`
Console ConsoleConfig `env:",prefix=CONSOLE_"`
Identity IdentityConfig `env:",prefix=IDENTITY_"`
// contains filtered or unexported fields
}
Config represents the complete application configuration
func LoadDevelopment ¶ added in v1.0.3
LoadDevelopment loads process environment settings without a configuration file and applies the guarded development runtime contract.
func LoadWithDefaults ¶
LoadWithDefaults loads configuration from the standard sources.
func (*Config) AuthModeSource ¶ added in v1.1.0
AuthModeSource names where the stated authentication mode came from, or SourceUnset when nobody stated one. Startup passes it to authmode.Resolve, which decides whether a mode an operator stored from the console applies.
func (*Config) ConfigureDevelopmentRuntime ¶ added in v1.0.3
func (c *Config) ConfigureDevelopmentRuntime()
ConfigureDevelopmentRuntime selects process-local settings that cannot expose a development gateway or create persistent state.
func (*Config) EnableProvider ¶ added in v1.0.2
func (c *Config) EnableProvider(providerID catalogs.ProviderID)
EnableProvider marks one exact catalog provider for operator credential resolution. Catalog membership and adapter activation remain independent.
func (*Config) ResolveProviderRuntime ¶ added in v1.0.3
func (c *Config) ResolveProviderRuntime( ctx context.Context, provider catalogs.Provider, explicit ProviderConfig, refresh bool, ) (ProviderConfig, bool, error)
ResolveProviderRuntime resolves one catalog provider. Refresh bypasses a fresh cache entry but preserves valid cached material after a transient source failure.
func (*Config) ResolveProviderSet ¶ added in v1.0.2
func (c *Config) ResolveProviderSet( ctx context.Context, providers catalogs.ProvidersReader, settings ProvidersConfig, ) (ProvidersConfig, error)
ResolveProviderSet resolves one deployment-owned provider configuration against an exact catalog without changing the supplied settings.
func (*Config) ResolveProviderSetLocalIsolated ¶ added in v1.0.3
func (c *Config) ResolveProviderSetLocalIsolated( ctx context.Context, providers catalogs.ProvidersReader, settings ProvidersConfig, ) (ProvidersConfig, []ProviderResolutionFailure, error)
ResolveProviderSetLocalIsolated resolves startup-local environment fields without contacting a remote secret source or cloud identity endpoint. The background reconciler owns external source discovery.
func (*Config) ResolveProviders ¶ added in v1.0.2
ResolveProviders resolves named inference material from the active Starmap provider collection. It validates the complete alias namespace before the first environment read.
type ConsoleConfig ¶ added in v1.1.0
type ConsoleConfig struct {
Enabled bool `env:"ENABLED,default=true"`
}
ConsoleConfig defines settings for the embedded web console
type CredentialReference ¶ added in v1.0.2
type CredentialReference struct {
Reference string `json:"reference"`
FallbackAmbient bool `json:"fallback_ambient,omitempty"`
}
CredentialReference selects one explicit source for a catalog credential field. Ambient fallback applies only to a not-configured source result.
type CredentialSourcesConfig ¶ added in v1.0.2
type CredentialSourcesConfig struct {
RemoteRefreshInterval time.Duration `env:"REMOTE_REFRESH_INTERVAL,default=5m"`
ReconcileInterval time.Duration `env:"RECONCILE_INTERVAL,default=1m"`
ReconcileTimeout time.Duration `env:"RECONCILE_TIMEOUT,default=10s"`
}
CredentialSourcesConfig defines direct inference secret-source lifecycle.
func (*CredentialSourcesConfig) Validate ¶ added in v1.0.2
func (c *CredentialSourcesConfig) Validate() error
Validate validates the direct inference secret-source lifecycle.
type FilesConfig ¶ added in v1.1.0
type FilesConfig struct {
// Backend names the store. An absent value selects the filesystem, which
// needs nothing configured and serves one node.
Backend string `env:"BACKEND,default=filesystem"`
// Path roots the filesystem backend. An absent value puts the objects in
// the platform data directory, beside the record store.
Path string `env:"PATH"`
// MaxUploadBytes bounds one upload. It is a deployment decision rather
// than a wire-format one: the same request that a shared object store
// absorbs can fill the disk of a single node. FIL6 adds the separate
// bound on what one account may keep stored at once.
MaxUploadBytes int64 `env:"MAX_UPLOAD_BYTES,default=536870912"`
// Retention is how long a stored file stays readable. Every file expires,
// and an upload may ask for a shorter window but never a longer one.
Retention time.Duration `env:"RETENTION,default=720h"`
// SweepInterval is how often the gateway reclaims expired and abandoned
// files. It is a floor on how long deleted bytes survive, not on how long
// a file reads: an expired file reads as not found the moment it expires.
SweepInterval time.Duration `env:"SWEEP_INTERVAL,default=1h"`
ObjectStore ObjectStoreConfig `env:",prefix=OBJECT_STORE_"`
}
FilesConfig selects where uploaded file bytes land.
func (*FilesConfig) RetentionWindow ¶ added in v1.1.0
func (c *FilesConfig) RetentionWindow() time.Duration
RetentionWindow reports how long a stored file stays readable.
func (*FilesConfig) SelectedBackend ¶ added in v1.1.0
func (c *FilesConfig) SelectedBackend() string
SelectedBackend reports the backend this configuration names, with the filesystem standing in for an absent value.
func (*FilesConfig) SweepEvery ¶ added in v1.1.0
func (c *FilesConfig) SweepEvery() time.Duration
SweepEvery reports how often the reclaim pass runs.
func (*FilesConfig) UploadBound ¶ added in v1.1.0
func (c *FilesConfig) UploadBound() int64
UploadBound reports the bound one upload may reach, with the default standing in for an absent or nonsense value.
func (*FilesConfig) Validate ¶ added in v1.1.0
func (c *FilesConfig) Validate() error
Validate reports a selection this build cannot open.
type IdentityConfig ¶ added in v1.1.0
type IdentityConfig struct {
CallbackBaseURL string `env:"CALLBACK_BASE_URL" redact:"url"`
OAuth OAuthIdentityConfig `env:",prefix=OAUTH_"`
WorkOS WorkOSIdentityConfig `env:",prefix=WORKOS_"`
}
IdentityConfig defines how people authenticate to the console through an external identity provider. CallbackBaseURL is the address every provider sends the browser back to — scheme and host, no path — and is shared by every acquisition path.
func (IdentityConfig) Enabled ¶ added in v1.1.0
func (c IdentityConfig) Enabled() bool
Enabled reports whether any acquisition path is configured.
func (IdentityConfig) RuntimeAcquisition ¶ added in v1.1.0
func (c IdentityConfig) RuntimeAcquisition() identity.AcquisitionConfig
RuntimeAcquisition projects the operator's settings into the identity contract. A half-configured path is passed through rather than dropped, so the acquisition path can refuse it with a named error instead of this projection silently turning it off.
type JobsConfig ¶ added in v1.1.0
type JobsConfig struct {
// AssetRetention is how long a finished asset stays readable, measured from
// the moment this gateway stored it. A caller that comes back past it reads
// that the asset expired rather than that the job never produced one.
AssetRetention time.Duration `env:"ASSET_RETENTION,default=24h"`
// MaxAssetBytes bounds one stored asset. Without it a provider's decision
// about how large its own answer is would size this deployment's storage.
MaxAssetBytes int64 `env:"MAX_ASSET_BYTES,default=268435456"`
// SweepInterval is how often the gateway reclaims expired asset storage. It
// is a floor on how long expired bytes survive on disk, not on how long an
// asset reads: an expired asset stops reading the moment it expires.
SweepInterval time.Duration `env:"SWEEP_INTERVAL,default=1h"`
}
JobsConfig sizes what a gateway keeps for work that outlives its request.
A provider serves a finished video from a link that expires, so Starport fetches the bytes and answers for them itself. Bytes with no stated window turn a gateway into unbounded storage that no operator sized, which is what these three settings exist to stop.
func (*JobsConfig) AssetBound ¶ added in v1.1.0
func (c *JobsConfig) AssetBound() int64
AssetBound reports the largest asset this deployment stores.
func (*JobsConfig) AssetRetentionWindow ¶ added in v1.1.0
func (c *JobsConfig) AssetRetentionWindow() time.Duration
AssetRetentionWindow reports how long a stored asset stays readable.
func (*JobsConfig) SweepEvery ¶ added in v1.1.0
func (c *JobsConfig) SweepEvery() time.Duration
SweepEvery reports how often the reclaim pass runs.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader reads configuration without changing process state.
func NewLoader ¶
func NewLoader() *Loader
NewLoader creates a loader for the process environment and platform paths.
func (*Loader) Load ¶
Load resolves configuration sources, applies defaults and any overrides, and validates the result.
func (*Loader) LoadDevelopment ¶ added in v1.0.3
LoadDevelopment reads process settings, applies the guarded development runtime contract and any overrides, and validates the result.
func (*Loader) WithEnvFiles ¶
WithEnvFiles sets environment files in descending precedence order. An empty list disables file loading.
func (*Loader) WithEnvironment ¶ added in v1.0.1
WithEnvironment replaces the process environment source.
type LoggingConfig ¶
type LoggingConfig struct {
Level string `env:"LEVEL,default=info"`
Format string `env:"FORMAT,default=json"`
Output string `env:"OUTPUT,default=stdout"`
FilePath string `env:"FILE_PATH"`
MaxSize int `env:"MAX_SIZE,default=100"`
MaxBackups int `env:"MAX_BACKUPS,default=3"`
MaxAge int `env:"MAX_AGE,default=7"`
Compress bool `env:"COMPRESS,default=true"`
}
LoggingConfig defines logging settings
func (*LoggingConfig) Validate ¶
func (c *LoggingConfig) Validate() error
Validate validates LoggingConfig
type OAuthApplicationConfig ¶ added in v1.1.0
type OAuthApplicationConfig struct {
ClientID string `env:"CLIENT_ID"`
ClientSecret string `env:"CLIENT_SECRET" secret:"true"`
}
OAuthApplicationConfig is one registered OAuth application's credential pair.
type OAuthIdentityConfig ¶ added in v1.1.0
type OAuthIdentityConfig struct {
Google OAuthApplicationConfig `env:",prefix=GOOGLE_"`
GitHub OAuthApplicationConfig `env:",prefix=GITHUB_"`
}
OAuthIdentityConfig names the OAuth applications an operator registered. Each provider is on when both halves of its application credential are set.
func (OAuthIdentityConfig) Enabled ¶ added in v1.1.0
func (c OAuthIdentityConfig) Enabled() bool
Enabled reports whether any OAuth provider is configured.
type ObjectStoreConfig ¶ added in v1.1.0
type ObjectStoreConfig struct {
// Bucket names the bucket. It is the one field with no default.
Bucket string `env:"BUCKET"`
// Region names the region. AWS S3 needs it. Another implementation
// usually accepts any value beside an explicit endpoint.
Region string `env:"REGION"`
// Endpoint addresses an implementation other than AWS S3. An absent value
// selects the AWS endpoint for the region.
Endpoint string `env:"ENDPOINT" redact:"url"`
// Prefix scopes every key this deployment writes, so one bucket can hold
// more than one deployment.
Prefix string `env:"PREFIX"`
// AccessKeyID and SecretAccessKey state static credentials. Both absent
// selects the ambient AWS credential chain, which is the usual choice on
// an instance that carries a role.
AccessKeyID string `env:"ACCESS_KEY_ID" secret:"true"`
SecretAccessKey string `env:"SECRET_ACCESS_KEY" secret:"true"`
}
ObjectStoreConfig addresses one S3-compatible bucket.
The two key fields carry the `secret` tag, so Redacted removes them from every inspection the console and the CLI print. No error this package returns names them either.
type Override ¶ added in v1.1.0
type Override func(*Config)
Override is one decision a caller made outside the environment, applied after configuration sources are read and before validation runs. A command line flag is the reason it exists: a flag has to meet exactly the same validation an environment value meets, or the checks that read it prove nothing about the flag.
func AllowRemoteWithoutAuthentication ¶ added in v1.1.0
func AllowRemoteWithoutAuthentication() Override
AllowRemoteWithoutAuthentication acknowledges that an unauthenticated gateway may bind an address the network can reach. Alone it changes nothing; it only lifts the tripwire that DisableAuthentication would otherwise trip.
func DisableAuthentication ¶ added in v1.1.0
func DisableAuthentication() Override
DisableAuthentication turns off the gateway API key check. It carries the same weight as STARPORT_SECURITY_AUTH_MODE=disabled, including the exposure tripwire that refuses a non-loopback bind address. It also records that a flag, not the environment, decided: the two write the same field, and a mode an operator stored from the console yields to either, so startup has to be able to name which one it is honoring.
type Paths ¶ added in v1.0.1
type Paths struct {
ConfigDir string `json:"config_dir"`
ConfigFile string `json:"config_file"`
DataDir string `json:"data_dir"`
BadgerDir string `json:"badger_dir"`
// SQLiteFile holds the embedded relational database. It sits in the data
// directory beside the Badger store: the same machine state, the other
// shape.
SQLiteFile string `json:"sqlite_file"`
// FilesDir roots the filesystem blob backend. It sits in the data
// directory beside the record store, because the bytes are state this
// machine holds rather than a decision an operator wrote down.
FilesDir string `json:"files_dir"`
// LocalTokenFile holds this machine's local admin token. It sits in the
// data directory rather than beside the configuration file, because it is
// state this machine generated and not a decision an operator wrote down.
LocalTokenFile string `json:"local_token_file"`
// WelcomeStampFile records that this machine has been told how to open the
// console. It exists so the greeting prints once: an operator who has run
// the gateway before is not a new operator, and a banner that repeats every
// start is one an experienced reader learns to skip past the day they
// needed it.
WelcomeStampFile string `json:"welcome_stamp_file"`
}
Paths contains the platform-owned files and directories that Starport uses.
func PathsForConfigDir ¶ added in v1.0.1
PathsForConfigDir derives all managed paths from one configuration directory.
func PlatformPaths ¶ added in v1.0.1
PlatformPaths resolves the current user's Starport paths.
type ProviderConfig ¶
type ProviderConfig struct {
BaseURL string `redact:"url"`
CredentialReferences map[catalogs.ProviderCredentialFieldID]CredentialReference `json:"credential_references,omitempty"`
Material credentials.Material `json:"-"`
CredentialSource credentials.MaterialSource `json:"-"`
Timeout time.Duration `json:"timeout"`
MaxConnections int `json:"max_connections"`
Enabled bool `json:"enabled"`
}
ProviderConfig defines settings for a single LLM provider
func (*ProviderConfig) Validate ¶
func (c *ProviderConfig) Validate() error
Validate validates ProviderConfig.
type ProviderEntry ¶
type ProviderEntry struct {
ProviderID catalogs.ProviderID
Config ProviderConfig
}
ProviderEntry binds external operator configuration to one exact Starmap provider ID.
type ProviderResolutionFailure ¶ added in v1.0.3
type ProviderResolutionFailure struct {
ProviderID catalogs.ProviderID
Err error
}
ProviderResolutionFailure identifies one provider whose inference material could not be resolved. It contains no credential material.
type ProvidersConfig ¶
type ProvidersConfig map[catalogs.ProviderID]ProviderConfig
ProvidersConfig stores inference settings by exact Starmap provider ID. Provider membership comes from the active catalog, not this map.
func CloneProvidersConfig ¶ added in v1.0.2
func CloneProvidersConfig(source ProvidersConfig) ProvidersConfig
CloneProvidersConfig returns a caller-owned copy of deployment provider settings. Material and source values are immutable handles.
func (ProvidersConfig) Entries ¶
func (c ProvidersConfig) Entries() []ProviderEntry
Entries returns all supported external configuration slots. Adapter semantics and provider membership remain outside the configuration package.
func (*ProvidersConfig) Validate ¶
func (c *ProvidersConfig) Validate() error
Validate validates each active provider configuration.
type RateLimitingConfig ¶
type RateLimitingConfig struct {
DefaultRequestsPerMinute int `env:"DEFAULT_REQUESTS_PER_MINUTE,default=60"`
WindowSize time.Duration `env:"WINDOW_SIZE,default=1m"`
}
RateLimitingConfig defines the global default request window. Per-key request limits and budgets live on the identity record and beat these defaults.
func (*RateLimitingConfig) Validate ¶
func (c *RateLimitingConfig) Validate() error
Validate validates RateLimitingConfig
type SQLConfig ¶ added in v1.1.0
type SQLConfig struct {
Mode string `env:"MODE,default=sqlite"`
SQLite SQLiteConfig `env:",prefix=SQLITE_"`
Postgres SQLPostgresConfig `env:",prefix=POSTGRES_"`
MySQL SQLMySQLConfig `env:",prefix=MYSQL_"`
}
SQLConfig defines relational store settings.
type SQLMySQLConfig ¶ added in v1.1.0
type SQLMySQLConfig struct {
DSN string `env:"DSN" secret:"true"`
}
SQLMySQLConfig defines the MySQL connect's settings. The DSN embeds the password, so inspection redacts it whole.
type SQLPostgresConfig ¶ added in v1.1.0
type SQLPostgresConfig struct {
URL string `env:"URL" redact:"url"`
}
SQLPostgresConfig defines the PostgreSQL connect's settings.
type SQLiteConfig ¶ added in v1.1.0
type SQLiteConfig struct {
Path string `env:"PATH,overwrite"`
}
SQLiteConfig defines the embedded relational store's settings. An empty path keeps the database in memory, which is the development runtime's choice.
type SecurityConfig ¶
type SecurityConfig struct {
MasterKey string `env:"MASTER_KEY" secret:"true"`
TLSCertPath string `env:"TLS_CERT_PATH"`
TLSKeyPath string `env:"TLS_KEY_PATH"`
EnableTLS bool `env:"ENABLE_TLS,default=false"`
AllowedOrigins string `env:"ALLOWED_ORIGINS"`
EnableCORS bool `env:"ENABLE_CORS,default=false"`
JWTSecret string `env:"JWT_SECRET" secret:"true"`
APIKeyHeader string `env:"API_KEY_HEADER,default=Authorization"`
EnableRateLimiting bool `env:"ENABLE_RATE_LIMITING,default=true"`
// AuthMode selects whether the gateway requires a gateway API key. It
// carries no default, so an unset value stays empty and startup can tell
// "the operator said required" from "the operator said nothing". Only the
// second yields to a mode an operator stored from the console.
AuthMode AuthMode `env:"AUTH_MODE"`
// AllowRemoteNoAuth is the second, explicit acknowledgment that an
// unauthenticated gateway may bind an address the network can reach.
// Without it, startup refuses that combination; see the tripwire in
// validation.go.
AllowRemoteNoAuth bool `env:"ALLOW_REMOTE_NO_AUTH,default=false"`
// UnauthenticatedScopes lists the scopes a request holds while AuthMode
// is disabled. An empty list means the built-in default, which is every
// account scope and never admin. An operator who wants the admin plane
// open without a key has to name "admin" here.
UnauthenticatedScopes []string `env:"UNAUTHENTICATED_SCOPES"`
// LocalTokenPath is the file holding this machine's local admin token.
//
// It carries no environment tag on purpose. The gateway reads it from here
// and the CLI reads it from Paths, and both derive from one function, so
// the two cannot disagree about where the credential lives. A second knob
// for this one file would make disagreeing possible, and a CLI that rotates
// a token the running gateway never reads is worse than no command at all.
// An operator who needs the file elsewhere moves everything with
// STARPORT_CONFIG_DIR.
LocalTokenPath string `json:"local_token_path"`
// contains filtered or unexported fields
}
SecurityConfig defines security settings
func (SecurityConfig) LocalTokenReadOnly ¶ added in v1.1.0
func (c SecurityConfig) LocalTokenReadOnly() bool
LocalTokenReadOnly reports whether this process must not write the local admin token file: read the machine's token if it exists, hold an ephemeral one otherwise.
func (*SecurityConfig) Validate ¶
func (c *SecurityConfig) Validate() error
Validate validates SecurityConfig
type ServerConfig ¶
type ServerConfig struct {
Port int `env:"PORT,default=8080"`
Host string `env:"HOST,default=127.0.0.1"`
ReadTimeout time.Duration `env:"READ_TIMEOUT,default=30s"`
WriteTimeout time.Duration `env:"WRITE_TIMEOUT,default=30s"`
IdleTimeout time.Duration `env:"IDLE_TIMEOUT,default=120s"`
RequestTimeout time.Duration `env:"REQUEST_TIMEOUT,default=60s"`
MaxRequestSize int64 `env:"MAX_REQUEST_SIZE,default=33554432"`
MaxHeaderBytes int `env:"MAX_HEADER_BYTES,default=1048576"`
ShutdownTimeout time.Duration `env:"SHUTDOWN_TIMEOUT,default=30s"`
EnableProfiling bool `env:"ENABLE_PROFILING,default=false"`
EnableHealthCheck bool `env:"ENABLE_HEALTH_CHECK,default=true"`
}
ServerConfig defines HTTP server settings
func (*ServerConfig) Validate ¶
func (c *ServerConfig) Validate() error
Validate validates ServerConfig
type StorageConfig ¶
type StorageConfig struct {
Mode string `env:"MODE,default=badger"`
Badger BadgerConfig `env:",prefix=BADGER_"`
Valkey ValkeyConfig `env:",prefix=VALKEY_"`
SQL SQLConfig `env:",prefix=SQL_"`
}
StorageConfig defines storage backend settings. Mode selects the key-value store; SQL selects its relational twin, which pairs an embedded SQLite database with a network connect the way Badger pairs with Valkey.
func (StorageConfig) RuntimeSQL ¶ added in v1.1.0
func (c StorageConfig) RuntimeSQL() sqlstore.Config
RuntimeSQL projects the relational settings into the sqlstore contract, the way RuntimeStorage projects the key-value ones.
func (StorageConfig) RuntimeStorage ¶ added in v1.0.1
func (c StorageConfig) RuntimeStorage() storage.Config
RuntimeStorage projects external storage settings into the storage adapter contract.
func (*StorageConfig) Validate ¶
func (c *StorageConfig) Validate() error
Validate validates StorageConfig
type ValkeyConfig ¶
type ValkeyConfig struct {
URL string `env:"URL,default=valkey://localhost:6379" redact:"url"`
MaxConnections int `env:"MAX_CONNECTIONS,default=50"`
MinIdleConns int `env:"MIN_IDLE_CONNS,default=10"`
DialTimeout time.Duration `env:"DIAL_TIMEOUT,default=5s"`
ReadTimeout time.Duration `env:"READ_TIMEOUT,default=3s"`
WriteTimeout time.Duration `env:"WRITE_TIMEOUT,default=3s"`
IdleTimeout time.Duration `env:"IDLE_TIMEOUT,default=5m"`
ClusterMode bool `env:"CLUSTER_MODE,default=false"`
Password string `env:"PASSWORD" secret:"true"`
}
ValkeyConfig defines Valkey/Redis settings
func (*ValkeyConfig) Validate ¶
func (c *ValkeyConfig) Validate() error
Validate validates ValkeyConfig
type WorkOSIdentityConfig ¶ added in v1.1.0
type WorkOSIdentityConfig struct {
APIKey string `env:"API_KEY" secret:"true"`
ClientID string `env:"CLIENT_ID"`
Organization string `env:"ORGANIZATION"`
Connection string `env:"CONNECTION"`
}
WorkOSIdentityConfig is the enterprise SSO broker's settings. APIKey and ClientID come from the WorkOS dashboard; Organization or Connection names which enterprise directory people arrive from.