mirror of
https://git.mills.io/saltyim/saltyim.git
synced 2024-06-25 16:28:20 +00:00
![James Mills](/assets/img/avatar_default.png)
This PR also: - Tidies up the default options and config - Tidies up the service user code Co-authored-by: James Mills <prologic@shortcircuit.net.au> Reviewed-on: https://git.mills.io/saltyim/saltyim/pulls/116
45 lines
881 B
Go
45 lines
881 B
Go
package internal
|
|
|
|
import (
|
|
"net/url"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// Config contains the server configuration parameters
|
|
type Config struct {
|
|
Debug bool
|
|
|
|
TLS bool `json:"-"`
|
|
TLSKey string `json:"-"`
|
|
TLSCert string `json:"-"`
|
|
|
|
Data string `json:"-"`
|
|
Store string `json:"-"`
|
|
|
|
BaseURL string
|
|
PrimaryDomain string
|
|
|
|
AdminUser string `json:"-"`
|
|
SupportEmail string `json:"-"`
|
|
|
|
baseURL *url.URL
|
|
}
|
|
|
|
// Validate validates the configuration is valid which for the most part
|
|
// just ensures that default secrets are actually configured correctly
|
|
func (c *Config) Validate() error {
|
|
// Automatically correct missing Scheme in Pod Base URL
|
|
if c.baseURL.Scheme == "" {
|
|
log.Warnf("base url (-u/--base-url) %s is missing the scheme", c.BaseURL)
|
|
c.baseURL.Scheme = "http"
|
|
c.BaseURL = c.baseURL.String()
|
|
}
|
|
|
|
if c.Debug {
|
|
return nil
|
|
}
|
|
|
|
return nil
|
|
}
|