configx

package
v1.0.4-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfigForEnv

func LoadConfigForEnv(config Config) error

func LoadConfigFromPathForEnv

func LoadConfigFromPathForEnv(searchPath string, config Config) error

LoadConfigFromPathForEnv - search the property-<ENV> properties in the given search path (for ex. "./config" )

func ReadConfiguration

func ReadConfiguration(configFilePath string, config Config) error

ReadConfiguration reads the configuration from the file and environment variables

Types

type BaseConfig

type BaseConfig struct {
	Name        string         `mapstructure:"name"`
	Environment string         `mapstructure:"environment"`
	Version     string         `mapstructure:"version"`
	Logging     *LoggingConfig `mapstructure:"logging"`
	Server      *ServerConfig  `mapstructure:"server"`
	Gcp         *GcpConfig     `mapstructure:"gcp"`
	Image       *Image         `mapstructure:"image"`
}

BaseConfig - app config struct. This struct represents the base configuration for the application and is expected to be in the following YAML format:

name: "TestApp" environment: "development" version: "1.0" logging:

level: "debug"

gcp:

projectNumber: 620222630834
project: test-project
location: europe-west4

image:

repository: europe-west4-docker.pkg.dev/ingka-opoa-nexus-dev/nexus-docker-repo
name: test-app
pullPolicy: Always
tag: latest

server:

port: "8080"
concurrency: 10
disableStartupMsg: false
bodyLimit: 1048576

func (BaseConfig) GetEnvironment

func (cfg BaseConfig) GetEnvironment() string

func (BaseConfig) GetGcpConfig

func (cfg BaseConfig) GetGcpConfig() *GcpConfig

func (BaseConfig) GetLoggingConfig

func (cfg BaseConfig) GetLoggingConfig() *LoggingConfig

func (BaseConfig) GetServerConfig

func (cfg BaseConfig) GetServerConfig() *ServerConfig

func (BaseConfig) GetServiceName

func (cfg BaseConfig) GetServiceName() string

func (BaseConfig) GetVersion

func (cfg BaseConfig) GetVersion() string

func (BaseConfig) IsLocalEnvironment

func (cfg BaseConfig) IsLocalEnvironment() bool

type Config

type Config interface {
	GetServiceName() string
	GetVersion() string
	GetEnvironment() string
	GetServerConfig() *ServerConfig
	GetGcpConfig() *GcpConfig
	GetLoggingConfig() *LoggingConfig
	IsLocalEnvironment() bool
}

Config - config interface.

type GcpConfig

type GcpConfig struct {
	ProjectId     string `mapstructure:"project"`
	ProjectNumber string `mapstructure:"projectNumber"`
	Location      string `mapstructure:"location"`
}

type Image

type Image struct {
	Repository string `mapstructure:"repository"`
	Name       string `mapstructure:"name"`
	PullPolicy string `mapstructure:"pullPolicy"`
	Tag        string `mapstructure:"tag"`
}

Image - Image properties

type LoggingConfig

type LoggingConfig struct {
	Level string `mapstructure:"level"`
}

type ServerConfig

type ServerConfig struct {
	Port                  string `mapstructure:"port"`
	Concurrency           int    `mapstructure:"concurrency"`
	DisableStartupMessage bool   `mapstructure:"disableStartupMsg"`
	BodyLimit             int    `mapstructure:"bodyLimit"`
}

func (ServerConfig) GetBodyLimit added in v1.0.3

func (srv ServerConfig) GetBodyLimit() int

Jump to

Keyboard shortcuts

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