config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: GPL-3.0 Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAdminPasswordFromFromEnv

func GetAdminPasswordFromFromEnv() (string, error)

GetAdminPasswordFromFromEnv returns the DB driver based on the value of environment variables :

ADMIN_PASSWORD : string containing the password to use for the administrative account

func GetAdminUserFromFromEnv

func GetAdminUserFromFromEnv(defaultAdminUser string) string

GetAdminUserFromFromEnv returns the DB driver based on the value of environment variables :

ADMIN_USER : string containing the username to use for the administrative account

func GetJwtDurationFromEnv

func GetJwtDurationFromEnv(defaultJwtDuration int) (int, error)

GetJwtDurationFromEnv returns a number string based on the values of environment variable : JWT_DURATION_MINUTES : int value between 1 and 14400 minutes, 10 days seems an extreme max value the parameter defaultJwtDuration will be used if this env variable is not defined in case the ENV variable JWT_DURATION_MINUTES exists and contains an invalid integer the functions returns 0 and an error

func GetJwtSecretFromEnv

func GetJwtSecretFromEnv() (string, error)

GetJwtSecretFromEnv returns a secret to be used with JWT based on the content of the env variable JWT_SECRET : should contain a string with your secret

func GetPgDbDsnUrlFromEnv

func GetPgDbDsnUrlFromEnv(defaultIP string, defaultPort int,
	defaultDbName string, defaultDbUser string, defaultSSL string) (string, error)

GetPgDbDsnUrlFromEnv returns a valid DSN connection string based on the values of environment variables :

	DB_HOST : string containing a valid Ip Address to use for DB connection
	DB_PORT : int value between 1 and 65535
	DB_NAME : string containing the database name
	DB_USER : string containing the database username
	DB_PASSWORD : string containing the database user password
 DB_SSL_MODE : string containing ssl mode (disable|allow|prefer|require|verify-ca|verify-full)
 more info on libpg SSL : https://www.postgresql.org/docs/11/libpq-ssl.html#LIBPQ-SSL-PROTECTION
 more info : https://pkg.go.dev/github.com/jackc/pgconn#ParseConfig

func GetPortFromEnv

func GetPortFromEnv(defaultPort int) (string, error)

GetPortFromEnv returns a valid TCP/IP listening ':PORT' string based on the values of environment variable :

	PORT : int value between 1 and 65535 (the parameter defaultPort will be used if env is not defined)
 in case the ENV variable PORT exists and contains an invalid integer the functions returns an empty string and an error

Types

type Error

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

func (*Error) Error

func (e *Error) Error() string

Error returns a string with an error and a specifics message

Jump to

Keyboard shortcuts

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