diff --git a/cmd/backend/config.go b/cmd/backend/config.go index 53a5ea1..4df4c24 100644 --- a/cmd/backend/config.go +++ b/cmd/backend/config.go @@ -14,11 +14,11 @@ import ( type Config struct { AESKeyFile string ArticleDir string + AtomFile string ConfigFile string DBName string Description string Domain string - AtomFile string FirebaseKey string GOBKeyFile string Link string @@ -52,7 +52,7 @@ func newConfig() *Config { PDFDir: "/var/www/cpolis/pdfs", PicsDir: "/var/www/cpolis/pics", Port: ":8080", - Version: "v0.14.1", + Version: "v0.15.0", WebDir: "/var/www/cpolis/web", } } @@ -171,6 +171,14 @@ func (c *Config) setupConfig(cliConfig *Config) error { return fmt.Errorf("error setting up directory: %v", err) } + if cliConfig.AtomFile != defaultConfig.AtomFile { + c.AtomFile = cliConfig.AtomFile + } + c.AtomFile, err = mkFile(c.AtomFile, 0644, 0744) + if err != nil { + return fmt.Errorf("error setting up file: %v", err) + } + if cliConfig.DBName != defaultConfig.DBName { c.DBName = cliConfig.DBName } @@ -182,19 +190,11 @@ func (c *Config) setupConfig(cliConfig *Config) error { if cliConfig.Domain != defaultConfig.Domain { c.Domain = cliConfig.Domain } - domainStrings := strings.Split(c.Domain, "/") - if domainStrings[0] != "http:" && domainStrings[0] != "https:" { + domainStrings := strings.Split(c.Domain, ":") + if domainStrings[0] != "http" && domainStrings[0] != "https" { c.Domain = "https://" + c.Domain } - if cliConfig.AtomFile != defaultConfig.AtomFile { - c.AtomFile = cliConfig.AtomFile - } - c.AtomFile, err = mkFile(c.AtomFile, 0644, 0744) - if err != nil { - return fmt.Errorf("error setting up file: %v", err) - } - if cliConfig.FirebaseKey != defaultConfig.FirebaseKey { c.FirebaseKey = cliConfig.FirebaseKey }