{"modulePath":"github.com/openshift-hyperfleet/hyperfleet-api","version":"v0.4.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package config\n\n## Constants\n\n```go\nconst (\n\tDefaultJWTHeader        = \"Authorization\"\n\tDefaultJWTIdentityClaim = \"email\"\n)\n```\n\n```go\nconst EnvPrefix = \"HYPERFLEET\"\n```\nEnvPrefix is the environment variable prefix for all HyperFleet configuration. All configuration can be set via environment variables using the format:\n\n\tHYPERFLEET_\u003cSECTION\u003e_\u003cKEY\u003e=value\n\nFor example:\n\n  - HYPERFLEET\\_SERVER\\_HOST=0.0.0.0\n  - HYPERFLEET\\_DATABASE\\_PASSWORD=secret\n  - HYPERFLEET\\_LOGGING\\_LEVEL=debug\n\n```go\nconst (\n\t// RedactedValue is used to mask sensitive data in logs and JSON output\n\t// Must match pkg/middleware/masking.go RedactedValue for consistency\n\tRedactedValue = \"***REDACTED***\"\n)\n```\n\n## Functions\n\n```go\nfunc AddAllConfigFlags(cmd *cobra.Command)\n```\nAddAllConfigFlags adds all configuration flags to the command This is a convenience function that adds all flag groups\n\n```go\nfunc AddConfigFlag(cmd *cobra.Command)\n```\nAddConfigFlags adds the --config flag to the command This flag has highest priority in config file resolution\n\n```go\nfunc AddDatabaseFlags(cmd *cobra.Command)\n```\nAddDatabaseFlags adds database configuration flags following standard naming Format: --db-\\\u003cfield\u003e maps to HYPERFLEET\\_DATABASE\\_\\\u003cFIELD\u003e and database.\\\u003cfield\u003e\n\n```go\nfunc AddHealthFlags(cmd *cobra.Command)\n```\nAddHealthFlags adds health check configuration flags following standard naming Format: --health-\\\u003cfield\u003e maps to HYPERFLEET\\_HEALTH\\_\\\u003cFIELD\u003e and health.\\\u003cfield\u003e\n\n```go\nfunc AddLoggingFlags(cmd *cobra.Command)\n```\nAddLoggingFlags adds logging configuration flags following standard naming Format: --log-\\\u003cfield\u003e maps to HYPERFLEET\\_LOGGING\\_\\\u003cFIELD\u003e and logging.\\\u003cfield\u003e\n\n```go\nfunc AddMetricsFlags(cmd *cobra.Command)\n```\nAddMetricsFlags adds metrics configuration flags following standard naming Format: --metrics-\\\u003cfield\u003e maps to HYPERFLEET\\_METRICS\\_\\\u003cFIELD\u003e and metrics.\\\u003cfield\u003e\n\n```go\nfunc AddServerFlags(cmd *cobra.Command)\n```\nAddServerFlags adds server configuration flags following standard naming Format: --server-\\\u003cfield\u003e maps to HYPERFLEET\\_SERVER\\_\\\u003cFIELD\u003e and server.\\\u003cfield\u003e\n\n```go\nfunc DumpConfig(config *ApplicationConfig) string\n```\nDumpConfig returns a human-readable string representation of configuration with sensitive fields redacted. Useful for debugging.\n\n## Types\n\n```go\ntype ApplicationConfig struct {\n\tServer   *ServerConfig               `mapstructure:\"server\" json:\"server\" validate:\"required\"`\n\tMetrics  *MetricsConfig              `mapstructure:\"metrics\" json:\"metrics\" validate:\"required\"`\n\tHealth   *HealthConfig               `mapstructure:\"health\" json:\"health\" validate:\"required\"`\n\tDatabase *DatabaseConfig             `mapstructure:\"database\" json:\"database\" validate:\"required\"`\n\tLogging  *LoggingConfig              `mapstructure:\"logging\" json:\"logging\" validate:\"required\"`\n\tTracing  *TracingConfig              `mapstructure:\"tracing\" json:\"tracing\" validate:\"required\"`\n\tEntities []registry.EntityDescriptor `mapstructure:\"entities\" json:\"entities\"`\n}\n```\nApplicationConfig holds all application configuration Follows HyperFleet Configuration Standard with validation and structured marshaling\n\n```go\nfunc NewApplicationConfig() *ApplicationConfig\n```\nNewApplicationConfig returns default ApplicationConfig with all sub-configs initialized These defaults can be overridden by config file, env vars, or CLI flags\n\n```go\ntype ConfigLoader struct {\n\t// contains filtered or unexported fields\n}\n```\nConfigLoader handles loading and validating application configuration following the HyperFleet Configuration Standard.\n\n```go\nfunc NewConfigLoader() *ConfigLoader\n```\nNewConfigLoader creates a new configuration loader\n\n```go\nfunc (l *ConfigLoader) Load(ctx context.Context, cmd *cobra.Command) (*ApplicationConfig, error)\n```\nLoad loads configuration from all sources according to priority: 1. Command-line flags (highest priority) 2. Environment variables 3. Configuration files 4. Defaults (lowest priority)\n\nReturns validated ApplicationConfig or error if validation fails.\n\n```go\ntype DatabaseConfig struct {\n\tDialect      string     `mapstructure:\"dialect\" json:\"dialect\" validate:\"required,oneof=postgres\"`\n\tHost         string     `mapstructure:\"host\" json:\"host\" validate:\"required,hostname|ip\"`\n\tHostFile     string     `mapstructure:\"host_file\" json:\"host_file\"`\n\tName         string     `mapstructure:\"name\" json:\"name\" validate:\"required\"`\n\tNameFile     string     `mapstructure:\"name_file\" json:\"name_file\"`\n\tUsername     string     `mapstructure:\"username\" json:\"-\"`\n\tUsernameFile string     `mapstructure:\"username_file\" json:\"username_file\"`\n\tPassword     string     `mapstructure:\"password\" json:\"-\"`\n\tPasswordFile string     `mapstructure:\"password_file\" json:\"password_file\"`\n\tPortFile     string     `mapstructure:\"port_file\" json:\"port_file\"`\n\tSSL          SSLConfig  `mapstructure:\"ssl\" json:\"ssl\" validate:\"required\"`\n\tPool         PoolConfig `mapstructure:\"pool\" json:\"pool\" validate:\"required\"`\n\tPort         int        `mapstructure:\"port\" json:\"port\" validate:\"required,min=1,max=65535\"`\n\tDebug        bool       `mapstructure:\"debug\" json:\"debug\"`\n}\n```\nDatabaseConfig holds database connection configuration Follows HyperFleet Configuration Standard\n\n```go\nfunc NewDatabaseConfig() *DatabaseConfig\n```\nNewDatabaseConfig returns default DatabaseConfig values These defaults can be overridden by config file, env vars, or CLI flags Includes defaults from HYPERFLEET-694 for connection pool management\n\n```go\nfunc (c *DatabaseConfig) ConnectionString(ssl bool) string\n```\nConnectionString generates database connection string ssl parameter controls whether to include SSL settings\n\n```go\nfunc (c *DatabaseConfig) ConnectionStringWithName(name string, ssl bool) string\n```\nConnectionStringWithName generates database connection string with custom database name This is useful for test databases. ssl parameter controls whether to include SSL settings.\n\n```go\nfunc (c *DatabaseConfig) LogSafeConnectionString(ssl bool) string\n```\nLogSafeConnectionString returns connection string with username and password redacted\n\n```go\nfunc (c *DatabaseConfig) LogSafeConnectionStringWithName(name string, ssl bool) string\n```\nLogSafeConnectionStringWithName returns connection string with custom name and username/password redacted This is useful for test databases.\n\n```go\nfunc (c DatabaseConfig) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements custom JSON marshaling to redact sensitive fields\n\n```go\nfunc (c *DatabaseConfig) ResolveFileOverrides() error\n```\nResolveFileOverrides applies HYPERFLEET\\_DATABASE\\_\\*\\_FILE overrides\n\n```go\nfunc (c *DatabaseConfig) SetLogLevel(globalLogLevel string) logger.LogLevel\n```\nSetLogLevel determines the GORM logger level based on database.debug flag and global logging level. Priority: database.debug \u003e global logging level \u003e default\n\nBehavior:\n\n  - database.debug=true → logger.Info (show all SQL queries)\n  - logging.level=debug → logger.Info (show all SQL queries)\n  - logging.level=error → logger.Silent (suppress all SQL logs)\n  - default → logger.Warn (show only slow queries and errors)\n\n```go\ntype DeprecatedOTelConfig struct {\n\tEnabled bool `mapstructure:\"enabled\" json:\"enabled\"`\n}\n```\nDeprecatedOTelConfig exists solely to let viper unmarshal the old logging.otel key without rejecting it as unknown.\n\n```go\ntype HealthConfig struct {\n\tHost            string        `mapstructure:\"host\" json:\"host\" validate:\"required\"`\n\tTLS             TLSConfig     `mapstructure:\"tls\" json:\"tls\" validate:\"required\"`\n\tPort            int           `mapstructure:\"port\" json:\"port\" validate:\"required,min=1,max=65535\"`\n\tShutdownTimeout time.Duration `mapstructure:\"shutdown_timeout\" json:\"shutdown_timeout\" validate:\"required\"`\n\tDBPingTimeout   time.Duration `mapstructure:\"db_ping_timeout\" json:\"db_ping_timeout\"`\n}\n```\nHealthConfig holds health check server configuration Follows HyperFleet Configuration Standard\n\n```go\nfunc NewHealthConfig() *HealthConfig\n```\nNewHealthConfig returns default HealthConfig values These defaults can be overridden by config file, env vars, or CLI flags\n\n```go\nfunc (h *HealthConfig) BindAddress() string\n```\nBindAddress returns bind address in host:port format Uses net.JoinHostPort to correctly handle IPv6 addresses\n\n```go\nfunc (h *HealthConfig) PingTimeout() time.Duration\n```\n\n```go\nfunc (h *HealthConfig) TLSCertFile() string\n```\n\n```go\nfunc (h *HealthConfig) TLSEnabled() bool\n```\n\n```go\nfunc (h *HealthConfig) TLSKeyFile() string\n```\n\n```go\nfunc (h *HealthConfig) Validate() error\n```\nValidate validates health config durations\n\n```go\ntype JWTConfig struct {\n\tConfigs []JWTIssuerConfig `mapstructure:\"configs\" json:\"configs\"`\n\tEnabled bool              `mapstructure:\"enabled\" json:\"enabled\"`\n}\n```\nJWTConfig holds JWT authentication configuration with support for multiple issuers.\n\n```go\nfunc (c *JWTConfig) ApplyDefaults()\n```\nApplyDefaults sets default values for optional fields in each issuer config. Call this after config loading and before Validate().\n\n```go\nfunc (c *JWTConfig) Validate() error\n```\n\n```go\ntype JWTIssuerConfig struct {\n\tCompiledPattern      *regexp.Regexp `mapstructure:\"-\" json:\"-\"`\n\tIssuerURL            string         `mapstructure:\"issuer_url\" json:\"issuer_url\" validate:\"required,url\"`\n\tJWKCertURL           string         `mapstructure:\"jwk_cert_url\" json:\"jwk_cert_url\" validate:\"omitempty,url\"`\n\tJWKCertFile          string         `mapstructure:\"jwk_cert_file\" json:\"jwk_cert_file\" validate:\"omitempty,filepath\"`\n\tJWKCertCAFile        string         `mapstructure:\"jwk_cert_ca_file\" json:\"jwk_cert_ca_file\" validate:\"omitempty,filepath\"` //nolint:lll\n\tHeader               string         `mapstructure:\"header\" json:\"header\"`\n\tIdentityHeader       string         `mapstructure:\"identity_header\" json:\"identity_header\"`\n\tAudience             string         `mapstructure:\"audience\" json:\"audience\"`\n\tIdentityClaim        string         `mapstructure:\"identity_claim\" json:\"identity_claim\"`\n\tIdentityClaimPattern string         `mapstructure:\"identity_claim_pattern\" json:\"identity_claim_pattern\"`\n}\n```\nJWTIssuerConfig holds configuration for a single JWT issuer (trust anchor). Each entry defines how to validate tokens from one identity provider.\n\n```go\ntype LoggingConfig struct {\n\tLevel   string        `mapstructure:\"level\" json:\"level\" validate:\"required,oneof=debug info warn error\"`\n\tFormat  string        `mapstructure:\"format\" json:\"format\" validate:\"required,oneof=json text\"`\n\tOutput  string        `mapstructure:\"output\" json:\"output\" validate:\"required,oneof=stdout stderr\"`\n\tMasking MaskingConfig `mapstructure:\"masking\" json:\"masking\" validate:\"required\"`\n\t// Deprecated: use TracingConfig.Enabled. Kept so UnmarshalExact accepts\n\t// existing config files that still carry logging.otel.enabled.\n\tOTel DeprecatedOTelConfig `mapstructure:\"otel\" json:\"otel,omitempty\"`\n}\n```\nLoggingConfig holds logging configuration Follows HyperFleet Configuration Standard\n\n```go\nfunc NewLoggingConfig() *LoggingConfig\n```\nNewLoggingConfig returns default LoggingConfig values These defaults can be overridden by config file, env vars, or CLI flags\n\n```go\nfunc (l *LoggingConfig) GetSensitiveFieldsList() []string\n```\nGetSensitiveFieldsList returns list of sensitive fields This is used by logger for masking\n\n```go\nfunc (l *LoggingConfig) GetSensitiveFieldsString() string\n```\nGetSensitiveFieldsString returns fields as comma-separated string\n\n```go\nfunc (l *LoggingConfig) GetSensitiveHeadersList() []string\n```\nGetSensitiveHeadersList returns list of sensitive headers This is used by logger for masking\n\n```go\nfunc (l *LoggingConfig) GetSensitiveHeadersString() string\n```\nGetSensitiveHeadersString returns headers as comma-separated string\n\n```go\ntype MaskingConfig struct {\n\tHeaders []string `mapstructure:\"headers\" json:\"headers\"`\n\tFields  []string `mapstructure:\"fields\" json:\"fields\"`\n\tEnabled bool     `mapstructure:\"enabled\" json:\"enabled\"`\n}\n```\nMaskingConfig holds log masking configuration\n\n```go\ntype MetricsConfig struct {\n\tHost                          string        `mapstructure:\"host\" json:\"host\" validate:\"required\"`\n\tTLS                           TLSConfig     `mapstructure:\"tls\" json:\"tls\" validate:\"required\"`\n\tPort                          int           `mapstructure:\"port\" json:\"port\" validate:\"required,min=1,max=65535\"`\n\tLabelMetricsInclusionDuration time.Duration `mapstructure:\"label_metrics_inclusion_duration\" json:\"label_metrics_inclusion_duration\" validate:\"required\"` //nolint:lll\n\tReconciliationStuckThreshold  time.Duration `mapstructure:\"reconciliation_stuck_threshold\" json:\"reconciliation_stuck_threshold\" validate:\"required\"`     //nolint:lll\n}\n```\nMetricsConfig holds Prometheus metrics server configuration Follows HyperFleet Configuration Standard\n\n```go\nfunc NewMetricsConfig() *MetricsConfig\n```\nNewMetricsConfig returns default MetricsConfig values These defaults can be overridden by config file, env vars, or CLI flags\n\n```go\nfunc (m *MetricsConfig) BindAddress() string\n```\nBindAddress returns bind address in host:port format Uses net.JoinHostPort to correctly handle IPv6 addresses\n\n```go\nfunc (m *MetricsConfig) TLSCertFile() string\n```\n\n```go\nfunc (m *MetricsConfig) TLSEnabled() bool\n```\n\n```go\nfunc (m *MetricsConfig) TLSKeyFile() string\n```\n\n```go\nfunc (m *MetricsConfig) Validate() error\n```\nValidate validates MetricsConfig fields that struct tags cannot enforce\n\n```go\ntype PoolConfig struct {\n\tMaxConnections     int           `mapstructure:\"max_connections\" json:\"max_connections\" validate:\"required,min=1,max=200\"` //nolint:lll // gofmt alignment\n\tMaxIdleConnections int           `mapstructure:\"max_idle_connections\" json:\"max_idle_connections\" validate:\"min=0\"`\n\tConnMaxLifetime    time.Duration `mapstructure:\"conn_max_lifetime\" json:\"conn_max_lifetime\"`\n\tConnMaxIdleTime    time.Duration `mapstructure:\"conn_max_idle_time\" json:\"conn_max_idle_time\"`\n\tRequestTimeout     time.Duration `mapstructure:\"request_timeout\" json:\"request_timeout\"`\n\tConnRetryAttempts  int           `mapstructure:\"conn_retry_attempts\" json:\"conn_retry_attempts\" validate:\"min=1\"`\n\tConnRetryInterval  time.Duration `mapstructure:\"conn_retry_interval\" json:\"conn_retry_interval\"`\n\t// HYPERFLEET-618: prevents indefinite blocking during migrations\n\tAdvisoryLockTimeout time.Duration `mapstructure:\"advisory_lock_timeout\" json:\"advisory_lock_timeout\"`\n}\n```\nPoolConfig holds connection pool configuration Includes fields from HYPERFLEET-694 for connection lifecycle management\n\n```go\ntype SSLConfig struct {\n\tMode         string `mapstructure:\"mode\" json:\"mode\" validate:\"required,oneof=disable require verify-ca verify-full\"`\n\tRootCertFile string `mapstructure:\"root_cert_file\" json:\"root_cert_file\"`\n}\n```\nSSLConfig holds SSL/TLS configuration\n\n```go\ntype ServerConfig struct {\n\tHostname          string         `mapstructure:\"hostname\" json:\"hostname\" validate:\"omitempty,hostname|ip\"`\n\tHost              string         `mapstructure:\"host\" json:\"host\" validate:\"required,hostname|ip\"`\n\tOpenAPISchemaPath string         `mapstructure:\"openapi_schema_path\" json:\"openapi_schema_path\"`\n\tTLS               TLSConfig      `mapstructure:\"tls\" json:\"tls\" validate:\"required\"`\n\tJWT               JWTConfig      `mapstructure:\"jwt\" json:\"jwt\" validate:\"required\"`\n\tTenant            TenantConfig   `mapstructure:\"tenant\" json:\"tenant\" validate:\"required\"`\n\tTimeouts          TimeoutsConfig `mapstructure:\"timeouts\" json:\"timeouts\" validate:\"required\"`\n\tPort              int            `mapstructure:\"port\" json:\"port\" validate:\"required,min=1,max=65535\"`\n}\n```\nServerConfig holds HTTP/HTTPS server configuration Follows HyperFleet Configuration Standard\n\n```go\nfunc NewServerConfig() *ServerConfig\n```\nNewServerConfig returns default ServerConfig values These defaults can be overridden by config file, env vars, or CLI flags\n\n```go\nfunc (s *ServerConfig) BindAddress() string\n```\nBindAddress returns bind address in host:port format Uses net.JoinHostPort to correctly handle IPv6 addresses\n\n```go\nfunc (s *ServerConfig) ReadTimeout() time.Duration\n```\n\n```go\nfunc (s *ServerConfig) TLSCertFile() string\n```\n\n```go\nfunc (s *ServerConfig) TLSEnabled() bool\n```\n\n```go\nfunc (s *ServerConfig) TLSKeyFile() string\n```\n\n```go\nfunc (s *ServerConfig) WriteTimeout() time.Duration\n```\n\n```go\ntype TLSConfig struct {\n\tCertFile string `mapstructure:\"cert_file\" json:\"cert_file\" validate:\"omitempty,filepath\"`\n\tKeyFile  string `mapstructure:\"key_file\" json:\"key_file\" validate:\"omitempty,filepath\"`\n\tEnabled  bool   `mapstructure:\"enabled\" json:\"enabled\"`\n}\n```\nTLSConfig holds TLS configuration\n\n```go\nfunc (c *TLSConfig) Validate() error\n```\nValidate validates TLS configuration\n\n```go\ntype TenantConfig struct {\n\tSystemHeader string            `mapstructure:\"system_header\" json:\"system_header\"`\n\tDimensions   []TenantDimension `mapstructure:\"dimensions\" json:\"dimensions\"`\n\tEnabled      bool              `mapstructure:\"enabled\" json:\"enabled\"`\n}\n```\nTenantConfig holds tenant enforcement middleware configuration. Identity arrives as trusted headers injected by the gateway (Envoy + Authorino); the API never extracts JWT claims for tenancy.\n\n```go\nfunc (c *TenantConfig) Validate() error\n```\nValidate enforces the tenant configuration invariants. A caller resolving zero dimensions must never reach the data layer (an empty tenancy map would contain-match every row), so at least one dimension must be required.\n\n```go\ntype TenantDimension struct {\n\tHeader   string `mapstructure:\"header\" json:\"header\"`\n\tKey      string `mapstructure:\"key\" json:\"key\"`\n\tRequired bool   `mapstructure:\"required\" json:\"required\"`\n}\n```\nTenantDimension maps one trusted gateway-injected header to a tenancy key. Required dimensions must be present for a non-system caller to be granted a tenant context; see TenantConfig.Validate for the at-least-one-required rule.\n\n```go\ntype TimeoutsConfig struct {\n\tRead  time.Duration `mapstructure:\"read\" json:\"read\" validate:\"required\"`\n\tWrite time.Duration `mapstructure:\"write\" json:\"write\" validate:\"required\"`\n}\n```\nTimeoutsConfig holds HTTP timeout configuration\n\n```go\nfunc (c *TimeoutsConfig) Validate() error\n```\nValidate validates timeout durations\n\n```go\ntype TracingConfig struct {\n\tServiceName string `mapstructure:\"service_name\" json:\"service_name\"`\n\tEnabled     bool   `mapstructure:\"enabled\" json:\"enabled\"`\n}\n```\n\n```go\nfunc NewTracingConfig() *TracingConfig\n```\n\n```go\nfunc (c *TracingConfig) Validate() error\n```\n\n","path":"github.com/openshift-hyperfleet/hyperfleet-api/pkg/config","name":"config","synopsis":"","isRedistributable":true}
