conf

package
v1.11.13 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package conf sets the configurations of this program using the host system environment variables.

Index

Constants

View Source
const (
	EnvPrefix  = "DF2_"     // EnvPrefix is the prefix applied to all environment variable names.
	LiveServer = "DF2_HOST" // LiveServer is environment variable name to identify the live web server.
	GapUser    = "df2"      // GapUser is the Go Application Paths username.
)

Variables

View Source
var ErrPointer = errors.New("pointer value cannot be nil")

Functions

func BinPath

func BinPath() (string, error)

func DownloadDir

func DownloadDir(name string, l *zap.SugaredLogger) error

DownloadDir runs checks against the named directory containing the UUID record downloads. Problems will either log warnings or fatal errors.

func LogDir

func LogDir(name string, l *zap.SugaredLogger) error

LogDir runs checks against the named log directory. Problems will either log warnings or fatal errors.

func Options

func Options() env.Options

Types

type Config

type Config struct {
	IsProduction  bool   `env:"PRODUCTION" help:"Use the production mode to log all errors and warnings to a file"` //nolint:lll
	MaxProcs      uint   `env:"MAXPROCS" help:"Limit the number of operating system threads the program can use"`   //nolint:lll
	DBName        string `env:"DBNAME" help:"Name of the database to use"`
	DBUser        string `env:"DBUSER" help:"Database connection user name"`
	DBPass        string `env:"DBPASS" help:"Database connection password"`
	DBHost        string `env:"DBHOST" help:"Database connection host address"`
	DBPort        uint   `env:"DBPORT" help:"Database connection TCP port"`
	WebRoot       string `env:"ROOT" help:"Path to the root directory of the website"`
	Downloads     string `env:"DOWNLOAD" help:"Path containing UUID named files served as downloads"`
	Images        string `env:"IMG000" help:"Path containing screenshots and previews"`
	Thumbs        string `env:"IMG400" help:"Path containing 400x400 thumbnails of the screenshots"`
	Backups       string `env:"BACKUP" help:"Path containing backup archives or previously removed files"`
	Emulator      string `env:"EMULATOR" help:"Path containing the DOSee emulation files"`
	HTMLExports   string `env:"HTML" help:"Path to save the HTML files generated by this tool"`
	IncomingFiles string `env:"INCOMING" help:"Path containing user uploaded files"`
	IncomingImgs  string `env:"INCOMINGIMG" help:"Path containing screenshots of user uploaded files"`
	HTMLViews     string `env:"VIEWS" help:"Path to save the HTML files generated by this tool"`
	SQLDumps      string `env:"SQLDUMP" help:"Path containing database data exports as SQL dumps"`
	Timeout       uint   `env:"TIMEOUT" help:"The timeout in seconds value for database connections"`
}

Config environment overrides for the Defacto2 tool. There are no envDefault attributes in this struct, instead they're found in the func Defaults().

func Defaults

func Defaults() Config

Defaults for the Config environment struct. Directory paths are different based on weather the DF2_HOST environment variable is set. When set, a /opt/ parent directory is used as the root, otherwise the user home directory is used.

func TestData

func TestData() Config

TestData returns the directory paths but with the temporary directory as root. This is intended for directories unit tests.

func (Config) Checks

func (c Config) Checks(l *zap.SugaredLogger) error

Checks runs a number of sanity checks for the environment variable configurations.

func (Config) String

func (c Config) String(w io.Writer)

Jump to

Keyboard shortcuts

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