diff options
author | 2021-03-04 12:07:24 +0100 | |
---|---|---|
committer | 2021-03-04 12:07:24 +0100 | |
commit | 645ea31856eb578882791b116481385bf10da6e8 (patch) | |
tree | ca866b976da8ec4021f7af4e4a3f46581a11053d /internal/db/postgres.go | |
parent | further yak shaving (diff) | |
download | gotosocial-645ea31856eb578882791b116481385bf10da6e8.tar.xz |
Move some consts around
Diffstat (limited to 'internal/db/postgres.go')
-rw-r--r-- | internal/db/postgres.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/internal/db/postgres.go b/internal/db/postgres.go index 14c8d3d7b..1eb3eb4b9 100644 --- a/internal/db/postgres.go +++ b/internal/db/postgres.go @@ -28,6 +28,7 @@ import ( "github.com/go-fed/activity/streams/vocab" "github.com/go-pg/pg" + "github.com/gotosocial/gotosocial/internal/consts" "github.com/sirupsen/logrus" ) @@ -100,23 +101,22 @@ func derivePGOptions(config *Config) (*pg.Options, error) { return nil, fmt.Errorf("expected db type of %s but got %s", dbTypePostgres, config.Type) } - // use sensible default port - var port int = config.Port - if port == 0 { - port = postgresDefaultPort + // validate port + if config.Port == 0 { + return nil, errors.New("no port set") } // validate address if config.Address == "" { - config.Address = defaultAddress + return nil, errors.New("no address set") } - if !hostnameRegex.MatchString(config.Address) && !ipv4Regex.MatchString(config.Address) && config.Address != "localhost" { + if !consts.HostnameRegex.MatchString(config.Address) && !consts.IPV4Regex.MatchString(config.Address) && config.Address != "localhost" { return nil, fmt.Errorf("address %s was neither an ipv4 address nor a valid hostname", config.Address) } // validate username if config.User == "" { - config.User = postgresDefaultUser + return nil, errors.New("no user set") } // validate that there's a password @@ -126,7 +126,7 @@ func derivePGOptions(config *Config) (*pg.Options, error) { // validate database if config.Database == "" { - config.Database = defaultDatabase + return nil, errors.New("no database set") } // We can rely on the pg library we're using to set |