config

package
v0.0.0-...-e647751 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ServerRoleWebapp represents the webapp server role.
	ServerRoleWebapp = "webapp"
	// ServerRoleWellKnown represents the well-known server role.
	ServerRoleWellKnown = "well-known"
)

Variables

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

	ApplicationName:    "feditools-login",
	ApplicationWebsite: "https://github.com/feditools/login",

	DBType:         "postgres",
	DBAddress:      "",
	DBPort:         5432,
	DBUser:         "",
	DBPassword:     "",
	DBDatabase:     "ft_login",
	DBTLSMode:      "disable",
	DBTLSCACert:    "",
	DBLoadTestData: false,

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

	AccessExpiration:  time.Minute * 15,
	RefreshExpiration: time.Hour * 24 * 7,

	ServerExternalURL: "http://localhost:5000",
	ServerGRPCBind:    ":50051",
	ServerHTTPBind:    ":5000",
	ServerMinifyHTML:  true,
	ServerRoles: []string{
		ServerRoleWebapp,
		ServerRoleWellKnown,
	},

	WebappBootstrapCSSURI:         "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css",
	WebappBootstrapCSSIntegrity:   "sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDBrCEXSU1oBoqyl2QvZ6jIW3",
	WebappBootstrapJSURI:          "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js",
	WebappBootstrapJSIntegrity:    "sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p",
	WebappFontAwesomeCSSURI:       "https://cdn.fedi.tools/vendor/fontawesome-free-6.1.1/css/all.min.css",
	WebappFontAwesomeCSSIntegrity: "sha384-/frq1SRXYH/bSyou/HUp/hib7RVN1TawQYja658FEOodR/FQBKVqT9Ol+Oz3Olq5",
	WebappLogoSrcDark:             "https://cdn.fedi.tools/img/feditools-logo-dark.svg",
	WebappLogoSrcLight:            "https://cdn.fedi.tools/img/feditools-logo-light.svg",

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

Defaults contains the default values.

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

	ApplicationName:    "application-name",
	ApplicationWebsite: "application-website",
	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",
	DBLoadTestData:  "test-data",
	DBEncryptionKey: "db-crypto-key",

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

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

	AccessExpiration:  "access-expiration",
	AccessSecret:      "access-secret",
	ECPrivateKey:      "ec-private-key",
	ECPublicKey:       "ec-public-key",
	RefreshExpiration: "refresh-expiration",
	RefreshSecret:     "refresh-secret",

	ServerExternalURL: "external-url",
	ServerGRPCBind:    "grpc-bind",
	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",
	WebappFontAwesomeCSSURI:       "webapp-fontawesome-css-uri",
	WebappFontAwesomeCSSIntegrity: "webapp-fontawesome-css-integrity",
	WebappLogoSrcDark:             "webapp-logo-src-dark",
	WebappLogoSrcLight:            "webapp-logo-src-light",

	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
	ApplicationName    string
	ApplicationWebsite string
	SoftwareVersion    string
	TokenSalt          string

	// database
	DBType          string
	DBAddress       string
	DBPort          string
	DBUser          string
	DBPassword      string
	DBDatabase      string
	DBTLSMode       string
	DBTLSCACert     string
	DBLoadTestData  string
	DBEncryptionKey string

	// redis
	RedisAddress  string
	RedisDB       string
	RedisPassword string

	// account
	AccountAccount  string
	AccountAddGroup string

	// auth
	AccessExpiration  string
	AccessSecret      string
	ECPrivateKey      string
	ECPublicKey       string
	RefreshExpiration string
	RefreshSecret     string

	// server
	ServerExternalURL string
	ServerGRPCBind    string
	ServerHTTPBind    string
	ServerMinifyHTML  string
	ServerRoles       string

	// webapp
	WebappBootstrapCSSURI         string
	WebappBootstrapCSSIntegrity   string
	WebappBootstrapJSURI          string
	WebappBootstrapJSIntegrity    string
	WebappFontAwesomeCSSURI       string
	WebappFontAwesomeCSSIntegrity string
	WebappLogoSrcDark             string
	WebappLogoSrcLight            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
	ApplicationName    string
	ApplicationWebsite string
	SoftwareVersion    string
	TokenSalt          string

	// database
	DBType          string
	DBAddress       string
	DBPort          int
	DBUser          string
	DBPassword      string
	DBDatabase      string
	DBTLSMode       string
	DBTLSCACert     string
	DBLoadTestData  bool
	DBEncryptionKey string

	// redis
	RedisAddress  string
	RedisDB       int
	RedisPassword string

	// account
	AccountAccount  string
	AccountAddGroup []string

	// auth
	AccessExpiration  time.Duration
	AccessSecret      string
	ECPrivateKey      string
	ECPublicKey       string
	RefreshExpiration time.Duration
	RefreshSecret     string

	// server
	ServerExternalURL string
	ServerGRPCBind    string
	ServerHTTPBind    string
	ServerMinifyHTML  bool
	ServerRoles       []string

	// webapp
	WebappBootstrapCSSURI         string
	WebappBootstrapCSSIntegrity   string
	WebappBootstrapJSURI          string
	WebappBootstrapJSIntegrity    string
	WebappFontAwesomeCSSURI       string
	WebappFontAwesomeCSSIntegrity string
	WebappLogoSrcDark             string
	WebappLogoSrcLight            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