config

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

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

func ReadFile

func ReadFile(file string) (string, error)

Types

type AdapterRequirementsConfig

type AdapterRequirementsConfig struct {
	RequiredClusterAdapters  []string
	RequiredNodePoolAdapters []string
}

AdapterRequirementsConfig configures which adapters must be ready for resources

func NewAdapterRequirementsConfig

func NewAdapterRequirementsConfig() (*AdapterRequirementsConfig, error)

NewAdapterRequirementsConfig creates config from environment variables. Returns an error if required environment variables are not set. Required env vars: HYPERFLEET_CLUSTER_ADAPTERS, HYPERFLEET_NODEPOOL_ADAPTERS Format: JSON array, e.g., '["validation","dns","pullsecret","hypershift"]'

func (*AdapterRequirementsConfig) LoadFromEnv

func (c *AdapterRequirementsConfig) LoadFromEnv() error

LoadFromEnv loads adapter lists from HYPERFLEET_CLUSTER_ADAPTERS and HYPERFLEET_NODEPOOL_ADAPTERS (JSON array format: '["adapter1","adapter2"]') Returns an error if the environment variables are not set or have invalid JSON.

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"`
	Adapters *AdapterRequirementsConfig `json:"adapters"`
}

func NewApplicationConfig

func NewApplicationConfig() *ApplicationConfig

func (*ApplicationConfig) AddFlags

func (c *ApplicationConfig) AddFlags(flagset *pflag.FlagSet)

func (*ApplicationConfig) LoadAdapters

func (c *ApplicationConfig) LoadAdapters() error

LoadAdapters initializes the adapter configuration from environment variables. This should be called once during application startup.

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

func (*OCMConfig) AddFlags

func (c *OCMConfig) AddFlags(fs *pflag.FlagSet)

func (*OCMConfig) ReadFiles

func (c *OCMConfig) ReadFiles() error

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

Jump to

Keyboard shortcuts

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