| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | /* | 
					
						
							|  |  |  |    GoToSocial | 
					
						
							|  |  |  |    Copyright (C) 2021 GoToSocial Authors admin@gotosocial.org | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |    it under the terms of the GNU Affero General Public License as published by | 
					
						
							|  |  |  |    the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |    (at your option) any later version. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |    GNU Affero General Public License for more details. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |    along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package config | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"os" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 21:15:20 +01:00
										 |  |  | 	"gopkg.in/yaml.v2" | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-04 14:38:18 +01:00
										 |  |  | // Config pulls together all the configuration needed to run gotosocial | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | type Config struct { | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | 	LogLevel        string          `yaml:"logLevel"` | 
					
						
							|  |  |  | 	ApplicationName string          `yaml:"applicationName"` | 
					
						
							| 
									
										
										
										
											2021-03-22 22:26:54 +01:00
										 |  |  | 	Host            string          `yaml:"host"` | 
					
						
							|  |  |  | 	Protocol        string          `yaml:"protocol"` | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | 	DBConfig        *DBConfig       `yaml:"db"` | 
					
						
							|  |  |  | 	TemplateConfig  *TemplateConfig `yaml:"template"` | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	AccountsConfig  *AccountsConfig `yaml:"accounts"` | 
					
						
							|  |  |  | 	MediaConfig     *MediaConfig    `yaml:"media"` | 
					
						
							|  |  |  | 	StorageConfig   *StorageConfig  `yaml:"storage"` | 
					
						
							| 
									
										
										
										
											2021-04-01 23:05:31 +02:00
										 |  |  | 	StatusesConfig  *StatusesConfig `yaml:"statuses"` | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | // FromFile returns a new config from a file, or an error if something goes amiss. | 
					
						
							|  |  |  | func FromFile(path string) (*Config, error) { | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	if path != "" { | 
					
						
							|  |  |  | 		c, err := loadFromFile(path) | 
					
						
							|  |  |  | 		if err != nil { | 
					
						
							|  |  |  | 			return nil, fmt.Errorf("error creating config: %s", err) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return c, nil | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	return Empty(), nil | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | // Empty just returns an empty config | 
					
						
							|  |  |  | func Empty() *Config { | 
					
						
							|  |  |  | 	return &Config{ | 
					
						
							| 
									
										
										
										
											2021-03-20 19:04:27 +01:00
										 |  |  | 		DBConfig:       &DBConfig{}, | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | 		TemplateConfig: &TemplateConfig{}, | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 		AccountsConfig: &AccountsConfig{}, | 
					
						
							|  |  |  | 		MediaConfig:    &MediaConfig{}, | 
					
						
							|  |  |  | 		StorageConfig:  &StorageConfig{}, | 
					
						
							| 
									
										
										
										
											2021-04-01 23:05:31 +02:00
										 |  |  | 		StatusesConfig: &StatusesConfig{}, | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-03 21:15:20 +01:00
										 |  |  | // loadFromFile takes a path to a yaml file and attempts to load a Config object from it | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | func loadFromFile(path string) (*Config, error) { | 
					
						
							|  |  |  | 	bytes, err := os.ReadFile(path) | 
					
						
							|  |  |  | 	if err != nil { | 
					
						
							|  |  |  | 		return nil, fmt.Errorf("could not read file at path %s: %s", path, err) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	config := &Config{} | 
					
						
							| 
									
										
										
										
											2021-03-03 21:15:20 +01:00
										 |  |  | 	if err := yaml.Unmarshal(bytes, config); err != nil { | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | 		return nil, fmt.Errorf("could not unmarshal file at path %s: %s", path, err) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return config, nil | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | // ParseCLIFlags sets flags on the config using the provided Flags object | 
					
						
							|  |  |  | func (c *Config) ParseCLIFlags(f KeyedFlags) { | 
					
						
							| 
									
										
										
										
											2021-03-04 14:38:18 +01:00
										 |  |  | 	fn := GetFlagNames() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// For all of these flags, we only want to set them on the config if: | 
					
						
							|  |  |  | 	// | 
					
						
							|  |  |  | 	// a) They haven't been set at all in the config file we already parsed, | 
					
						
							|  |  |  | 	// 	  and so we take the default from the flags object. | 
					
						
							|  |  |  | 	// | 
					
						
							|  |  |  | 	// b) They may have been set in the config, but they've *also* been set explicitly | 
					
						
							|  |  |  | 	//    as a command-line argument or an env variable, which takes priority. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// general flags | 
					
						
							|  |  |  | 	if c.LogLevel == "" || f.IsSet(fn.LogLevel) { | 
					
						
							|  |  |  | 		c.LogLevel = f.String(fn.LogLevel) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.ApplicationName == "" || f.IsSet(fn.ApplicationName) { | 
					
						
							|  |  |  | 		c.ApplicationName = f.String(fn.ApplicationName) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-22 22:26:54 +01:00
										 |  |  | 	if c.Host == "" || f.IsSet(fn.Host) { | 
					
						
							|  |  |  | 		c.Host = f.String(fn.Host) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.Protocol == "" || f.IsSet(fn.Protocol) { | 
					
						
							|  |  |  | 		c.Protocol = f.String(fn.Protocol) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-04 14:38:18 +01:00
										 |  |  | 	// db flags | 
					
						
							|  |  |  | 	if c.DBConfig.Type == "" || f.IsSet(fn.DbType) { | 
					
						
							|  |  |  | 		c.DBConfig.Type = f.String(fn.DbType) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.DBConfig.Address == "" || f.IsSet(fn.DbAddress) { | 
					
						
							|  |  |  | 		c.DBConfig.Address = f.String(fn.DbAddress) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.DBConfig.Port == 0 || f.IsSet(fn.DbPort) { | 
					
						
							|  |  |  | 		c.DBConfig.Port = f.Int(fn.DbPort) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-03-03 21:15:20 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-04 14:38:18 +01:00
										 |  |  | 	if c.DBConfig.User == "" || f.IsSet(fn.DbUser) { | 
					
						
							|  |  |  | 		c.DBConfig.User = f.String(fn.DbUser) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.DBConfig.Password == "" || f.IsSet(fn.DbPassword) { | 
					
						
							|  |  |  | 		c.DBConfig.Password = f.String(fn.DbPassword) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.DBConfig.Database == "" || f.IsSet(fn.DbDatabase) { | 
					
						
							|  |  |  | 		c.DBConfig.Database = f.String(fn.DbDatabase) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// template flags | 
					
						
							|  |  |  | 	if c.TemplateConfig.BaseDir == "" || f.IsSet(fn.TemplateBaseDir) { | 
					
						
							|  |  |  | 		c.TemplateConfig.BaseDir = f.String(fn.TemplateBaseDir) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// accounts flags | 
					
						
							|  |  |  | 	if f.IsSet(fn.AccountsOpenRegistration) { | 
					
						
							|  |  |  | 		c.AccountsConfig.OpenRegistration = f.Bool(fn.AccountsOpenRegistration) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if f.IsSet(fn.AccountsRequireApproval) { | 
					
						
							|  |  |  | 		c.AccountsConfig.RequireApproval = f.Bool(fn.AccountsRequireApproval) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// media flags | 
					
						
							|  |  |  | 	if c.MediaConfig.MaxImageSize == 0 || f.IsSet(fn.MediaMaxImageSize) { | 
					
						
							|  |  |  | 		c.MediaConfig.MaxImageSize = f.Int(fn.MediaMaxImageSize) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.MediaConfig.MaxVideoSize == 0 || f.IsSet(fn.MediaMaxVideoSize) { | 
					
						
							|  |  |  | 		c.MediaConfig.MaxVideoSize = f.Int(fn.MediaMaxVideoSize) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// storage flags | 
					
						
							|  |  |  | 	if c.StorageConfig.Backend == "" || f.IsSet(fn.StorageBackend) { | 
					
						
							|  |  |  | 		c.StorageConfig.Backend = f.String(fn.StorageBackend) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.StorageConfig.BasePath == "" || f.IsSet(fn.StorageBasePath) { | 
					
						
							|  |  |  | 		c.StorageConfig.BasePath = f.String(fn.StorageBasePath) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.StorageConfig.ServeProtocol == "" || f.IsSet(fn.StorageServeProtocol) { | 
					
						
							|  |  |  | 		c.StorageConfig.ServeProtocol = f.String(fn.StorageServeProtocol) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.StorageConfig.ServeHost == "" || f.IsSet(fn.StorageServeHost) { | 
					
						
							|  |  |  | 		c.StorageConfig.ServeHost = f.String(fn.StorageServeHost) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if c.StorageConfig.ServeBasePath == "" || f.IsSet(fn.StorageServeBasePath) { | 
					
						
							|  |  |  | 		c.StorageConfig.ServeBasePath = f.String(fn.StorageServeBasePath) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-04-01 23:05:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// statuses flags | 
					
						
							|  |  |  | 	if c.StatusesConfig.MaxChars == 0 || f.IsSet(fn.StatusesMaxChars) { | 
					
						
							|  |  |  | 		c.StatusesConfig.MaxChars = f.Int(fn.StatusesMaxChars) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if c.StatusesConfig.CWMaxChars == 0 || f.IsSet(fn.StatusesCWMaxChars) { | 
					
						
							|  |  |  | 		c.StatusesConfig.CWMaxChars = f.Int(fn.StatusesCWMaxChars) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if c.StatusesConfig.PollMaxOptions == 0 || f.IsSet(fn.StatusesPollMaxOptions) { | 
					
						
							|  |  |  | 		c.StatusesConfig.PollMaxOptions = f.Int(fn.StatusesPollMaxOptions) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if c.StatusesConfig.PollOptionMaxChars == 0 || f.IsSet(fn.StatusesPollOptionMaxChars) { | 
					
						
							|  |  |  | 		c.StatusesConfig.PollOptionMaxChars = f.Int(fn.StatusesPollOptionMaxChars) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if c.StatusesConfig.MaxMediaFiles == 0 || f.IsSet(fn.StatusesMaxMediaFiles) { | 
					
						
							|  |  |  | 		c.StatusesConfig.MaxMediaFiles = f.Int(fn.StatusesMaxMediaFiles) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-04 14:38:18 +01:00
										 |  |  | // KeyedFlags is a wrapper for any type that can store keyed flags and give them back. | 
					
						
							|  |  |  | // HINT: This works with a urfave cli context struct ;) | 
					
						
							|  |  |  | type KeyedFlags interface { | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 	Bool(k string) bool | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | 	String(k string) string | 
					
						
							|  |  |  | 	Int(k string) int | 
					
						
							| 
									
										
										
										
											2021-03-04 14:38:18 +01:00
										 |  |  | 	IsSet(k string) bool | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Flags is used for storing the names of the various flags used for | 
					
						
							|  |  |  | // initializing and storing urfavecli flag variables. | 
					
						
							|  |  |  | type Flags struct { | 
					
						
							|  |  |  | 	LogLevel        string | 
					
						
							|  |  |  | 	ApplicationName string | 
					
						
							|  |  |  | 	ConfigPath      string | 
					
						
							| 
									
										
										
										
											2021-03-22 22:26:54 +01:00
										 |  |  | 	Host            string | 
					
						
							|  |  |  | 	Protocol        string | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	DbType     string | 
					
						
							|  |  |  | 	DbAddress  string | 
					
						
							|  |  |  | 	DbPort     string | 
					
						
							|  |  |  | 	DbUser     string | 
					
						
							|  |  |  | 	DbPassword string | 
					
						
							|  |  |  | 	DbDatabase string | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | 	TemplateBaseDir string | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	AccountsOpenRegistration string | 
					
						
							|  |  |  | 	AccountsRequireApproval  string | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	MediaMaxImageSize string | 
					
						
							|  |  |  | 	MediaMaxVideoSize string | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	StorageBackend       string | 
					
						
							|  |  |  | 	StorageBasePath      string | 
					
						
							|  |  |  | 	StorageServeProtocol string | 
					
						
							|  |  |  | 	StorageServeHost     string | 
					
						
							|  |  |  | 	StorageServeBasePath string | 
					
						
							| 
									
										
										
										
											2021-04-01 23:05:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-02 19:20:41 +02:00
										 |  |  | 	StatusesMaxChars           string | 
					
						
							|  |  |  | 	StatusesCWMaxChars         string | 
					
						
							|  |  |  | 	StatusesPollMaxOptions     string | 
					
						
							| 
									
										
										
										
											2021-04-01 23:05:31 +02:00
										 |  |  | 	StatusesPollOptionMaxChars string | 
					
						
							| 
									
										
										
										
											2021-04-02 19:20:41 +02:00
										 |  |  | 	StatusesMaxMediaFiles      string | 
					
						
							| 
									
										
										
										
											2021-03-04 14:38:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // GetFlagNames returns a struct containing the names of the various flags used for | 
					
						
							|  |  |  | // initializing and storing urfavecli flag variables. | 
					
						
							|  |  |  | func GetFlagNames() Flags { | 
					
						
							|  |  |  | 	return Flags{ | 
					
						
							|  |  |  | 		LogLevel:        "log-level", | 
					
						
							|  |  |  | 		ApplicationName: "application-name", | 
					
						
							|  |  |  | 		ConfigPath:      "config-path", | 
					
						
							| 
									
										
										
										
											2021-03-22 22:26:54 +01:00
										 |  |  | 		Host:            "host", | 
					
						
							|  |  |  | 		Protocol:        "protocol", | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		DbType:     "db-type", | 
					
						
							|  |  |  | 		DbAddress:  "db-address", | 
					
						
							|  |  |  | 		DbPort:     "db-port", | 
					
						
							|  |  |  | 		DbUser:     "db-user", | 
					
						
							|  |  |  | 		DbPassword: "db-password", | 
					
						
							|  |  |  | 		DbDatabase: "db-database", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | 		TemplateBaseDir: "template-basedir", | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		AccountsOpenRegistration: "accounts-open-registration", | 
					
						
							|  |  |  | 		AccountsRequireApproval:  "accounts-require-approval", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		MediaMaxImageSize: "media-max-image-size", | 
					
						
							|  |  |  | 		MediaMaxVideoSize: "media-max-video-size", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		StorageBackend:       "storage-backend", | 
					
						
							|  |  |  | 		StorageBasePath:      "storage-base-path", | 
					
						
							|  |  |  | 		StorageServeProtocol: "storage-serve-protocol", | 
					
						
							|  |  |  | 		StorageServeHost:     "storage-serve-host", | 
					
						
							|  |  |  | 		StorageServeBasePath: "storage-serve-base-path", | 
					
						
							| 
									
										
										
										
											2021-04-01 23:05:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-02 19:20:41 +02:00
										 |  |  | 		StatusesMaxChars:           "statuses-max-chars", | 
					
						
							|  |  |  | 		StatusesCWMaxChars:         "statuses-cw-max-chars", | 
					
						
							|  |  |  | 		StatusesPollMaxOptions:     "statuses-poll-max-options", | 
					
						
							| 
									
										
										
										
											2021-04-01 23:05:31 +02:00
										 |  |  | 		StatusesPollOptionMaxChars: "statuses-poll-option-max-chars", | 
					
						
							| 
									
										
										
										
											2021-04-02 19:20:41 +02:00
										 |  |  | 		StatusesMaxMediaFiles:      "statuses-max-media-files", | 
					
						
							| 
									
										
										
										
											2021-03-04 14:38:18 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // GetEnvNames returns a struct containing the names of the environment variable keys used for | 
					
						
							|  |  |  | // initializing and storing urfavecli flag variables. | 
					
						
							|  |  |  | func GetEnvNames() Flags { | 
					
						
							|  |  |  | 	return Flags{ | 
					
						
							|  |  |  | 		LogLevel:        "GTS_LOG_LEVEL", | 
					
						
							|  |  |  | 		ApplicationName: "GTS_APPLICATION_NAME", | 
					
						
							|  |  |  | 		ConfigPath:      "GTS_CONFIG_PATH", | 
					
						
							| 
									
										
										
										
											2021-03-22 22:26:54 +01:00
										 |  |  | 		Host:            "GTS_HOST", | 
					
						
							|  |  |  | 		Protocol:        "GTS_PROTOCOL", | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		DbType:     "GTS_DB_TYPE", | 
					
						
							|  |  |  | 		DbAddress:  "GTS_DB_ADDRESS", | 
					
						
							|  |  |  | 		DbPort:     "GTS_DB_PORT", | 
					
						
							|  |  |  | 		DbUser:     "GTS_DB_USER", | 
					
						
							|  |  |  | 		DbPassword: "GTS_DB_PASSWORD", | 
					
						
							|  |  |  | 		DbDatabase: "GTS_DB_DATABASE", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-18 23:27:43 +01:00
										 |  |  | 		TemplateBaseDir: "GTS_TEMPLATE_BASEDIR", | 
					
						
							| 
									
										
										
										
											2021-04-01 20:46:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		AccountsOpenRegistration: "GTS_ACCOUNTS_OPEN_REGISTRATION", | 
					
						
							|  |  |  | 		AccountsRequireApproval:  "GTS_ACCOUNTS_REQUIRE_APPROVAL", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		MediaMaxImageSize: "GTS_MEDIA_MAX_IMAGE_SIZE", | 
					
						
							|  |  |  | 		MediaMaxVideoSize: "GTS_MEDIA_MAX_VIDEO_SIZE", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		StorageBackend:       "GTS_STORAGE_BACKEND", | 
					
						
							|  |  |  | 		StorageBasePath:      "GTS_STORAGE_BASE_PATH", | 
					
						
							|  |  |  | 		StorageServeProtocol: "GTS_STORAGE_SERVE_PROTOCOL", | 
					
						
							|  |  |  | 		StorageServeHost:     "GTS_STORAGE_SERVE_HOST", | 
					
						
							|  |  |  | 		StorageServeBasePath: "GTS_STORAGE_SERVE_BASE_PATH", | 
					
						
							| 
									
										
										
										
											2021-04-01 23:05:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-02 19:20:41 +02:00
										 |  |  | 		StatusesMaxChars:           "GTS_STATUSES_MAX_CHARS", | 
					
						
							|  |  |  | 		StatusesCWMaxChars:         "GTS_STATUSES_CW_MAX_CHARS", | 
					
						
							|  |  |  | 		StatusesPollMaxOptions:     "GTS_STATUSES_POLL_MAX_OPTIONS", | 
					
						
							| 
									
										
										
										
											2021-04-01 23:05:31 +02:00
										 |  |  | 		StatusesPollOptionMaxChars: "GTS_STATUSES_POLL_OPTION_MAX_CHARS", | 
					
						
							| 
									
										
										
										
											2021-04-02 19:20:41 +02:00
										 |  |  | 		StatusesMaxMediaFiles:      "GTS_STATUSES_MAX_MEDIA_FILES", | 
					
						
							| 
									
										
										
										
											2021-03-04 14:38:18 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-03-03 18:12:02 +01:00
										 |  |  | } |