config

package
v0.0.0-...-6fd8457 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config provides the configuration for the application.

Index

Constants

View Source
const (
	ModeDevelopment = "development"
	ModeProduction  = "production"
)
View Source
const (
	LogFormatJSON = "json"
	LogFormatText = "text"
)
View Source
const (
	DriverSqlite3 = "sqlite3"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	conf.Version
	Mode    string     `yaml:"mode"    conf:"default:development"` // development or production
	Web     WebConfig  `yaml:"web"`
	Storage Storage    `yaml:"storage"`
	Log     LoggerConf `yaml:"logger"`
	Mailer  MailerConf `yaml:"mailer"`
	Demo    bool       `yaml:"demo"`
	Debug   DebugConf  `yaml:"debug"`
	Options Options    `yaml:"options"`
}

func New

func New(buildstr string, description string) (*Config, error)

New parses the CLI/Config file and returns a Config struct. If the file argument is an empty string, the file is not read. If the file is not empty, the file is read and the Config struct is returned.

func (*Config) Print

func (c *Config) Print()

Print prints the configuration to stdout as a json indented string This is useful for debugging. If the marshaller errors out, it will panic.

type DebugConf

type DebugConf struct {
	Enabled bool   `yaml:"enabled" conf:"default:false"`
	Port    string `yaml:"port"    conf:"default:4000"`
}

type LoggerConf

type LoggerConf struct {
	Level  string `conf:"default:info"`
	Format string `conf:"default:text"`
}

type MailerConf

type MailerConf struct {
	Host     string `conf:""`
	Port     int    `conf:""`
	Username string `conf:""`
	Password string `conf:""`
	From     string `conf:""`
}

func (*MailerConf) Ready

func (mc *MailerConf) Ready() bool

Ready is a simple check to ensure that the configuration is not empty. or with it's default state.

type Options

type Options struct {
	AllowRegistration    bool   `yaml:"disable_registration"    conf:"default:true"`
	AutoIncrementAssetID bool   `yaml:"auto_increment_asset_id" conf:"default:true"`
	CurrencyConfig       string `yaml:"currencies"`
}

type Storage

type Storage struct {
	// Data is the path to the root directory
	Data      string `yaml:"data"       conf:"default:./.data"`
	SqliteURL string `yaml:"sqlite-url" conf:"default:./.data/homebox.db?_pragma=busy_timeout=999&_pragma=journal_mode=WAL&_fk=1"`
}

type WebConfig

type WebConfig struct {
	Port          string        `yaml:"port"            conf:"default:7745"`
	Host          string        `yaml:"host"`
	MaxUploadSize int64         `yaml:"max_file_upload" conf:"default:10"`
	ReadTimeout   time.Duration `yaml:"read_timeout"    conf:"default:10s"`
	WriteTimeout  time.Duration `yaml:"write_timeout"   conf:"default:10s"`
	IdleTimeout   time.Duration `yaml:"idle_timeout"    conf:"default:30s"`
}

Jump to

Keyboard shortcuts

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