config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigType     = "yaml"
	DefaultConfigDir      = "./appconfig"
	DefaultConfigFileName = "default"
	WorkDirEnv            = "WORKDIR"
	EnvPrefix             = "env|"
	FilePrefix            = "file|"
)

Default options for configuration loading.

Variables

This section is empty.

Functions

func SubstituteConfigValues

func SubstituteConfigValues(v reflect.Value)

SubstituteConfigValues recursively walks through the config struct and replaces string values of the form 'env|VAR' or 'file|/path' with the corresponding value.

Types

type APIServerConfig added in v0.1.0

type APIServerConfig struct {
	Address string     `yaml:"address"`
	Auth    AuthConfig `yaml:"auth"`
	CORS    CORSConfig `yaml:"cors"`
}

type App

type App struct {
	Name        string `yaml:"name"`
	Version     string `yaml:"version"`
	Environment string `yaml:"environment"`
	Debug       bool   `yaml:"debug"`
}

App represents the application configuration

type AppConfig

type AppConfig struct {
	App        App                       `yaml:"app"`
	LDAP       ldap.LDAP                 `yaml:"ldap"`
	Cache      cache.Config              `yaml:"cache"`
	Backends   []Backend                 `yaml:"backends"`
	Pattern    map[string][]PatternEntry `yaml:"pattern"`
	HttpClient struct {
		ConnectionPoolConfig    httpclient.ConnectionPoolConfig    `yaml:"connectionPoolConfig"`
		HystrixResiliencyConfig httpclient.HystrixResiliencyConfig `yaml:"hystrixResiliencyConfig"`
	} `yaml:"httpClient"`
	APIServer  APIServerConfig               `yaml:"apiServer"`
	BackendMap map[string]map[string]Backend `yaml:"-"`
}

Config represents the top-level configuration structure

func GetConfig

func GetConfig() (*AppConfig, error)

func LoadConfig

func LoadConfig(env string) (*AppConfig, error)

type AuthConfig added in v0.1.0

type AuthConfig struct {
	Enabled    bool        `yaml:"enabled"`
	BasicUsers []BasicUser `yaml:"basic_users" mapstructure:"basic_users"`
}

type Backend

type Backend struct {
	Name       string                 `yaml:"name"`
	Type       string                 `yaml:"type"`
	Enabled    bool                   `yaml:"enabled"`
	DependsOn  Dependant              `yaml:"depends_on,omitempty" mapstructure:"depends_on,omitempty"`
	Connection map[string]interface{} `yaml:"connection"`
}

Backend represents a backend service configuration

func (*Backend) GetStringConnection

func (b *Backend) GetStringConnection(name string, defaultValue string) string

type BasicUser added in v0.1.0

type BasicUser struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type CORSConfig added in v0.1.0

type CORSConfig struct {
	AllowedOrigins []string `yaml:"allowed_origins"`
}

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is a wrapper over a underlying config loader implementation.

func NewConfig

func NewConfig(opts Options) *Config

NewConfig returns new config struct.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig returns new config struct with default options.

func (*Config) Load

func (c *Config) Load(env string, config interface{}) error

Load reads environment specific configurations and along with the defaults unmarshalls into config.

type Dependant added in v0.2.0

type Dependant struct {
	Name string `yaml:"name"`
	Type string `yaml:"type"`
}

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options is config options.

func NewDefaultOptions

func NewDefaultOptions() Options

func NewOptions

func NewOptions(configType string, configPath string, defaultConfigFileName string) Options

NewOptions returns new Options struct.

type PatternEntry

type PatternEntry struct {
	Input  string `yaml:"input"`
	Output string `yaml:"output"`
}

PatternEntry represents the input and output pattern of group names

Jump to

Keyboard shortcuts

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