config

package
v0.0.0-...-89b6d9c Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ServerRoleBootstrap represents the bootstrap test server role
	ServerRoleBootstrap = "bootstrap"
	// ServerRoleWebapp represents the webapp server role
	ServerRoleWebapp = "webapp"
)

Variables

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

	ApplicationName: "feditools",

	DbType:         "postgres",
	DbAddress:      "",
	DbPort:         5432,
	DbUser:         "",
	DbPassword:     "",
	DbDatabase:     "feditools",
	DbTLSMode:      "disable",
	DbTLSCACert:    "",
	DbLoadTestData: false,

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

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

	S3Endpoint:               "play.min.io",
	S3Region:                 "us-east-1",
	S3UseSSL:                 true,
	S3Bucket:                 "feditools",
	S3PresignedURLExpiration: 10 * time.Second,

	ServerExternalHostname: "localhost",
	ServerHTTP2:            true,
	ServerHTTP2Bind:        ":5000",
	ServerHTTP3:            false,
	ServerHTTP3Bind:        ":5000",
	ServerMinifyHTML:       true,
	ServerRoles: []string{
		ServerRoleWebapp,
	},
	ServerTLSCertPath: "server.crt",
	ServerTLSKeyPath:  "server.key",

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

Defaults contains the default values

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

	ApplicationName: "application-name",
	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",

	AccessExpiration:  "access-expiration",
	AccessSecret:      "access-secret",
	RefreshExpiration: "refresh-expiration",
	RefreshSecret:     "refresh-secret",

	S3Endpoint:               "s3-endpoint",
	S3Region:                 "s3-region",
	S3AccessKeyID:            "s3-access-id",
	S3SecretAccessKey:        "s3-secret-key",
	S3UseSSL:                 "s3-ssl",
	S3Bucket:                 "s3-bucket",
	S3PresignedURLExpiration: "s3-url-expiration",

	ServerExternalHostname: "external-hostname",
	ServerHTTP2:            "http2",
	ServerHTTP2Bind:        "http2-bind",
	ServerHTTP3:            "http3",
	ServerHTTP3Bind:        "http3-bind",
	ServerMinifyHTML:       "minify-html",
	ServerRoles:            "server-role",
	ServerTLSCertPath:      "tls-cert",
	ServerTLSKeyPath:       "tls-key",

	UserAccount: "account",
	UserGroups:  "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
	ApplicationName 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

	// auth
	AccessExpiration  string
	AccessSecret      string
	RefreshExpiration string
	RefreshSecret     string

	// s3
	S3Endpoint               string
	S3Region                 string
	S3AccessKeyID            string
	S3SecretAccessKey        string
	S3UseSSL                 string
	S3Bucket                 string
	S3PresignedURLExpiration string

	// server
	ServerExternalHostname string
	ServerHTTP2            string
	ServerHTTP2Bind        string
	ServerHTTP3            string
	ServerHTTP3Bind        string
	ServerMinifyHTML       string
	ServerRoles            string
	ServerTLSCertPath      string
	ServerTLSKeyPath       string

	// account
	UserAccount string
	UserGroups  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
	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

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

	// s3
	S3Endpoint               string
	S3Region                 string
	S3AccessKeyID            string
	S3SecretAccessKey        string
	S3UseSSL                 bool
	S3Bucket                 string
	S3PresignedURLExpiration time.Duration

	// server
	ServerExternalHostname string
	ServerHTTP2            bool
	ServerHTTP2Bind        string
	ServerHTTP3            bool
	ServerHTTP3Bind        string
	ServerMinifyHTML       bool
	ServerRoles            []string
	ServerTLSCertPath      string
	ServerTLSKeyPath       string

	// account
	UserAccount string
	UserGroups  []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