config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Defaults = Values{
	LogLevel:        "info",
	ApplicationName: "gotosocial",
	ConfigPath:      "",
	Host:            "",
	AccountDomain:   "",
	Protocol:        "https",
	BindAddress:     "0.0.0.0",
	Port:            8080,
	TrustedProxies:  []string{"127.0.0.1/32"},

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

	WebTemplateBaseDir: "./web/template/",
	WebAssetBaseDir:    "./web/assets/",

	AccountsRegistrationOpen: true,
	AccountsApprovalRequired: true,
	AccountsReasonRequired:   true,

	MediaImageMaxSize:        2097152,
	MediaVideoMaxSize:        10485760,
	MediaDescriptionMinChars: 0,
	MediaDescriptionMaxChars: 500,
	MediaRemoteCacheDays:     30,

	StorageBackend:       "local",
	StorageLocalBasePath: "/gotosocial/storage",

	StatusesMaxChars:           5000,
	StatusesCWMaxChars:         100,
	StatusesPollMaxOptions:     6,
	StatusesPollOptionMaxChars: 50,
	StatusesMediaMaxFiles:      6,

	LetsEncryptEnabled:      false,
	LetsEncryptPort:         80,
	LetsEncryptCertDir:      "/gotosocial/storage/certs",
	LetsEncryptEmailAddress: "",

	OIDCEnabled:          false,
	OIDCIdpName:          "",
	OIDCSkipVerification: false,
	OIDCIssuer:           "",
	OIDCClientID:         "",
	OIDCClientSecret:     "",
	OIDCScopes:           []string{oidc.ScopeOpenID, "profile", "email", "groups"},

	SMTPHost:     "",
	SMTPPort:     0,
	SMTPUsername: "",
	SMTPPassword: "",
	SMTPFrom:     "GoToSocial",

	SyslogEnabled:  false,
	SyslogProtocol: "udp",
	SyslogAddress:  "localhost:514",
}

Defaults returns a populated Values struct with most of the values set to reasonable defaults. Note that if you use this, you still need to set Host and, if desired, ConfigPath.

View Source
var Keys = KeyNames{
	LogLevel:        "log-level",
	ApplicationName: "application-name",
	ConfigPath:      "config-path",
	Host:            "host",
	AccountDomain:   "account-domain",
	Protocol:        "protocol",
	BindAddress:     "bind-address",
	Port:            "port",
	TrustedProxies:  "trusted-proxies",
	SoftwareVersion: "software-version",

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

	WebTemplateBaseDir: "web-template-base-dir",
	WebAssetBaseDir:    "web-asset-base-dir",

	AccountsRegistrationOpen: "accounts-registration-open",
	AccountsApprovalRequired: "accounts-approval-required",
	AccountsReasonRequired:   "accounts-reason-required",

	MediaImageMaxSize:        "media-image-max-size",
	MediaVideoMaxSize:        "media-video-max-size",
	MediaDescriptionMinChars: "media-description-min-chars",
	MediaDescriptionMaxChars: "media-description-max-chars",
	MediaRemoteCacheDays:     "media-remote-cache-days",

	StorageBackend:       "storage-backend",
	StorageLocalBasePath: "storage-local-base-path",

	StatusesMaxChars:           "statuses-max-chars",
	StatusesCWMaxChars:         "statuses-cw-max-chars",
	StatusesPollMaxOptions:     "statuses-poll-max-options",
	StatusesPollOptionMaxChars: "statuses-poll-option-max-chars",
	StatusesMediaMaxFiles:      "statuses-media-max-files",

	LetsEncryptEnabled:      "letsencrypt-enabled",
	LetsEncryptPort:         "letsencrypt-port",
	LetsEncryptCertDir:      "letsencrypt-cert-dir",
	LetsEncryptEmailAddress: "letsencrypt-email-address",

	OIDCEnabled:          "oidc-enabled",
	OIDCIdpName:          "oidc-idp-name",
	OIDCSkipVerification: "oidc-skip-verification",
	OIDCIssuer:           "oidc-issuer",
	OIDCClientID:         "oidc-client-id",
	OIDCClientSecret:     "oidc-client-secret",
	OIDCScopes:           "oidc-scopes",

	SMTPHost:     "smtp-host",
	SMTPPort:     "smtp-port",
	SMTPUsername: "smtp-username",
	SMTPPassword: "smtp-password",
	SMTPFrom:     "smtp-from",

	SyslogEnabled:  "syslog-enabled",
	SyslogProtocol: "syslog-protocol",
	SyslogAddress:  "syslog-address",

	AdminAccountUsername: "username",
	AdminAccountEmail:    "email",
	AdminAccountPassword: "password",
	AdminTransPath:       "path",
}

Keys contains the names of the various keys used for initializing and storing flag variables, and retrieving values from the viper config store.

Functions

func InitViper added in v0.2.0

func InitViper(f *pflag.FlagSet) error

func ReadFromFile added in v0.2.0

func ReadFromFile() error

ReadFromFile checks if there's already a path to the config file set in viper. If there is, it will attempt to read the config file into viper.

Types

type KeyNames added in v0.2.0

type KeyNames struct {
	// root
	LogLevel   string
	ConfigPath string

	// general
	ApplicationName string
	Host            string
	AccountDomain   string
	Protocol        string
	BindAddress     string
	Port            string
	TrustedProxies  string
	SoftwareVersion string

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

	// template
	WebTemplateBaseDir string
	WebAssetBaseDir    string

	// accounts
	AccountsRegistrationOpen string
	AccountsApprovalRequired string
	AccountsReasonRequired   string

	// media
	MediaImageMaxSize        string
	MediaVideoMaxSize        string
	MediaDescriptionMinChars string
	MediaDescriptionMaxChars string
	MediaRemoteCacheDays     string

	// storage
	StorageBackend       string
	StorageLocalBasePath string

	// statuses
	StatusesMaxChars           string
	StatusesCWMaxChars         string
	StatusesPollMaxOptions     string
	StatusesPollOptionMaxChars string
	StatusesMediaMaxFiles      string

	// letsencrypt
	LetsEncryptEnabled      string
	LetsEncryptCertDir      string
	LetsEncryptEmailAddress string
	LetsEncryptPort         string

	// oidc
	OIDCEnabled          string
	OIDCIdpName          string
	OIDCSkipVerification string
	OIDCIssuer           string
	OIDCClientID         string
	OIDCClientSecret     string
	OIDCScopes           string

	// smtp
	SMTPHost     string
	SMTPPort     string
	SMTPUsername string
	SMTPPassword string
	SMTPFrom     string

	// syslog
	SyslogEnabled  string
	SyslogProtocol string
	SyslogAddress  string

	// admin
	AdminAccountUsername string
	AdminAccountEmail    string
	AdminAccountPassword string
	AdminTransPath       string
}

KeyNames is a struct that just contains the names of configuration keys.

type Values added in v0.2.0

type Values struct {
	LogLevel        string
	ApplicationName string
	ConfigPath      string
	Host            string
	AccountDomain   string
	Protocol        string
	BindAddress     string
	Port            int
	TrustedProxies  []string
	SoftwareVersion string

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

	WebTemplateBaseDir string
	WebAssetBaseDir    string

	AccountsRegistrationOpen bool
	AccountsApprovalRequired bool
	AccountsReasonRequired   bool

	MediaImageMaxSize        int
	MediaVideoMaxSize        int
	MediaDescriptionMinChars int
	MediaDescriptionMaxChars int
	MediaRemoteCacheDays     int

	StorageBackend       string
	StorageLocalBasePath string

	StatusesMaxChars           int
	StatusesCWMaxChars         int
	StatusesPollMaxOptions     int
	StatusesPollOptionMaxChars int
	StatusesMediaMaxFiles      int

	LetsEncryptEnabled      bool
	LetsEncryptCertDir      string
	LetsEncryptEmailAddress string
	LetsEncryptPort         int

	OIDCEnabled          bool
	OIDCIdpName          string
	OIDCSkipVerification bool
	OIDCIssuer           string
	OIDCClientID         string
	OIDCClientSecret     string
	OIDCScopes           []string

	SMTPHost     string
	SMTPPort     int
	SMTPUsername string
	SMTPPassword string
	SMTPFrom     string

	SyslogEnabled  bool
	SyslogProtocol string
	SyslogAddress  string

	AdminAccountUsername string
	AdminAccountEmail    string
	AdminAccountPassword string
	AdminTransPath       string
}

Values contains contains the type of each configuration value.

Jump to

Keyboard shortcuts

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