config

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServerRoleActivityPub represents the activity pub server role.
	ServerRoleActivityPub = "activity-pub"
	// ServerRoleRobots represents the static asset server role.
	ServerRoleRobots = "robots"
	// ServerRoleWebapp represents the webapp server role.
	ServerRoleWebapp = "webapp"
)

Variables

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

	ActorKeySize:        2048,
	ApplicationName:     "feditools-relay",
	ApplicationWebsite:  "https://github.com/feditools/relay",
	CachedActivityLimit: 1024,
	CachedActorLimit:    1024,
	CachedDigestLimit:   1024,

	DbType:      "postgres",
	DbAddress:   "",
	DbPort:      5432,
	DbUser:      "",
	DbPassword:  "",
	DbDatabase:  "relay",
	DbTLSMode:   "disable",
	DbTLSCACert: "",

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

	RunnerConcurrency: 4,

	ServerExternalHostname: "localhost",
	ServerHTTPBind:         ":5000",
	ServerMinifyHTML:       true,
	ServerRoles: []string{
		ServerRoleActivityPub,
		ServerRoleRobots,
		ServerRoleWebapp,
	},

	WebappBootstrapCSSURI:         "https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css",
	WebappBootstrapCSSIntegrity:   "sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor",
	WebappBootstrapJSURI:          "https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js",
	WebappBootstrapJSIntegrity:    "sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2",
	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",

	MetricsStatsDAddress: "localhost:8125",
	MetricsStatsDPrefix:  "relay",
}

Defaults contains the default values

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

	ActorKeySize:        "actor-key-size",
	ApplicationName:     "application-name",
	ApplicationWebsite:  "application-website",
	CachedActivityLimit: "cached-activity-limit",
	CachedActorLimit:    "cached-actor-limit",
	CachedDigestLimit:   "cached-digest-limit",
	EncryptionKey:       "encryption-key",
	SoftwareVersion:     "software-version",
	TokenSalt:           "token-salt",

	DbType:      "db-type",
	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",

	RunnerConcurrency: "runner-concurrency",

	ServerExternalHostname: "external-hostname",
	ServerHTTPBind:         "http-bind",
	ServerMinifyHTML:       "minify-html",
	ServerRoles:            "server-role",

	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",

	MetricsStatsDAddress: "statsd-addr",
	MetricsStatsDPrefix:  "statsd-prefix",
}

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
	ActorKeySize        string
	ApplicationName     string
	ApplicationWebsite  string
	CachedActivityLimit string
	CachedActorLimit    string
	CachedDigestLimit   string
	EncryptionKey       string
	SoftwareVersion     string
	TokenSalt           string

	// database
	DbType      string
	DbAddress   string
	DbPort      string
	DbUser      string
	DbPassword  string
	DbDatabase  string
	DbTLSMode   string
	DbTLSCACert string

	// redis
	RedisAddress  string
	RedisDB       string
	RedisPassword string

	// runner
	RunnerConcurrency string

	// server
	ServerExternalHostname string
	ServerHTTPBind         string
	ServerMinifyHTML       string
	ServerRoles            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
	MetricsStatsDAddress string
	MetricsStatsDPrefix  string
}

KeyNames is a struct that contains the names of keys.

type Values

type Values struct {
	ConfigPath string
	LogLevel   string

	// application
	ActorKeySize        int
	ApplicationName     string
	ApplicationWebsite  string
	CachedActivityLimit int
	CachedActorLimit    int
	CachedDigestLimit   int
	EncryptionKey       string
	SoftwareVersion     string
	TokenSalt           string

	// database
	DbType      string
	DbAddress   string
	DbPort      int
	DbUser      string
	DbPassword  string
	DbDatabase  string
	DbTLSMode   string
	DbTLSCACert string

	// redis
	RedisAddress  string
	RedisDB       int
	RedisPassword string

	// runner
	RunnerConcurrency int

	// server
	ServerExternalHostname string
	ServerHTTPBind         string
	ServerMinifyHTML       bool
	ServerRoles            []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
	MetricsStatsDAddress string
	MetricsStatsDPrefix  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