configuration

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CurrentDir    = "."
	ConfigDir     = "./config"
	CmdDir        = "../../config/"
	ConfigName    = "config"
	FileExtension = "yaml"
)

Default values and dirs

View Source
const (
	TracingFlag = "tracing"
	MetricsFlag = "metrics"
)
View Source
const (
	EtcdAddress = "etcd.address"
	EtcdPrefix  = "etcd.prefix"

	// Database
	DatabaseType        = "database.type"
	DatabaseAddress     = "database.host"
	DatabasePort        = "database.port"
	DatabaseUsername    = "database.username"
	DatabasePassword    = "database.password"
	DatabaseName        = "database.database"
	DatabaseReplicaSet  = "database.replicaSet"
	DatabaseTLSEnabled  = "database.tls.enabled"
	DatabaseTLSKeyPath  = "database.tls.keyPath"
	DatabaseTLSCertPath = "database.tls.certPath"

	// HTTP server
	ServerAddress     = "http.address"
	ServerPathPrefix  = "http.pathPrefix"
	ServerTLSEnabled  = "http.tls.enabled"
	ServerTLSKeyPath  = "http.tls.keyPath"
	ServerTLSCertPath = "http.tls.certPath"

	// Metrics
	MetricsServerAddress = "observability.metrics.address"
	MetricsEnable        = "observability.metrics.enable"
	MetricsEndpoint      = "observability.metrics.endpoint"

	// Tracing
	TracingEnable      = "observability.tracing.enable"
	TracingAddress     = "observability.tracing.address"
	TracingAuth        = "observability.tracing.auth"
	TracingTLSEnabled  = "observability.tracing.tls.enabled"
	TracingTLSKeyPath  = "observability.tracing.tls.keyPath"
	TracingTLSCertPath = "observability.tracing.tls.certPath"
)

Variables

This section is empty.

Functions

func GetConfiguration

func GetConfiguration(viper *viper.Viper, configStruct interface{})

GetConfiguration loads the configuration from Viper and validates it.

func InitConfig

func InitConfig(configurationFilePath string, additionalDirs ...string)

InitConfig initializes the configuration for the service, either from file or from ETCD (if ETCD was set).

func SetDefaults

func SetDefaults(serviceName string)

SetDefaults sets the default values for the app configuration.

func SetupEnv

func SetupEnv(serviceName string)

SetupEnv sets up the environment variables for the service.

Types

type CORS

type CORS struct {
	// IsEnabled is the flag to enable/disable CORS
	IsEnabled bool `yaml:"enabled" json:"enabled,omitempty" mapstructure:"enabled"`

	// AllowedOrigins is the list of allowed origins
	AllowedOrigins []string `yaml:"allowedOrigins" json:"allowedOrigins,omitempty" mapstructure:"allowedOrigins"`
}

Cross Origin Resource Sharing configuration

type Database

type Database struct {
	Type       string `json:"type" yaml:"type" mapstructure:"type" required:""`
	URI        string `json:"uri,omitempty" yaml:"uri" mapstructure:"uri"`
	Host       string `json:"host,omitempty" yaml:"host" mapstructure:"host"`
	Username   string `json:"username,omitempty" yaml:"username" mapstructure:"username"`
	Password   string `json:"password,omitempty" yaml:"password" mapstructure:"password"`
	Port       int    `json:"port,omitempty" yaml:"port" mapstructure:"port"`
	Database   string `json:"database,omitempty" yaml:"database" mapstructure:"database"`
	ReplicaSet string `json:"replicaSet,omitempty" yaml:"replicaSet" mapstructure:"replicaSet"`
	TLS        TLS    `json:"tls" yaml:"tls" mapstructure:"tls"`
}

Primary Database configuration

type InfluxDB

type InfluxDB struct {
	URL          string `yaml:"url" json:"url" mapstructure:"url"`
	Organization string `yaml:"organization" json:"organization" mapstructure:"organization"`
	Bucket       string `yaml:"bucket" json:"bucket" mapstructure:"bucket"`
	AccessToken  string `yaml:"accessToken" json:"accessToken" mapstructure:"accessToken"`
	TLS          TLS    `mapstructure:"tls" yaml:"tls" json:"tls"`
}

InfluxDB database configuration with TLS

type Redis

type Redis struct {
	Address  string `yaml:"address" json:"address" mapstructure:"address"`
	Password string `yaml:"password" json:"password" mapstructure:"password"`
	TLS      TLS    `mapstructure:"tls" yaml:"tls" json:"tls"`
}

Redis database configuration with TLS

type TLS

type TLS struct {
	// IsEnabled is the flag to enable/disable TLS
	IsEnabled bool `yaml:"enabled" json:"enabled,omitempty" mapstructure:"enabled"`

	// RootCertificatePath is the path to the root certificate
	RootCertificatePath string `yaml:"rootCaPath" json:"rootCaPath,omitempty" mapstructure:"rootCaPath"`

	// CertificatePath is the path to the certificate
	CertificatePath string `yaml:"certPath" json:"certPath,omitempty" mapstructure:"certPath"`

	// PrivateKeyPath is the path to the private key
	PrivateKeyPath string `yaml:"keyPath" json:"keyPath,omitempty" mapstructure:"keyPath"`
}

TLS configuration with the option to enable/disable and with paths to the certificates

Jump to

Keyboard shortcuts

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