config

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config loads, validates, and normalizes gateway runtime configuration.

Index

Constants

View Source
const (
	PIIModeOff            = "off"
	PIIModeRedactStorage  = "redact_storage"
	PIIModeRedactUpstream = "redact_upstream"
	PIIModeBlock          = "block"
)

Variables

This section is empty.

Functions

func Validate

func Validate(cfg Config) error

Validate checks configuration invariants required at runtime.

Types

type AuthConfig

type AuthConfig struct {
	Enabled bool               `yaml:"enabled"`
	Header  string             `yaml:"header"`
	Keys    []GatewayKeyConfig `yaml:"keys"`
}

type Config

type Config struct {
	Server        ServerConfig        `yaml:"server"`
	Storage       StorageConfig       `yaml:"storage"`
	Providers     ProvidersConfig     `yaml:"providers"`
	Tracing       TracingConfig       `yaml:"tracing"`
	Observability ObservabilityConfig `yaml:"observability"`
	PII           PIIConfig           `yaml:"pii"`
	Auth          AuthConfig          `yaml:"auth"`
	Limits        LimitsConfig        `yaml:"limits"`
}

func Default

func Default() Config

func Load

func Load(path string) (Config, error)

func (Config) EffectivePIIMode

func (cfg Config) EffectivePIIMode() string

func (Config) ResolvePIIPolicy

func (cfg Config) ResolvePIIPolicy(input PIIScopeInput) PIIConfig

type GatewayKeyConfig

type GatewayKeyConfig struct {
	ID          string   `yaml:"id"`
	Token       string   `yaml:"token"`
	OrgID       string   `yaml:"org_id"`
	WorkspaceID string   `yaml:"workspace_id"`
	Team        string   `yaml:"team"` // Backward-compatible alias for workspace_id.
	Name        string   `yaml:"name"`
	Description string   `yaml:"description"`
	CreatedBy   string   `yaml:"created_by"`
	Role        string   `yaml:"role"`
	Permissions []string `yaml:"permissions"`
}

type LimitsConfig

type LimitsConfig struct {
	PerKey       UsageLimitConfig `yaml:"per_key"`
	PerWorkspace UsageLimitConfig `yaml:"per_workspace"`
}

type OTelConfig

type OTelConfig struct {
	Enabled                bool    `yaml:"enabled"`
	Endpoint               string  `yaml:"endpoint"`
	Insecure               bool    `yaml:"insecure"`
	ServiceName            string  `yaml:"service_name"`
	TracesEnabled          bool    `yaml:"traces_enabled"`
	MetricsEnabled         bool    `yaml:"metrics_enabled"`
	PrometheusEnabled      bool    `yaml:"prometheus_enabled"`
	PrometheusPath         string  `yaml:"prometheus_path"`
	SamplingRatio          float64 `yaml:"sampling_ratio"`
	ExportTimeoutMS        int     `yaml:"export_timeout_ms"`
	MetricExportIntervalMS int     `yaml:"metric_export_interval_ms"`
}

type ObservabilityConfig

type ObservabilityConfig struct {
	OTel OTelConfig `yaml:"otel"`
}

type PIIBodyConfig

type PIIBodyConfig struct {
	KeyDenylist []string `yaml:"key_denylist"`
}

type PIIConfig

type PIIConfig struct {
	Mode        string               `yaml:"mode"`
	PolicyID    string               `yaml:"policy_id"`
	Stages      PIIStagesConfig      `yaml:"stages"`
	Detectors   PIIDetectorsConfig   `yaml:"detectors"`
	Headers     PIIHeadersConfig     `yaml:"headers"`
	Body        PIIBodyConfig        `yaml:"body"`
	Replacement PIIReplacementConfig `yaml:"replacement"`
	Scopes      []PIIScopeConfig     `yaml:"scopes"`
}

type PIIDetectorsConfig

type PIIDetectorsConfig struct {
	Email     bool `yaml:"email"`
	Phone     bool `yaml:"phone"`
	SSN       bool `yaml:"ssn"`
	TokenLike bool `yaml:"token_like"`
}

type PIIHeadersConfig

type PIIHeadersConfig struct {
	Denylist []string `yaml:"denylist"`
}

type PIIReplacementConfig

type PIIReplacementConfig struct {
	Format   string `yaml:"format"`
	HashSalt string `yaml:"hash_salt"`
}

type PIIScopeConfig

type PIIScopeConfig struct {
	Match    PIIScopeMatchConfig `yaml:"match"`
	Mode     string              `yaml:"mode"`
	PolicyID string              `yaml:"policy_id"`
}

type PIIScopeInput

type PIIScopeInput struct {
	OrgID       string
	WorkspaceID string
	KeyID       string
	Provider    string
	Route       string
}

type PIIScopeMatchConfig

type PIIScopeMatchConfig struct {
	OrgID       string `yaml:"org_id"`
	WorkspaceID string `yaml:"workspace_id"`
	KeyID       string `yaml:"key_id"`
	Provider    string `yaml:"provider"`
	RoutePrefix string `yaml:"route_prefix"`
}

type PIIStagesConfig

type PIIStagesConfig struct {
	RequestHeaders  bool `yaml:"request_headers"`
	RequestBody     bool `yaml:"request_body"`
	ResponseHeaders bool `yaml:"response_headers"`
	ResponseBody    bool `yaml:"response_body"`
}

type ProviderConfig

type ProviderConfig struct {
	Upstream string `yaml:"upstream"`
	Prefix   string `yaml:"prefix"`
}

type ProvidersConfig

type ProvidersConfig struct {
	OpenAI    ProviderConfig `yaml:"openai"`
	Anthropic ProviderConfig `yaml:"anthropic"`
}

type ServerConfig

type ServerConfig struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
}

func (ServerConfig) Address

func (c ServerConfig) Address() string

type StorageConfig

type StorageConfig struct {
	Driver string `yaml:"driver"`
	Path   string `yaml:"path"`
	DSN    string `yaml:"dsn"`
}

type TracingConfig

type TracingConfig struct {
	CaptureBodies bool `yaml:"capture_bodies"`
	BodyMaxSize   int  `yaml:"body_max_size"`
}

type UsageLimitConfig

type UsageLimitConfig struct {
	RequestsPerMinute int     `yaml:"requests_per_minute"`
	MaxTokensPerDay   int64   `yaml:"max_tokens_per_day"`
	MaxCostUSDPerDay  float64 `yaml:"max_cost_usd_per_day"`
}

Jump to

Keyboard shortcuts

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