config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProjectRootDir

func GetProjectRootDir() string

Return project root path based on the relative path of this file

func ReadFile

func ReadFile(file string) (string, error)

Types

type ApplicationConfig

type ApplicationConfig struct {
	Server      *ServerConfig      `json:"server"`
	Metrics     *MetricsConfig     `json:"metrics"`
	HealthCheck *HealthCheckConfig `json:"health_check"`
	Database    *DatabaseConfig    `json:"database"`
	OCM         *OCMConfig         `json:"ocm"`
	Sentry      *SentryConfig      `json:"sentry"`
}

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) ConnectionString

func (c *DatabaseConfig) ConnectionString(withSSL bool) string

func (*DatabaseConfig) ConnectionStringWithName

func (c *DatabaseConfig) ConnectionStringWithName(name string, withSSL bool) string

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 HealthCheckConfig

type HealthCheckConfig struct {
	BindAddress string `json:"bind_address"`
	EnableHTTPS bool   `json:"enable_https"`
}

func NewHealthCheckConfig

func NewHealthCheckConfig() *HealthCheckConfig

func (*HealthCheckConfig) AddFlags

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

func (*HealthCheckConfig) ReadFiles

func (c *HealthCheckConfig) ReadFiles() error

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 SentryConfig

type SentryConfig struct {
	Enabled bool          `json:"enabled"`
	Key     string        `json:"key"`
	URL     string        `json:"url"`
	Project string        `json:"project"`
	Debug   bool          `json:"debug"`
	Timeout time.Duration `json:"timeout"`

	KeyFile string `json:"key_file"`
}

func NewSentryConfig

func NewSentryConfig() *SentryConfig

func (*SentryConfig) AddFlags

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

func (*SentryConfig) ReadFiles

func (c *SentryConfig) ReadFiles() error

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