Documentation
¶
Index ¶
- func GetProjectRootDir() string
- func ReadFile(file string) (string, error)
- type ApplicationConfig
- type DatabaseConfig
- func (c *DatabaseConfig) AddFlags(fs *pflag.FlagSet)
- func (c *DatabaseConfig) BindEnv(fs *pflag.FlagSet)
- func (c *DatabaseConfig) ConnectionString(withSSL bool) string
- func (c *DatabaseConfig) ConnectionStringWithName(name string, withSSL bool) string
- func (c *DatabaseConfig) GetGormLogLevel(logLevel string) logger.LogLevel
- func (c *DatabaseConfig) LogSafeConnectionString(withSSL bool) string
- func (c *DatabaseConfig) LogSafeConnectionStringWithName(name string, withSSL bool) string
- func (c *DatabaseConfig) ReadFiles() error
- type HealthConfig
- type LoggingConfig
- type MaskingConfig
- type MetricsConfig
- type OCMConfig
- type OTelConfig
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetProjectRootDir ¶
func GetProjectRootDir() string
GetProjectRootDir Return project root path based on the relative path of this file
Types ¶
type ApplicationConfig ¶
type ApplicationConfig struct {
Server *ServerConfig `json:"server"`
Metrics *MetricsConfig `json:"metrics"`
Health *HealthConfig `json:"health"`
Database *DatabaseConfig `json:"database"`
OCM *OCMConfig `json:"ocm"`
Logging *LoggingConfig `json:"logging"`
}
func NewApplicationConfig ¶
func NewApplicationConfig() *ApplicationConfig
func (*ApplicationConfig) AddFlags ¶
func (c *ApplicationConfig) AddFlags(flagset *pflag.FlagSet)
func (*ApplicationConfig) ReadFiles ¶
func (c *ApplicationConfig) ReadFiles() []string
type DatabaseConfig ¶
type DatabaseConfig struct {
Dialect string `json:"dialect"`
SSLMode string `json:"sslmode"`
Debug bool `json:"debug"`
MaxOpenConnections int `json:"max_connections"`
Host string `json:"host"`
Port int `json:"port"`
Name string `json:"name"`
Username string `json:"username"`
Password string `json:"password"`
HostFile string `json:"host_file"`
PortFile string `json:"port_file"`
NameFile string `json:"name_file"`
UsernameFile string `json:"username_file"`
PasswordFile string `json:"password_file"`
RootCertFile string `json:"certificate_file"`
}
func NewDatabaseConfig ¶
func NewDatabaseConfig() *DatabaseConfig
func (*DatabaseConfig) AddFlags ¶
func (c *DatabaseConfig) AddFlags(fs *pflag.FlagSet)
func (*DatabaseConfig) BindEnv ¶
func (c *DatabaseConfig) BindEnv(fs *pflag.FlagSet)
BindEnv reads configuration from environment variables Priority: flags > env vars > defaults
func (*DatabaseConfig) ConnectionString ¶
func (c *DatabaseConfig) ConnectionString(withSSL bool) string
func (*DatabaseConfig) ConnectionStringWithName ¶
func (c *DatabaseConfig) ConnectionStringWithName(name string, withSSL bool) string
func (*DatabaseConfig) GetGormLogLevel ¶
func (c *DatabaseConfig) GetGormLogLevel(logLevel string) logger.LogLevel
GetGormLogLevel returns the appropriate GORM log level based on DB_DEBUG and LOG_LEVEL. DB_DEBUG=true always returns Info level, otherwise follows LOG_LEVEL mapping.
func (*DatabaseConfig) LogSafeConnectionString ¶
func (c *DatabaseConfig) LogSafeConnectionString(withSSL bool) string
func (*DatabaseConfig) LogSafeConnectionStringWithName ¶
func (c *DatabaseConfig) LogSafeConnectionStringWithName(name string, withSSL bool) string
func (*DatabaseConfig) ReadFiles ¶
func (c *DatabaseConfig) ReadFiles() error
type HealthConfig ¶
type HealthConfig struct {
BindAddress string `json:"bind_address"`
EnableHTTPS bool `json:"enable_https"`
ShutdownTimeout time.Duration `json:"shutdown_timeout"`
}
func NewHealthConfig ¶
func NewHealthConfig() *HealthConfig
func (*HealthConfig) AddFlags ¶
func (s *HealthConfig) AddFlags(fs *pflag.FlagSet)
func (*HealthConfig) ReadFiles ¶
func (s *HealthConfig) ReadFiles() error
type LoggingConfig ¶
type LoggingConfig struct {
Level string `json:"log_level"`
Format string `json:"log_format"`
Output string `json:"log_output"`
OTel OTelConfig `json:"otel"`
Masking MaskingConfig `json:"masking"`
}
LoggingConfig holds logging configuration
func NewLoggingConfig ¶
func NewLoggingConfig() *LoggingConfig
NewLoggingConfig creates a new LoggingConfig with default values
func (*LoggingConfig) AddFlags ¶
func (l *LoggingConfig) AddFlags(fs *pflag.FlagSet)
AddFlags adds CLI flags for core logging configuration
func (*LoggingConfig) BindEnv ¶
func (l *LoggingConfig) BindEnv(fs *pflag.FlagSet)
BindEnv reads configuration from environment variables Priority: flags > env vars > defaults If fs is nil, all env vars are applied (backward compatibility)
func (*LoggingConfig) GetSensitiveFieldsList ¶
func (l *LoggingConfig) GetSensitiveFieldsList() []string
GetSensitiveFieldsList parses comma-separated sensitive fields
func (*LoggingConfig) GetSensitiveHeadersList ¶
func (l *LoggingConfig) GetSensitiveHeadersList() []string
GetSensitiveHeadersList parses comma-separated sensitive headers
func (*LoggingConfig) ReadFiles ¶
func (l *LoggingConfig) ReadFiles() error
ReadFiles satisfies the config interface
type MaskingConfig ¶
type MaskingConfig struct {
Enabled bool `json:"enabled"`
SensitiveHeaders string `json:"sensitive_headers"`
SensitiveFields string `json:"sensitive_fields"`
}
MaskingConfig holds data masking configuration
type MetricsConfig ¶
type MetricsConfig struct {
BindAddress string `json:"bind_address"`
EnableHTTPS bool `json:"enable_https"`
LabelMetricsInclusionDuration time.Duration `json:"label_metrics_inclusion_duration"`
}
func NewMetricsConfig ¶
func NewMetricsConfig() *MetricsConfig
func (*MetricsConfig) AddFlags ¶
func (s *MetricsConfig) AddFlags(fs *pflag.FlagSet)
func (*MetricsConfig) ReadFiles ¶
func (s *MetricsConfig) ReadFiles() error
type OCMConfig ¶
type OCMConfig struct {
BaseURL string `json:"base_url"`
ClientID string `json:"client-id"`
ClientIDFile string `json:"client-id_file"`
ClientSecret string `json:"client-secret"`
ClientSecretFile string `json:"client-secret_file"`
SelfToken string `json:"self_token"`
SelfTokenFile string `json:"self_token_file"`
TokenURL string `json:"token_url"`
Debug bool `json:"debug"`
EnableMock bool `json:"enable_mock"`
}
func NewOCMConfig ¶
func NewOCMConfig() *OCMConfig
type OTelConfig ¶
type OTelConfig struct {
Enabled bool `json:"enabled"`
SamplingRate float64 `json:"sampling_rate"`
}
OTelConfig holds OpenTelemetry configuration
type ServerConfig ¶
type ServerConfig struct {
Hostname string `json:"hostname"`
BindAddress string `json:"bind_address"`
ReadTimeout time.Duration `json:"read_timeout"`
WriteTimeout time.Duration `json:"write_timeout"`
HTTPSCertFile string `json:"https_cert_file"`
HTTPSKeyFile string `json:"https_key_file"`
EnableHTTPS bool `json:"enable_https"`
EnableJWT bool `json:"enable_jwt"`
EnableAuthz bool `json:"enable_authz"`
JwkCertFile string `json:"jwk_cert_file"`
JwkCertURL string `json:"jwk_cert_url"`
ACLFile string `json:"acl_file"`
}
func NewServerConfig ¶
func NewServerConfig() *ServerConfig
func (*ServerConfig) AddFlags ¶
func (s *ServerConfig) AddFlags(fs *pflag.FlagSet)
func (*ServerConfig) ReadFiles ¶
func (s *ServerConfig) ReadFiles() error