config

package
v0.0.0-...-5767ed4 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 (
	FileStoreTypeLocal = "local"
	FileStoreTypeMinio = "minio"

	// ServerRoleWebapp represents the webapp server role.
	ServerRoleWebapp = "webapp"
)

Variables

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

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

	DBType:         "postgres",
	DBAddress:      "localhost",
	DBPort:         5432,
	DBUser:         "democrablock",
	DBDatabase:     "democrablock",
	DBTLSMode:      "disable",
	DBTLSCACert:    "",
	DBLoadTestData: false,

	FileStoreType:                   FileStoreTypeLocal,
	FileStorePath:                   "filestore",
	FileStoreBucket:                 "democrablock",
	FileStoreEndpoint:               "play.min.io",
	FileStoreRegion:                 "us-east-1",
	FileStoreUseTLS:                 true,
	FileStorePresignedURLExpiration: 5 * time.Minute,

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

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

	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:  "democrablock",
}

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",
	EncryptionKey:      "encryption-key",

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

	FileStoreType:                   "filestore-type",
	FileStorePath:                   "filestore-path",
	FileStoreBucket:                 "filestore-bucket",
	FileStoreEndpoint:               "filestore-endpoint",
	FileStoreRegion:                 "filestore-region",
	FileStoreAccessKeyID:            "filestore-access-key-id",
	FileStoreSecretAccessKey:        "filestore-secret-access-key",
	FileStoreUseTLS:                 "filestore-use-tls",
	FileStorePresignedURLExpiration: "filestore-presigned-utl-expiration",

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

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

	CouncilMembers: "member",

	ServerExternalURL: "external-url",
	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
	EncryptionKey      string
	SoftwareVersion    string
	TokenSalt          string

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

	// filestore
	FileStoreType                   string
	FileStorePath                   string
	FileStoreBucket                 string
	FileStoreEndpoint               string
	FileStoreRegion                 string
	FileStoreAccessKeyID            string
	FileStoreSecretAccessKey        string
	FileStoreUseTLS                 string
	FileStorePresignedURLExpiration string

	// redis
	RedisAddress  string
	RedisDB       string
	RedisPassword string

	// account
	Account         string
	AccountAddGroup string

	// council
	CouncilMembers string

	// server
	ServerExternalURL 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
	EncryptionKey      string
	SoftwareVersion    string
	TokenSalt          string

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

	// filestore
	FileStoreType                   string
	FileStorePath                   string
	FileStoreBucket                 string
	FileStoreEndpoint               string
	FileStoreRegion                 string
	FileStoreAccessKeyID            string
	FileStoreSecretAccessKey        string
	FileStoreUseTLS                 bool
	FileStorePresignedURLExpiration time.Duration

	// redis
	RedisAddress  string
	RedisDB       int
	RedisPassword string

	// account
	Account         string
	AccountAddGroup []string

	// council
	CouncilMembers []string

	// server
	ServerExternalURL 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