Backend: Migrate to using non-global configuration (#31856)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
+18
-13
@@ -70,8 +70,6 @@ var (
|
||||
CustomInitPath = "conf/custom.ini"
|
||||
|
||||
// HTTP server options
|
||||
HttpAddr, HttpPort string
|
||||
CertFile, KeyFile string
|
||||
DataProxyLogging bool
|
||||
DataProxyTimeout int
|
||||
DataProxyTLSHandshakeTimeout int
|
||||
@@ -80,8 +78,6 @@ var (
|
||||
DataProxyKeepAlive int
|
||||
DataProxyIdleConnTimeout int
|
||||
StaticRootPath string
|
||||
EnableGzip bool
|
||||
EnforceDomain bool
|
||||
|
||||
// Security settings.
|
||||
SecretKey string
|
||||
@@ -187,6 +183,10 @@ type Cfg struct {
|
||||
Logger log.Logger
|
||||
|
||||
// HTTP Server Settings
|
||||
CertFile string
|
||||
KeyFile string
|
||||
HTTPAddr string
|
||||
HTTPPort string
|
||||
AppURL string
|
||||
AppSubURL string
|
||||
ServeFromSubPath bool
|
||||
@@ -196,6 +196,8 @@ type Cfg struct {
|
||||
RouterLogging bool
|
||||
Domain string
|
||||
CDNRootURL *url.URL
|
||||
EnableGzip bool
|
||||
EnforceDomain bool
|
||||
|
||||
// build
|
||||
BuildVersion string
|
||||
@@ -353,6 +355,8 @@ type Cfg struct {
|
||||
|
||||
// ExpressionsEnabled specifies whether expressions are enabled.
|
||||
ExpressionsEnabled bool
|
||||
|
||||
ImageUploadProvider string
|
||||
}
|
||||
|
||||
// IsLiveEnabled returns if grafana live should be enabled
|
||||
@@ -895,7 +899,8 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
||||
}
|
||||
|
||||
imageUploadingSection := iniFile.Section("external_image_storage")
|
||||
ImageUploadProvider = valueAsString(imageUploadingSection, "provider", "")
|
||||
cfg.ImageUploadProvider = valueAsString(imageUploadingSection, "provider", "")
|
||||
ImageUploadProvider = cfg.ImageUploadProvider
|
||||
|
||||
enterprise := iniFile.Section("enterprise")
|
||||
cfg.EnterpriseLicensePath = valueAsString(enterprise, "license_path", filepath.Join(cfg.DataPath, "license.jwt"))
|
||||
@@ -1303,13 +1308,13 @@ func (cfg *Cfg) readServerSettings(iniFile *ini.File) error {
|
||||
|
||||
if protocolStr == "https" {
|
||||
cfg.Protocol = HTTPSScheme
|
||||
CertFile = server.Key("cert_file").String()
|
||||
KeyFile = server.Key("cert_key").String()
|
||||
cfg.CertFile = server.Key("cert_file").String()
|
||||
cfg.KeyFile = server.Key("cert_key").String()
|
||||
}
|
||||
if protocolStr == "h2" {
|
||||
cfg.Protocol = HTTP2Scheme
|
||||
CertFile = server.Key("cert_file").String()
|
||||
KeyFile = server.Key("cert_key").String()
|
||||
cfg.CertFile = server.Key("cert_file").String()
|
||||
cfg.KeyFile = server.Key("cert_key").String()
|
||||
}
|
||||
if protocolStr == "socket" {
|
||||
cfg.Protocol = SocketScheme
|
||||
@@ -1317,12 +1322,12 @@ func (cfg *Cfg) readServerSettings(iniFile *ini.File) error {
|
||||
}
|
||||
|
||||
cfg.Domain = valueAsString(server, "domain", "localhost")
|
||||
HttpAddr = valueAsString(server, "http_addr", DefaultHTTPAddr)
|
||||
HttpPort = valueAsString(server, "http_port", "3000")
|
||||
cfg.HTTPAddr = valueAsString(server, "http_addr", DefaultHTTPAddr)
|
||||
cfg.HTTPPort = valueAsString(server, "http_port", "3000")
|
||||
cfg.RouterLogging = server.Key("router_logging").MustBool(false)
|
||||
|
||||
EnableGzip = server.Key("enable_gzip").MustBool(false)
|
||||
EnforceDomain = server.Key("enforce_domain").MustBool(false)
|
||||
cfg.EnableGzip = server.Key("enable_gzip").MustBool(false)
|
||||
cfg.EnforceDomain = server.Key("enforce_domain").MustBool(false)
|
||||
staticRoot := valueAsString(server, "static_root_path", "")
|
||||
StaticRootPath = makeAbsolute(staticRoot, HomePath)
|
||||
cfg.StaticRootPath = StaticRootPath
|
||||
|
||||
Reference in New Issue
Block a user