mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-15 13:33:00 -06:00
[chore] Global server configuration overhaul (#575)
* move config flag names and usage to config package, rewrite config package to use global Configuration{} struct
Signed-off-by: kim <grufwub@gmail.com>
* improved code comment
Signed-off-by: kim <grufwub@gmail.com>
* linter
Signed-off-by: kim <grufwub@gmail.com>
* fix unmarshaling
Signed-off-by: kim <grufwub@gmail.com>
* remove kim's custom go compiler changes
Signed-off-by: kim <grufwub@gmail.com>
* generate setter and flag-name functions, implement these in codebase
Signed-off-by: kim <grufwub@gmail.com>
* update deps
Signed-off-by: kim <grufwub@gmail.com>
* small change
Signed-off-by: kim <grufwub@gmail.com>
* appease the linter...
Signed-off-by: kim <grufwub@gmail.com>
* move configuration into ConfigState structure, ensure reloading to/from viper settings to keep in sync
Signed-off-by: kim <grufwub@gmail.com>
* lint
Signed-off-by: kim <grufwub@gmail.com>
* update code comments
Signed-off-by: kim <grufwub@gmail.com>
* fix merge issue
Signed-off-by: kim <grufwub@gmail.com>
* fix merge issue
Signed-off-by: kim <grufwub@gmail.com>
* improved version string (removes time + go version)
Signed-off-by: kim <grufwub@gmail.com>
* fix version string build to pass test script + consolidate logic in func
Signed-off-by: kim <grufwub@gmail.com>
* add license text, update config.Defaults comment
Signed-off-by: kim <grufwub@gmail.com>
* add license text to generated config helpers file
Signed-off-by: kim <grufwub@gmail.com>
* defer unlock on config.Set___(), to ensure unlocked on panic
Signed-off-by: kim <grufwub@gmail.com>
* make it more obvious which cmd flags are being attached
Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
ae5402ada6
commit
43ac0cdb9c
90 changed files with 2450 additions and 1125 deletions
|
|
@ -21,7 +21,6 @@ package router_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/router"
|
||||
|
|
@ -37,8 +36,8 @@ func (suite *SessionTestSuite) SetupTest() {
|
|||
}
|
||||
|
||||
func (suite *SessionTestSuite) TestDeriveSessionNameLocalhostWithPort() {
|
||||
viper.Set(config.Keys.Protocol, "http")
|
||||
viper.Set(config.Keys.Host, "localhost:8080")
|
||||
config.SetProtocol("http")
|
||||
config.SetHost("localhost:8080")
|
||||
|
||||
sessionName, err := router.SessionName()
|
||||
suite.NoError(err)
|
||||
|
|
@ -46,8 +45,8 @@ func (suite *SessionTestSuite) TestDeriveSessionNameLocalhostWithPort() {
|
|||
}
|
||||
|
||||
func (suite *SessionTestSuite) TestDeriveSessionNameLocalhost() {
|
||||
viper.Set(config.Keys.Protocol, "http")
|
||||
viper.Set(config.Keys.Host, "localhost")
|
||||
config.SetProtocol("http")
|
||||
config.SetHost("localhost")
|
||||
|
||||
sessionName, err := router.SessionName()
|
||||
suite.NoError(err)
|
||||
|
|
@ -55,8 +54,8 @@ func (suite *SessionTestSuite) TestDeriveSessionNameLocalhost() {
|
|||
}
|
||||
|
||||
func (suite *SessionTestSuite) TestDeriveSessionNoProtocol() {
|
||||
viper.Set(config.Keys.Protocol, "")
|
||||
viper.Set(config.Keys.Host, "localhost")
|
||||
config.SetProtocol("")
|
||||
config.SetHost("localhost")
|
||||
|
||||
sessionName, err := router.SessionName()
|
||||
suite.EqualError(err, "parse \"://localhost\": missing protocol scheme")
|
||||
|
|
@ -64,9 +63,9 @@ func (suite *SessionTestSuite) TestDeriveSessionNoProtocol() {
|
|||
}
|
||||
|
||||
func (suite *SessionTestSuite) TestDeriveSessionNoHost() {
|
||||
viper.Set(config.Keys.Protocol, "https")
|
||||
viper.Set(config.Keys.Host, "")
|
||||
viper.Set(config.Keys.Port, 0)
|
||||
config.SetProtocol("https")
|
||||
config.SetHost("")
|
||||
config.SetPort(0)
|
||||
|
||||
sessionName, err := router.SessionName()
|
||||
suite.EqualError(err, "could not derive hostname without port from https://")
|
||||
|
|
@ -74,8 +73,8 @@ func (suite *SessionTestSuite) TestDeriveSessionNoHost() {
|
|||
}
|
||||
|
||||
func (suite *SessionTestSuite) TestDeriveSessionOK() {
|
||||
viper.Set(config.Keys.Protocol, "https")
|
||||
viper.Set(config.Keys.Host, "example.org")
|
||||
config.SetProtocol("https")
|
||||
config.SetHost("example.org")
|
||||
|
||||
sessionName, err := router.SessionName()
|
||||
suite.NoError(err)
|
||||
|
|
@ -83,8 +82,8 @@ func (suite *SessionTestSuite) TestDeriveSessionOK() {
|
|||
}
|
||||
|
||||
func (suite *SessionTestSuite) TestDeriveSessionIDNOK() {
|
||||
viper.Set(config.Keys.Protocol, "https")
|
||||
viper.Set(config.Keys.Host, "fóid.org")
|
||||
config.SetProtocol("https")
|
||||
config.SetHost("fóid.org")
|
||||
|
||||
sessionName, err := router.SessionName()
|
||||
suite.NoError(err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue