Documentation
¶
Index ¶
- Constants
- func AddAllConfigFlags(cmd *cobra.Command)
- func AddConfigFlag(cmd *cobra.Command)
- func AddDatabaseFlags(cmd *cobra.Command)
- func AddHealthFlags(cmd *cobra.Command)
- func AddLoggingFlags(cmd *cobra.Command)
- func AddMetricsFlags(cmd *cobra.Command)
- func AddOCMFlags(cmd *cobra.Command)
- func AddServerFlags(cmd *cobra.Command)
- func DumpConfig(config *ApplicationConfig) string
- type ACLConfig
- type AdapterRequirementsConfig
- type ApplicationConfig
- type AuthzConfig
- type ConfigLoader
- type DatabaseConfig
- func (c *DatabaseConfig) ConnectionString(ssl bool) string
- func (c *DatabaseConfig) ConnectionStringWithName(name string, ssl bool) string
- func (c *DatabaseConfig) LogSafeConnectionString(ssl bool) string
- func (c *DatabaseConfig) LogSafeConnectionStringWithName(name string, ssl bool) string
- func (c DatabaseConfig) MarshalJSON() ([]byte, error)
- func (c *DatabaseConfig) SetLogLevel(globalLogLevel string) logger.LogLevel
- type HealthConfig
- type JWKConfig
- type JWTConfig
- type LoggingConfig
- type MaskingConfig
- type MetricsConfig
- type MockConfig
- type OCMConfig
- type OTelConfig
- type PoolConfig
- type RequiredAdapters
- type SSLConfig
- type ServerConfig
- type TLSConfig
- type TimeoutsConfig
Constants ¶
const EnvPrefix = "HYPERFLEET"
EnvPrefix is the environment variable prefix for all HyperFleet configuration. All configuration can be set via environment variables using the format:
HYPERFLEET_<SECTION>_<KEY>=value
For example:
- HYPERFLEET_SERVER_HOST=0.0.0.0
- HYPERFLEET_DATABASE_PASSWORD=secret
- HYPERFLEET_LOGGING_LEVEL=debug
const ( // RedactedValue is used to mask sensitive data in logs and JSON output // Must match pkg/middleware/masking.go RedactedValue for consistency RedactedValue = "***REDACTED***" )
Variables ¶
This section is empty.
Functions ¶
func AddAllConfigFlags ¶ added in v0.2.0
AddAllConfigFlags adds all configuration flags to the command This is a convenience function that adds all flag groups
Note: Adapter configuration is handled via environment variables (JSON arrays):
- HYPERFLEET_ADAPTERS_REQUIRED_CLUSTER: Required cluster adapters
- HYPERFLEET_ADAPTERS_REQUIRED_NODEPOOL: Required nodepool adapters
No CLI flags are provided for adapters as they are complex types (arrays)
func AddConfigFlag ¶ added in v0.2.0
AddConfigFlags adds the --config flag to the command This flag has highest priority in config file resolution
func AddDatabaseFlags ¶ added in v0.2.0
AddDatabaseFlags adds database configuration flags following standard naming Format: --db-<field> maps to HYPERFLEET_DATABASE_<FIELD> and database.<field>
func AddHealthFlags ¶ added in v0.2.0
AddHealthFlags adds health check configuration flags following standard naming Format: --health-<field> maps to HYPERFLEET_HEALTH_<FIELD> and health.<field>
func AddLoggingFlags ¶ added in v0.2.0
AddLoggingFlags adds logging configuration flags following standard naming Format: --log-<field> maps to HYPERFLEET_LOGGING_<FIELD> and logging.<field>
func AddMetricsFlags ¶ added in v0.2.0
AddMetricsFlags adds metrics configuration flags following standard naming Format: --metrics-<field> maps to HYPERFLEET_METRICS_<FIELD> and metrics.<field>
func AddOCMFlags ¶ added in v0.2.0
AddOCMFlags adds OCM configuration flags following standard naming Format: --ocm-<field> maps to HYPERFLEET_OCM_<FIELD> and ocm.<field>
func AddServerFlags ¶ added in v0.2.0
AddServerFlags adds server configuration flags following standard naming Format: --server-<field> maps to HYPERFLEET_SERVER_<FIELD> and server.<field>
func DumpConfig ¶ added in v0.2.0
func DumpConfig(config *ApplicationConfig) string
DumpConfig returns a human-readable string representation of configuration with sensitive fields redacted. Useful for debugging.
Types ¶
type ACLConfig ¶ added in v0.2.0
type ACLConfig struct {
File string `mapstructure:"file" json:"file" validate:"omitempty,filepath"`
}
ACLConfig holds access control list configuration
type AdapterRequirementsConfig ¶
type AdapterRequirementsConfig struct {
Required RequiredAdapters `mapstructure:"required" json:"required" validate:"required"`
}
AdapterRequirementsConfig configures which adapters must be ready for resources Follows HyperFleet Configuration Standard
func NewAdapterRequirementsConfig ¶
func NewAdapterRequirementsConfig() *AdapterRequirementsConfig
NewAdapterRequirementsConfig returns default AdapterRequirementsConfig values Note: This config typically REQUIRES values from environment or config file Empty defaults are provided but should be overridden
func (*AdapterRequirementsConfig) RequiredClusterAdapters ¶
func (a *AdapterRequirementsConfig) RequiredClusterAdapters() []string
RequiredClusterAdapters returns cluster adapters
func (*AdapterRequirementsConfig) RequiredNodePoolAdapters ¶
func (a *AdapterRequirementsConfig) RequiredNodePoolAdapters() []string
RequiredNodePoolAdapters returns nodepool adapters
type ApplicationConfig ¶
type ApplicationConfig struct {
Server *ServerConfig `mapstructure:"server" json:"server" validate:"required"`
Metrics *MetricsConfig `mapstructure:"metrics" json:"metrics" validate:"required"`
Health *HealthConfig `mapstructure:"health" json:"health" validate:"required"`
Database *DatabaseConfig `mapstructure:"database" json:"database" validate:"required"`
OCM *OCMConfig `mapstructure:"ocm" json:"ocm" validate:"required"`
Logging *LoggingConfig `mapstructure:"logging" json:"logging" validate:"required"`
Adapters *AdapterRequirementsConfig `mapstructure:"adapters" json:"adapters" validate:"required"`
}
ApplicationConfig holds all application configuration Follows HyperFleet Configuration Standard with validation and structured marshaling
func NewApplicationConfig ¶
func NewApplicationConfig() *ApplicationConfig
NewApplicationConfig returns default ApplicationConfig with all sub-configs initialized These defaults can be overridden by config file, env vars, or CLI flags
type AuthzConfig ¶ added in v0.2.0
type AuthzConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled"`
}
AuthzConfig holds authorization configuration
type ConfigLoader ¶ added in v0.2.0
type ConfigLoader struct {
// contains filtered or unexported fields
}
ConfigLoader handles loading and validating application configuration following the HyperFleet Configuration Standard.
func NewConfigLoader ¶ added in v0.2.0
func NewConfigLoader() *ConfigLoader
NewConfigLoader creates a new configuration loader
func (*ConfigLoader) Load ¶ added in v0.2.0
func (l *ConfigLoader) Load(ctx context.Context, cmd *cobra.Command) (*ApplicationConfig, error)
Load loads configuration from all sources according to priority: 1. Command-line flags (highest priority) 2. Environment variables 3. Configuration files 4. Defaults (lowest priority)
Returns validated ApplicationConfig or error if validation fails.
type DatabaseConfig ¶
type DatabaseConfig struct {
SSL SSLConfig `mapstructure:"ssl" json:"ssl" validate:"required"`
Dialect string `mapstructure:"dialect" json:"dialect" validate:"required,oneof=postgres"`
Host string `mapstructure:"host" json:"host" validate:"required,hostname|ip"`
Name string `mapstructure:"name" json:"name" validate:"required"`
Username string `mapstructure:"username" json:"-"`
Password string `mapstructure:"password" json:"-"`
Pool PoolConfig `mapstructure:"pool" json:"pool" validate:"required"`
Port int `mapstructure:"port" json:"port" validate:"required,min=1,max=65535"`
Debug bool `mapstructure:"debug" json:"debug"`
}
DatabaseConfig holds database connection configuration Follows HyperFleet Configuration Standard
func NewDatabaseConfig ¶
func NewDatabaseConfig() *DatabaseConfig
NewDatabaseConfig 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
func (*DatabaseConfig) ConnectionString ¶
func (c *DatabaseConfig) ConnectionString(ssl bool) string
ConnectionString generates database connection string ssl parameter controls whether to include SSL settings
func (*DatabaseConfig) ConnectionStringWithName ¶
func (c *DatabaseConfig) ConnectionStringWithName(name string, ssl bool) string
ConnectionStringWithName generates database connection string with custom database name This is useful for test databases. ssl parameter controls whether to include SSL settings.
func (*DatabaseConfig) LogSafeConnectionString ¶
func (c *DatabaseConfig) LogSafeConnectionString(ssl bool) string
LogSafeConnectionString returns connection string with username and password redacted
func (*DatabaseConfig) LogSafeConnectionStringWithName ¶
func (c *DatabaseConfig) LogSafeConnectionStringWithName(name string, ssl bool) string
LogSafeConnectionStringWithName returns connection string with custom name and username/password redacted This is useful for test databases.
func (DatabaseConfig) MarshalJSON ¶ added in v0.2.0
func (c DatabaseConfig) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling to redact sensitive fields
func (*DatabaseConfig) SetLogLevel ¶ added in v0.2.0
func (c *DatabaseConfig) SetLogLevel(globalLogLevel string) logger.LogLevel
SetLogLevel determines the GORM logger level based on database.debug flag and global logging level. Priority: database.debug > global logging level > default
Behavior:
- database.debug=true → logger.Info (show all SQL queries)
- logging.level=debug → logger.Info (show all SQL queries)
- logging.level=error → logger.Silent (suppress all SQL logs)
- default → logger.Warn (show only slow queries and errors)
type HealthConfig ¶
type HealthConfig struct {
Host string `mapstructure:"host" json:"host" validate:"required"`
TLS TLSConfig `mapstructure:"tls" json:"tls" validate:"required"`
Port int `mapstructure:"port" json:"port" validate:"required,min=1,max=65535"`
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout" json:"shutdown_timeout" validate:"required"`
DBPingTimeout time.Duration `mapstructure:"db_ping_timeout" json:"db_ping_timeout"`
}
HealthConfig holds health check server configuration Follows HyperFleet Configuration Standard
func NewHealthConfig ¶
func NewHealthConfig() *HealthConfig
NewHealthConfig returns default HealthConfig values These defaults can be overridden by config file, env vars, or CLI flags
func (*HealthConfig) BindAddress ¶
func (h *HealthConfig) BindAddress() string
BindAddress returns bind address in host:port format Uses net.JoinHostPort to correctly handle IPv6 addresses
func (*HealthConfig) Validate ¶ added in v0.2.0
func (h *HealthConfig) Validate() error
Validate validates health config durations
type JWKConfig ¶ added in v0.2.0
type JWKConfig struct {
CertFile string `mapstructure:"cert_file" json:"cert_file" validate:"omitempty,filepath"`
CertURL string `mapstructure:"cert_url" json:"cert_url" validate:"omitempty,url"`
}
JWKConfig holds JWK certificate configuration
type JWTConfig ¶ added in v0.2.0
type JWTConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled"`
}
JWTConfig holds JWT authentication configuration
type LoggingConfig ¶
type LoggingConfig struct {
Level string `mapstructure:"level" json:"level" validate:"required,oneof=debug info warn error"`
Format string `mapstructure:"format" json:"format" validate:"required,oneof=json text"`
Output string `mapstructure:"output" json:"output" validate:"required,oneof=stdout stderr"`
Masking MaskingConfig `mapstructure:"masking" json:"masking" validate:"required"`
OTel OTelConfig `mapstructure:"otel" json:"otel" validate:"required"`
}
LoggingConfig holds logging configuration Follows HyperFleet Configuration Standard
func NewLoggingConfig ¶
func NewLoggingConfig() *LoggingConfig
NewLoggingConfig returns default LoggingConfig values These defaults can be overridden by config file, env vars, or CLI flags
func (*LoggingConfig) GetSensitiveFieldsList ¶
func (l *LoggingConfig) GetSensitiveFieldsList() []string
GetSensitiveFieldsList returns list of sensitive fields This is used by logger for masking
func (*LoggingConfig) GetSensitiveFieldsString ¶ added in v0.2.0
func (l *LoggingConfig) GetSensitiveFieldsString() string
GetSensitiveFieldsString returns fields as comma-separated string
func (*LoggingConfig) GetSensitiveHeadersList ¶
func (l *LoggingConfig) GetSensitiveHeadersList() []string
GetSensitiveHeadersList returns list of sensitive headers This is used by logger for masking
func (*LoggingConfig) GetSensitiveHeadersString ¶ added in v0.2.0
func (l *LoggingConfig) GetSensitiveHeadersString() string
GetSensitiveHeadersString returns headers as comma-separated string
type MaskingConfig ¶
type MaskingConfig struct {
Headers []string `mapstructure:"headers" json:"headers"`
Fields []string `mapstructure:"fields" json:"fields"`
Enabled bool `mapstructure:"enabled" json:"enabled"`
}
MaskingConfig holds log masking configuration
type MetricsConfig ¶
type MetricsConfig struct {
Host string `mapstructure:"host" json:"host" validate:"required"`
TLS TLSConfig `mapstructure:"tls" json:"tls" validate:"required"`
Port int `mapstructure:"port" json:"port" validate:"required,min=1,max=65535"`
LabelMetricsInclusionDuration time.Duration `mapstructure:"label_metrics_inclusion_duration" json:"label_metrics_inclusion_duration" validate:"required"` //nolint:lll
}
MetricsConfig holds Prometheus metrics server configuration Follows HyperFleet Configuration Standard
func NewMetricsConfig ¶
func NewMetricsConfig() *MetricsConfig
NewMetricsConfig returns default MetricsConfig values These defaults can be overridden by config file, env vars, or CLI flags
func (*MetricsConfig) BindAddress ¶
func (m *MetricsConfig) BindAddress() string
BindAddress returns bind address in host:port format Uses net.JoinHostPort to correctly handle IPv6 addresses
func (*MetricsConfig) GetLabelMetricsInclusionDuration ¶ added in v0.2.0
func (m *MetricsConfig) GetLabelMetricsInclusionDuration() time.Duration
GetLabelMetricsInclusionDuration returns label metrics inclusion duration
type MockConfig ¶ added in v0.2.0
type MockConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled"`
}
MockConfig holds mock configuration for testing
type OCMConfig ¶
type OCMConfig struct {
BaseURL string `mapstructure:"base_url" json:"base_url" validate:"required,url"`
ClientID string `mapstructure:"client_id" json:"-"` // Excluded from JSON marshaling (sensitive)
ClientSecret string `mapstructure:"client_secret" json:"-"` // Excluded from JSON marshaling (sensitive)
SelfToken string `mapstructure:"self_token" json:"-"` // Excluded from JSON marshaling (sensitive)
TokenURL string `mapstructure:"token_url" json:"token_url" validate:"required,url"`
Debug bool `mapstructure:"debug" json:"debug"`
Mock MockConfig `mapstructure:"mock" json:"mock" validate:"required"`
}
OCMConfig holds OpenShift Cluster Manager configuration Follows HyperFleet Configuration Standard
func NewOCMConfig ¶
func NewOCMConfig() *OCMConfig
NewOCMConfig returns default OCMConfig values These defaults can be overridden by config file, env vars, or CLI flags
func (OCMConfig) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements custom JSON marshaling to redact sensitive fields
type OTelConfig ¶
type OTelConfig struct {
Enabled bool `mapstructure:"enabled" json:"enabled"`
SamplingRate float64 `mapstructure:"sampling_rate" json:"sampling_rate" validate:"gte=0,lte=1"`
}
OTelConfig holds OpenTelemetry configuration
type PoolConfig ¶ added in v0.2.0
type PoolConfig struct {
MaxConnections int `mapstructure:"max_connections" json:"max_connections" validate:"required,min=1,max=200"` //nolint:lll // gofmt alignment
MaxIdleConnections int `mapstructure:"max_idle_connections" json:"max_idle_connections" validate:"min=0"`
ConnMaxLifetime time.Duration `mapstructure:"conn_max_lifetime" json:"conn_max_lifetime"`
ConnMaxIdleTime time.Duration `mapstructure:"conn_max_idle_time" json:"conn_max_idle_time"`
RequestTimeout time.Duration `mapstructure:"request_timeout" json:"request_timeout"`
ConnRetryAttempts int `mapstructure:"conn_retry_attempts" json:"conn_retry_attempts" validate:"min=1"`
ConnRetryInterval time.Duration `mapstructure:"conn_retry_interval" json:"conn_retry_interval"`
// HYPERFLEET-618: prevents indefinite blocking during migrations
AdvisoryLockTimeout time.Duration `mapstructure:"advisory_lock_timeout" json:"advisory_lock_timeout"`
}
PoolConfig holds connection pool configuration Includes fields from HYPERFLEET-694 for connection lifecycle management
type RequiredAdapters ¶ added in v0.2.0
type RequiredAdapters struct {
Cluster []string `mapstructure:"cluster" json:"cluster" validate:"dive,required"`
Nodepool []string `mapstructure:"nodepool" json:"nodepool" validate:"dive,required"`
}
RequiredAdapters holds required adapters for different resource types
type SSLConfig ¶ added in v0.2.0
type SSLConfig struct {
Mode string `mapstructure:"mode" json:"mode" validate:"required,oneof=disable require verify-ca verify-full"`
RootCertFile string `mapstructure:"root_cert_file" json:"root_cert_file"`
}
SSLConfig holds SSL/TLS configuration
type ServerConfig ¶
type ServerConfig struct {
JWK JWKConfig `mapstructure:"jwk" json:"jwk" validate:"required"`
Hostname string `mapstructure:"hostname" json:"hostname" validate:"omitempty,hostname|ip"`
Host string `mapstructure:"host" json:"host" validate:"required,hostname|ip"`
OpenAPISchemaPath string `mapstructure:"openapi_schema_path" json:"openapi_schema_path"`
ACL ACLConfig `mapstructure:"acl" json:"acl" validate:"required"`
TLS TLSConfig `mapstructure:"tls" json:"tls" validate:"required"`
Timeouts TimeoutsConfig `mapstructure:"timeouts" json:"timeouts" validate:"required"`
Port int `mapstructure:"port" json:"port" validate:"required,min=1,max=65535"`
JWT JWTConfig `mapstructure:"jwt" json:"jwt" validate:"required"`
Authz AuthzConfig `mapstructure:"authz" json:"authz" validate:"required"`
}
ServerConfig holds HTTP/HTTPS server configuration Follows HyperFleet Configuration Standard
func NewServerConfig ¶
func NewServerConfig() *ServerConfig
NewServerConfig returns default ServerConfig values These defaults can be overridden by config file, env vars, or CLI flags
func (*ServerConfig) BindAddress ¶
func (s *ServerConfig) BindAddress() string
BindAddress returns bind address in host:port format Uses net.JoinHostPort to correctly handle IPv6 addresses
type TLSConfig ¶ added in v0.2.0
type TLSConfig struct {
CertFile string `mapstructure:"cert_file" json:"cert_file" validate:"omitempty,filepath"`
KeyFile string `mapstructure:"key_file" json:"key_file" validate:"omitempty,filepath"`
Enabled bool `mapstructure:"enabled" json:"enabled"`
}
TLSConfig holds TLS configuration
type TimeoutsConfig ¶ added in v0.2.0
type TimeoutsConfig struct {
Read time.Duration `mapstructure:"read" json:"read" validate:"required"`
Write time.Duration `mapstructure:"write" json:"write" validate:"required"`
}
TimeoutsConfig holds HTTP timeout configuration
func (*TimeoutsConfig) Validate ¶ added in v0.2.0
func (c *TimeoutsConfig) Validate() error
Validate validates timeout durations