Settings: Rename constants/variables to follow Go naming standards (#28002)

* settings: Rename constants/variables to follow Go naming standards
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-10-02 15:45:45 +02:00
committed by GitHub
parent a5e12f653d
commit a078e40238
23 changed files with 62 additions and 62 deletions

View File

@ -26,34 +26,33 @@ import (
type Scheme string
const (
HTTP Scheme = "http"
HTTPS Scheme = "https"
HTTP2 Scheme = "h2"
SOCKET Scheme = "socket"
DEFAULT_HTTP_ADDR string = "0.0.0.0"
REDACTED_PASSWORD string = "*********"
HTTPScheme Scheme = "http"
HTTPSScheme Scheme = "https"
HTTP2Scheme Scheme = "h2"
SocketScheme Scheme = "socket"
)
const (
DEV = "development"
PROD = "production"
TEST = "test"
APP_NAME = "Grafana"
redactedPassword = "*********"
DefaultHTTPAddr = "0.0.0.0"
Dev = "development"
Prod = "production"
Test = "test"
)
var (
ERR_TEMPLATE_NAME = "error"
ErrTemplateName = "error"
)
// This constant corresponds to the default value for ldap_sync_ttl in .ini files
// it is used for comparison and has to be kept in sync
const (
AUTH_PROXY_SYNC_TTL = 60
AuthProxySyncTTL = 60
)
var (
// App settings.
Env = DEV
Env = Dev
AppUrl string
AppSubUrl string
ServeFromSubPath bool
@ -371,7 +370,7 @@ func applyEnvVariableOverrides(file *ini.File) error {
if len(envValue) > 0 {
key.SetValue(envValue)
if shouldRedactKey(envKey) {
envValue = REDACTED_PASSWORD
envValue = redactedPassword
}
if shouldRedactURLKey(envKey) {
u, err := url.Parse(envValue)
@ -439,7 +438,7 @@ func applyCommandLineDefaultProperties(props map[string]string, file *ini.File)
if exists {
key.SetValue(value)
if shouldRedactKey(keyString) {
value = REDACTED_PASSWORD
value = redactedPassword
}
appliedCommandLineProperties = append(appliedCommandLineProperties, fmt.Sprintf("%s=%s", keyString, value))
}
@ -664,7 +663,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
cfg.IsEnterprise = IsEnterprise
cfg.Packaging = Packaging
ApplicationName = APP_NAME
ApplicationName = "Grafana"
Env = valueAsString(iniFile.Section(""), "app_mode", "development")
InstanceName = valueAsString(iniFile.Section(""), "instance_name", "unknown_instance_name")
@ -878,7 +877,7 @@ func (s *DynamicSection) Key(k string) *ini.Key {
key.SetValue(envValue)
if shouldRedactKey(envKey) {
envValue = REDACTED_PASSWORD
envValue = redactedPassword
}
s.Logger.Info("Config overridden from Environment variable", "var", fmt.Sprintf("%s=%s", envKey, envValue))
@ -1015,7 +1014,7 @@ func readAuthSettings(iniFile *ini.File, cfg *Cfg) (err error) {
ldapSyncVal := authProxy.Key("ldap_sync_ttl").MustInt()
syncVal := authProxy.Key("sync_ttl").MustInt()
if ldapSyncVal != AUTH_PROXY_SYNC_TTL {
if ldapSyncVal != AuthProxySyncTTL {
AuthProxySyncTtl = ldapSyncVal
cfg.Logger.Warn("[Deprecated] the configuration setting 'ldap_sync_ttl' is deprecated, please use 'sync_ttl' instead")
} else {
@ -1128,26 +1127,26 @@ func readServerSettings(iniFile *ini.File, cfg *Cfg) error {
cfg.AppSubUrl = AppSubUrl
cfg.ServeFromSubPath = ServeFromSubPath
Protocol = HTTP
Protocol = HTTPScheme
protocolStr := valueAsString(server, "protocol", "http")
if protocolStr == "https" {
Protocol = HTTPS
Protocol = HTTPSScheme
CertFile = server.Key("cert_file").String()
KeyFile = server.Key("cert_key").String()
}
if protocolStr == "h2" {
Protocol = HTTP2
Protocol = HTTP2Scheme
CertFile = server.Key("cert_file").String()
KeyFile = server.Key("cert_key").String()
}
if protocolStr == "socket" {
Protocol = SOCKET
Protocol = SocketScheme
SocketPath = server.Key("socket").String()
}
Domain = valueAsString(server, "domain", "localhost")
HttpAddr = valueAsString(server, "http_addr", DEFAULT_HTTP_ADDR)
HttpAddr = valueAsString(server, "http_addr", DefaultHTTPAddr)
HttpPort = valueAsString(server, "http_port", "3000")
RouterLogging = server.Key("router_logging").MustBool(false)