conf

package
v0.0.0-...-cae3fd7 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureLogger

func ConfigureLogger(c Logger)

func Load

func Load(fp string) error

Load loads the configuration file into C

func Parse

func Parse(in interface{}) error

Parse parses the function

func SetFormatter

func SetFormatter(format string)

func SetLogLevel

func SetLogLevel(lvl string)

SetLogLevel sets the logging level when possible, otherwise it fallbacks to the default logrus level and logs a warning

Types

type Conf

type Conf struct {
	Database   Database   `yaml:"database"`
	Server     Server     `yaml:"server"`
	Logger     Logger     `yaml:"logger"`
	Prometheus Prometheus `yaml:"prometheus"`
	Crontab    Crontab    `yaml:"crontab"`
}

Conf holds the necessary configuration for the application to work

var C Conf

C is the main exported configuration

func (*Conf) Parse

func (c *Conf) Parse() error

Parse will parse every nested fields with the env/defaults parser and set the values accordingly

type Cors

type Cors struct {
	AllowOrigins   []string `yaml:"allow_origins"`
	Enabled        bool     `yaml:"enabled" env:"CORS_ENABLED"`
	PermissiveMode bool     `yaml:"permissive_mode" env:"CORS_PERMISSIVE"`
}

Cors is a simple structure holding the information about CORS configuration

type Crontab

type Crontab struct {
	DownloadPath string `yaml:"download_path" env:"DOWNLOAD_PATH" default:"downloads"`
	EveryXHours  uint64 `yaml:"every_x_hours" env:"EVERY_X_HOURS" default:"3"`
}

Crontab is a simple struct holding configuration variables for the periodic task to be executed

type Database

type Database struct {
	User     string `yaml:"user" env:"DB_USER"`
	Name     string `yaml:"name" env:"DB_NAME" default:"opensirene"`
	Password string `yaml:"password" env:"DB_PASSWORD"`
	Host     string `yaml:"host" env:"DB_HOST" default:"127.0.0.1"`
	Port     int    `yaml:"port" env:"DB_PORT" default:"5432"`
	SSLMode  string `yaml:"sslmode" env:"DB_SSL_MODE" default:"disable"`
}

Database is the structure that holds all the mandatory information about the database connection

func (Database) ConnectionString

func (d Database) ConnectionString() string

ConnectionString generates and returns the connection string used by the standard SQL library or an ORM like Gorm.

type Logger

type Logger struct {
	Level  string `yaml:"level" env:"LOGLEVEL" default:"info"`
	Format string `yaml:"format" env:"LOGFORMAT" default:"text"`
}

type Prefix

type Prefix struct {
	Api   string `yaml:"api"`
	Admin string `yaml:"admin"`
}

Prefix is a simple structure holding the information about prefix apis

type Prometheus

type Prometheus struct {
	Prefix string `yaml:"prefix" env:"PROMETHEUS_PREFIX" default:"opensirene"`
}

Prometheus is a simple struct holding configuration variables for prometheus

type Server

type Server struct {
	Host   string `yaml:"host" env:"SERVER_HOST" default:"127.0.0.1"`
	Port   int    `yaml:"port" env:"SERVER_PORT" default:"8080"`
	Debug  bool   `yaml:"debug" env:"SERVER_DEBUG"`
	Cors   Cors   `yaml:"cors"`
	Prefix Prefix `yaml:"prefix"`
}

Server is the structure that holds the server configuration

Jump to

Keyboard shortcuts

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