config

package
v0.0.0-...-0f594a8 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Defaults = Values{
	ConfigPath: "",
	LogLevel:   "info",

	ApplicationName:    "block",
	ApplicationWebsite: "https://git.ptzo.gdn/feditools/block",
	ExternalEndpoint:   "http://localhost:5169",
	MinifyHTML:         true,
	HTTPBind:           ":5169",

	DBAddress:   "localhost",
	DBPort:      5432,
	DBUser:      "block",
	DBPassword:  "block",
	DBDatabase:  "block",
	DBTLSMode:   "disable",
	DBTLSCACert: "",

	RedisAddress: "localhost:6379",
	RedisDB:      0,

	WebappBootstrapCSSURI:         "https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css",
	WebappBootstrapCSSIntegrity:   "sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi",
	WebappBootstrapJSURI:          "https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js",
	WebappBootstrapJSIntegrity:    "sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3",
	WebappChartJSURI:              "https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js",
	WebappChartJSIntegrity:        "sha384-9MhbyIRcBVQiiC7FSd7T38oJNj2Zh+EfxS7/vjhBi4OOT78NlHSnzM31EZRWR1LZ",
	WebappFontAwesomeCSSURI:       "https://assets.fedi.tools/vendor/fontawesome-free-6.1.1/css/all.min.css",
	WebappFontAwesomeCSSIntegrity: "sha384-/frq1SRXYH/bSyou/HUp/hib7RVN1TawQYja658FEOodR/FQBKVqT9Ol+Oz3Olq5",
	WebappLogoSrcDark:             "https://assets.fedi.tools/img/feditools-logo-dark.svg",
	WebappLogoSrcLight:            "https://assets.fedi.tools/img/feditools-logo-light.svg",

	MetricsHTTPBind: ":9219",
}

Defaults contains the default values.

View Source
var Keys = KeyNames{
	ConfigPath: "config-path",
	LogLevel:   "log-level",

	ApplicationName:    "application-name",
	ApplicationWebsite: "application-website",
	EncryptionKey:      "encryption-key",
	ExternalEndpoint:   "external-endpoint",
	HTTPBind:           "http-bind",
	MinifyHTML:         "minify-html",
	SoftwareVersion:    "software-version",
	TokenSalt:          "token-salt",

	DBAddress:   "db-address",
	DBPort:      "db-port",
	DBUser:      "db-user",
	DBPassword:  "db-password",
	DBDatabase:  "db-database",
	DBTLSMode:   "db-tls-mode",
	DBTLSCACert: "db-tls-ca-cert",

	RedisAddress:  "redis-address",
	RedisDB:       "redis-db",
	RedisPassword: "redis-password",

	WebappBootstrapCSSURI:         "webapp-bootstrap-css-uri",
	WebappBootstrapCSSIntegrity:   "webapp-bootstrap-css-integrity",
	WebappBootstrapJSURI:          "webapp-bootstrap-js-uri",
	WebappBootstrapJSIntegrity:    "webapp-bootstrap-js-integrity",
	WebappChartJSURI:              "webapp-chart-js-uri",
	WebappChartJSIntegrity:        "webapp-chart-js-integrity",
	WebappFontAwesomeCSSURI:       "webapp-fontawesome-css-uri",
	WebappFontAwesomeCSSIntegrity: "webapp-fontawesome-css-integrity",
	WebappLogoSrcDark:             "webapp-logo-src-dark",
	WebappLogoSrcLight:            "webapp-logo-src-light",

	Account:         "account",
	AccountAddGroup: "add-group",

	MetricsHTTPBind: "metrics-http-bind",
}

Keys contains the names of config keys.

Functions

func Init

func Init(flags *pflag.FlagSet) error

Init starts config collection.

func ReadConfigFile

func ReadConfigFile() error

ReadConfigFile reads the config file from disk if config path is sent.

Types

type KeyNames

type KeyNames struct {
	LogLevel   string
	ConfigPath string

	// application
	ApplicationName    string
	ApplicationWebsite string
	EncryptionKey      string
	ExternalEndpoint   string
	HTTPBind           string
	MinifyHTML         string
	SoftwareVersion    string
	TokenSalt          string

	// database
	DBAddress   string
	DBPort      string
	DBUser      string
	DBPassword  string
	DBDatabase  string
	DBTLSMode   string
	DBTLSCACert string

	// redis
	RedisAddress  string
	RedisDB       string
	RedisPassword string

	// webapp
	WebappBootstrapCSSURI         string
	WebappBootstrapCSSIntegrity   string
	WebappBootstrapJSURI          string
	WebappBootstrapJSIntegrity    string
	WebappChartJSURI              string
	WebappChartJSIntegrity        string
	WebappFontAwesomeCSSURI       string
	WebappFontAwesomeCSSIntegrity string
	WebappLogoSrcDark             string
	WebappLogoSrcLight            string

	// account
	Account         string
	AccountAddGroup string

	// metrics
	MetricsHTTPBind string
}

KeyNames is a struct that contains the names of keys.

type Values

type Values struct {
	LogLevel   string
	ConfigPath string

	// application
	ApplicationName    string
	ApplicationWebsite string
	EncryptionKey      string
	ExternalEndpoint   string
	HTTPBind           string
	MinifyHTML         bool
	SoftwareVersion    string
	TokenSalt          string

	// database
	DBAddress   string
	DBPort      int
	DBUser      string
	DBPassword  string
	DBDatabase  string
	DBTLSMode   string
	DBTLSCACert string

	// redis
	RedisAddress  string
	RedisDB       int
	RedisPassword string

	// webapp
	WebappBootstrapCSSURI         string
	WebappBootstrapCSSIntegrity   string
	WebappBootstrapJSURI          string
	WebappBootstrapJSIntegrity    string
	WebappChartJSURI              string
	WebappChartJSIntegrity        string
	WebappFontAwesomeCSSURI       string
	WebappFontAwesomeCSSIntegrity string
	WebappLogoSrcDark             string
	WebappLogoSrcLight            string

	// account
	Account         string
	AccountAddGroup []string

	// metrics
	MetricsHTTPBind string
}

Values contains the type of each value.

Jump to

Keyboard shortcuts

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