Commit a078e402 by Arve Knudsen Committed by GitHub

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>
parent a5e12f65
...@@ -101,7 +101,7 @@ func Error(status int, message string, err error) *NormalResponse { ...@@ -101,7 +101,7 @@ func Error(status int, message string, err error) *NormalResponse {
} }
if err != nil { if err != nil {
if setting.Env != setting.PROD { if setting.Env != setting.Prod {
data["error"] = err.Error() data["error"] = err.Error()
} }
} }
......
...@@ -235,7 +235,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i ...@@ -235,7 +235,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *models.ReqContext) (map[string]i
}, },
"featureToggles": hs.Cfg.FeatureToggles, "featureToggles": hs.Cfg.FeatureToggles,
"rendererAvailable": hs.RenderService.IsAvailable(), "rendererAvailable": hs.RenderService.IsAvailable(),
"http2Enabled": hs.Cfg.Protocol == setting.HTTP2, "http2Enabled": hs.Cfg.Protocol == setting.HTTP2Scheme,
} }
return jsonObj, nil return jsonObj, nil
......
...@@ -106,11 +106,11 @@ func (hs *HTTPServer) Run(ctx context.Context) error { ...@@ -106,11 +106,11 @@ func (hs *HTTPServer) Run(ctx context.Context) error {
Handler: hs.macaron, Handler: hs.macaron,
} }
switch setting.Protocol { switch setting.Protocol {
case setting.HTTP2: case setting.HTTP2Scheme:
if err := hs.configureHttp2(); err != nil { if err := hs.configureHttp2(); err != nil {
return err return err
} }
case setting.HTTPS: case setting.HTTPSScheme:
if err := hs.configureHttps(); err != nil { if err := hs.configureHttps(); err != nil {
return err return err
} }
...@@ -138,7 +138,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error { ...@@ -138,7 +138,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error {
}() }()
switch setting.Protocol { switch setting.Protocol {
case setting.HTTP, setting.SOCKET: case setting.HTTPScheme, setting.SocketScheme:
if err := hs.httpSrv.Serve(listener); err != nil { if err := hs.httpSrv.Serve(listener); err != nil {
if err == http.ErrServerClosed { if err == http.ErrServerClosed {
hs.log.Debug("server was shutdown gracefully") hs.log.Debug("server was shutdown gracefully")
...@@ -146,7 +146,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error { ...@@ -146,7 +146,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error {
} }
return err return err
} }
case setting.HTTP2, setting.HTTPS: case setting.HTTP2Scheme, setting.HTTPSScheme:
if err := hs.httpSrv.ServeTLS(listener, setting.CertFile, setting.KeyFile); err != nil { if err := hs.httpSrv.ServeTLS(listener, setting.CertFile, setting.KeyFile); err != nil {
if err == http.ErrServerClosed { if err == http.ErrServerClosed {
hs.log.Debug("server was shutdown gracefully") hs.log.Debug("server was shutdown gracefully")
...@@ -169,13 +169,13 @@ func (hs *HTTPServer) getListener() (net.Listener, error) { ...@@ -169,13 +169,13 @@ func (hs *HTTPServer) getListener() (net.Listener, error) {
} }
switch setting.Protocol { switch setting.Protocol {
case setting.HTTP, setting.HTTPS, setting.HTTP2: case setting.HTTPScheme, setting.HTTPSScheme, setting.HTTP2Scheme:
listener, err := net.Listen("tcp", hs.httpSrv.Addr) listener, err := net.Listen("tcp", hs.httpSrv.Addr)
if err != nil { if err != nil {
return nil, errutil.Wrapf(err, "failed to open listener on address %s", hs.httpSrv.Addr) return nil, errutil.Wrapf(err, "failed to open listener on address %s", hs.httpSrv.Addr)
} }
return listener, nil return listener, nil
case setting.SOCKET: case setting.SocketScheme:
listener, err := net.ListenUnix("unix", &net.UnixAddr{Name: setting.SocketPath, Net: "unix"}) listener, err := net.ListenUnix("unix", &net.UnixAddr{Name: setting.SocketPath, Net: "unix"})
if err != nil { if err != nil {
return nil, errutil.Wrapf(err, "failed to open listener for socket %s", setting.SocketPath) return nil, errutil.Wrapf(err, "failed to open listener for socket %s", setting.SocketPath)
...@@ -437,7 +437,7 @@ func (hs *HTTPServer) mapStatic(m *macaron.Macaron, rootDir string, dir string, ...@@ -437,7 +437,7 @@ func (hs *HTTPServer) mapStatic(m *macaron.Macaron, rootDir string, dir string,
} }
} }
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
headers = func(c *macaron.Context) { headers = func(c *macaron.Context) {
c.Resp.Header().Set("Cache-Control", "max-age=0, must-revalidate, no-cache") c.Resp.Header().Set("Cache-Control", "max-age=0, must-revalidate, no-cache")
} }
......
...@@ -267,7 +267,7 @@ func rotateEndOfRequestFunc(ctx *models.ReqContext, authTokenService models.User ...@@ -267,7 +267,7 @@ func rotateEndOfRequestFunc(ctx *models.ReqContext, authTokenService models.User
} }
func WriteSessionCookie(ctx *models.ReqContext, value string, maxLifetime time.Duration) { func WriteSessionCookie(ctx *models.ReqContext, value string, maxLifetime time.Duration) {
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
ctx.Logger.Info("New token", "unhashed token", value) ctx.Logger.Info("New token", "unhashed token", value)
} }
...@@ -304,7 +304,8 @@ func AddDefaultResponseHeaders() macaron.Handler { ...@@ -304,7 +304,8 @@ func AddDefaultResponseHeaders() macaron.Handler {
// AddSecurityHeaders adds various HTTP(S) response headers that enable various security protections behaviors in the client's browser. // AddSecurityHeaders adds various HTTP(S) response headers that enable various security protections behaviors in the client's browser.
func AddSecurityHeaders(w macaron.ResponseWriter) { func AddSecurityHeaders(w macaron.ResponseWriter) {
if (setting.Protocol == setting.HTTPS || setting.Protocol == setting.HTTP2) && setting.StrictTransportSecurity { if (setting.Protocol == setting.HTTPSScheme || setting.Protocol == setting.HTTP2Scheme) &&
setting.StrictTransportSecurity {
strictHeaderValues := []string{fmt.Sprintf("max-age=%v", setting.StrictTransportSecurityMaxAge)} strictHeaderValues := []string{fmt.Sprintf("max-age=%v", setting.StrictTransportSecurityMaxAge)}
if setting.StrictTransportSecurityPreload { if setting.StrictTransportSecurityPreload {
strictHeaderValues = append(strictHeaderValues, "preload") strictHeaderValues = append(strictHeaderValues, "preload")
......
...@@ -44,7 +44,7 @@ func resetGetTime() { ...@@ -44,7 +44,7 @@ func resetGetTime() {
} }
func TestMiddleWareSecurityHeaders(t *testing.T) { func TestMiddleWareSecurityHeaders(t *testing.T) {
setting.ERR_TEMPLATE_NAME = errorTemplate setting.ErrTemplateName = errorTemplate
Convey("Given the grafana middleware", t, func() { Convey("Given the grafana middleware", t, func() {
middlewareScenario(t, "middleware should get correct x-xss-protection header", func(sc *scenarioContext) { middlewareScenario(t, "middleware should get correct x-xss-protection header", func(sc *scenarioContext) {
...@@ -61,7 +61,7 @@ func TestMiddleWareSecurityHeaders(t *testing.T) { ...@@ -61,7 +61,7 @@ func TestMiddleWareSecurityHeaders(t *testing.T) {
middlewareScenario(t, "middleware should add correct Strict-Transport-Security header", func(sc *scenarioContext) { middlewareScenario(t, "middleware should add correct Strict-Transport-Security header", func(sc *scenarioContext) {
setting.StrictTransportSecurity = true setting.StrictTransportSecurity = true
setting.Protocol = setting.HTTPS setting.Protocol = setting.HTTPSScheme
setting.StrictTransportSecurityMaxAge = 64000 setting.StrictTransportSecurityMaxAge = 64000
sc.fakeReq("GET", "/api/").exec() sc.fakeReq("GET", "/api/").exec()
So(sc.resp.Header().Get("Strict-Transport-Security"), ShouldEqual, "max-age=64000") So(sc.resp.Header().Get("Strict-Transport-Security"), ShouldEqual, "max-age=64000")
...@@ -76,7 +76,7 @@ func TestMiddleWareSecurityHeaders(t *testing.T) { ...@@ -76,7 +76,7 @@ func TestMiddleWareSecurityHeaders(t *testing.T) {
} }
func TestMiddlewareContext(t *testing.T) { func TestMiddlewareContext(t *testing.T) {
setting.ERR_TEMPLATE_NAME = errorTemplate setting.ErrTemplateName = errorTemplate
Convey("Given the grafana middleware", t, func() { Convey("Given the grafana middleware", t, func() {
middlewareScenario(t, "middleware should add context to injector", func(sc *scenarioContext) { middlewareScenario(t, "middleware should add context to injector", func(sc *scenarioContext) {
......
...@@ -130,7 +130,7 @@ func Recovery() macaron.Handler { ...@@ -130,7 +130,7 @@ func Recovery() macaron.Handler {
c.Data["AppSubUrl"] = setting.AppSubUrl c.Data["AppSubUrl"] = setting.AppSubUrl
c.Data["Theme"] = setting.DefaultTheme c.Data["Theme"] = setting.DefaultTheme
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
if theErr, ok := err.(error); ok { if theErr, ok := err.(error); ok {
c.Data["Title"] = theErr.Error() c.Data["Title"] = theErr.Error()
} }
...@@ -152,7 +152,7 @@ func Recovery() macaron.Handler { ...@@ -152,7 +152,7 @@ func Recovery() macaron.Handler {
c.JSON(500, resp) c.JSON(500, resp)
} else { } else {
c.HTML(500, setting.ERR_TEMPLATE_NAME) c.HTML(500, setting.ErrTemplateName)
} }
} }
}() }()
......
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
) )
func TestRecoveryMiddleware(t *testing.T) { func TestRecoveryMiddleware(t *testing.T) {
setting.ERR_TEMPLATE_NAME = "error-template" setting.ErrTemplateName = "error-template"
Convey("Given an api route that panics", t, func() { Convey("Given an api route that panics", t, func() {
apiURL := "/api/whatever" apiURL := "/api/whatever"
......
...@@ -25,7 +25,7 @@ type ReqContext struct { ...@@ -25,7 +25,7 @@ type ReqContext struct {
func (ctx *ReqContext) Handle(status int, title string, err error) { func (ctx *ReqContext) Handle(status int, title string, err error) {
if err != nil { if err != nil {
ctx.Logger.Error(title, "error", err) ctx.Logger.Error(title, "error", err)
if setting.Env != setting.PROD { if setting.Env != setting.Prod {
ctx.Data["ErrorMsg"] = err ctx.Data["ErrorMsg"] = err
} }
} }
...@@ -34,7 +34,7 @@ func (ctx *ReqContext) Handle(status int, title string, err error) { ...@@ -34,7 +34,7 @@ func (ctx *ReqContext) Handle(status int, title string, err error) {
ctx.Data["AppSubUrl"] = setting.AppSubUrl ctx.Data["AppSubUrl"] = setting.AppSubUrl
ctx.Data["Theme"] = "dark" ctx.Data["Theme"] = "dark"
ctx.HTML(status, setting.ERR_TEMPLATE_NAME) ctx.HTML(status, setting.ErrTemplateName)
} }
func (ctx *ReqContext) JsonOK(message string) { func (ctx *ReqContext) JsonOK(message string) {
...@@ -52,7 +52,7 @@ func (ctx *ReqContext) JsonApiErr(status int, message string, err error) { ...@@ -52,7 +52,7 @@ func (ctx *ReqContext) JsonApiErr(status int, message string, err error) {
if err != nil { if err != nil {
ctx.Logger.Error(message, "error", err) ctx.Logger.Error(message, "error", err)
if setting.Env != setting.PROD { if setting.Env != setting.Prod {
resp["error"] = err.Error() resp["error"] = err.Error()
} }
} }
......
...@@ -294,7 +294,7 @@ func (scanner *PluginScanner) loadPlugin(pluginJsonFilePath string) error { ...@@ -294,7 +294,7 @@ func (scanner *PluginScanner) loadPlugin(pluginJsonFilePath string) error {
break break
} }
} }
if setting.Env != setting.DEV && !allowUnsigned { if setting.Env != setting.Dev && !allowUnsigned {
return fmt.Errorf("plugin %q is unsigned", pluginCommon.Id) return fmt.Errorf("plugin %q is unsigned", pluginCommon.Id)
} }
scanner.log.Warn("Running an unsigned backend plugin", "pluginID", pluginCommon.Id, "pluginDir", pluginCommon.PluginDir) scanner.log.Warn("Running an unsigned backend plugin", "pluginID", pluginCommon.Id, "pluginDir", pluginCommon.PluginDir)
......
...@@ -29,7 +29,7 @@ func TestPluginManager_Init(t *testing.T) { ...@@ -29,7 +29,7 @@ func TestPluginManager_Init(t *testing.T) {
setting.StaticRootPath, err = filepath.Abs("../../public/") setting.StaticRootPath, err = filepath.Abs("../../public/")
require.NoError(t, err) require.NoError(t, err)
setting.Raw = ini.Empty() setting.Raw = ini.Empty()
setting.Env = setting.PROD setting.Env = setting.Prod
t.Run("Base case", func(t *testing.T) { t.Run("Base case", func(t *testing.T) {
pm := &PluginManager{ pm := &PluginManager{
......
...@@ -102,7 +102,7 @@ func (s *UserAuthTokenService) CreateToken(ctx context.Context, userId int64, cl ...@@ -102,7 +102,7 @@ func (s *UserAuthTokenService) CreateToken(ctx context.Context, userId int64, cl
func (s *UserAuthTokenService) LookupToken(ctx context.Context, unhashedToken string) (*models.UserToken, error) { func (s *UserAuthTokenService) LookupToken(ctx context.Context, unhashedToken string) (*models.UserToken, error) {
hashedToken := hashToken(unhashedToken) hashedToken := hashToken(unhashedToken)
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
s.log.Debug("looking up token", "unhashed", unhashedToken, "hashed", hashedToken) s.log.Debug("looking up token", "unhashed", unhashedToken, "hashed", hashedToken)
} }
......
...@@ -64,7 +64,7 @@ func (rs *RenderingService) Init() error { ...@@ -64,7 +64,7 @@ func (rs *RenderingService) Init() error {
// RendererCallbackUrl has already been passed, it won't generate an error. // RendererCallbackUrl has already been passed, it won't generate an error.
u, _ := url.Parse(rs.Cfg.RendererCallbackUrl) u, _ := url.Parse(rs.Cfg.RendererCallbackUrl)
rs.domain = u.Hostname() rs.domain = u.Hostname()
case setting.HttpAddr != setting.DEFAULT_HTTP_ADDR: case setting.HttpAddr != setting.DefaultHTTPAddr:
rs.domain = setting.HttpAddr rs.domain = setting.HttpAddr
default: default:
rs.domain = "localhost" rs.domain = "localhost"
...@@ -227,9 +227,9 @@ func (rs *RenderingService) getURL(path string) string { ...@@ -227,9 +227,9 @@ func (rs *RenderingService) getURL(path string) string {
protocol := setting.Protocol protocol := setting.Protocol
switch setting.Protocol { switch setting.Protocol {
case setting.HTTP: case setting.HTTPScheme:
protocol = "http" protocol = "http"
case setting.HTTP2, setting.HTTPS: case setting.HTTP2Scheme, setting.HTTPSScheme:
protocol = "https" protocol = "https"
} }
......
...@@ -28,7 +28,7 @@ func TestGetUrl(t *testing.T) { ...@@ -28,7 +28,7 @@ func TestGetUrl(t *testing.T) {
t.Run("And protocol HTTP configured should return expected path", func(t *testing.T) { t.Run("And protocol HTTP configured should return expected path", func(t *testing.T) {
rs.Cfg.ServeFromSubPath = false rs.Cfg.ServeFromSubPath = false
rs.Cfg.AppSubUrl = "" rs.Cfg.AppSubUrl = ""
setting.Protocol = setting.HTTP setting.Protocol = setting.HTTPScheme
url := rs.getURL(path) url := rs.getURL(path)
require.Equal(t, "http://localhost:3000/"+path+"&render=1", url) require.Equal(t, "http://localhost:3000/"+path+"&render=1", url)
...@@ -43,7 +43,7 @@ func TestGetUrl(t *testing.T) { ...@@ -43,7 +43,7 @@ func TestGetUrl(t *testing.T) {
t.Run("And protocol HTTPS configured should return expected path", func(t *testing.T) { t.Run("And protocol HTTPS configured should return expected path", func(t *testing.T) {
rs.Cfg.ServeFromSubPath = false rs.Cfg.ServeFromSubPath = false
rs.Cfg.AppSubUrl = "" rs.Cfg.AppSubUrl = ""
setting.Protocol = setting.HTTPS setting.Protocol = setting.HTTPSScheme
url := rs.getURL(path) url := rs.getURL(path)
require.Equal(t, "https://localhost:3000/"+path+"&render=1", url) require.Equal(t, "https://localhost:3000/"+path+"&render=1", url)
}) })
...@@ -51,7 +51,7 @@ func TestGetUrl(t *testing.T) { ...@@ -51,7 +51,7 @@ func TestGetUrl(t *testing.T) {
t.Run("And protocol HTTP2 configured should return expected path", func(t *testing.T) { t.Run("And protocol HTTP2 configured should return expected path", func(t *testing.T) {
rs.Cfg.ServeFromSubPath = false rs.Cfg.ServeFromSubPath = false
rs.Cfg.AppSubUrl = "" rs.Cfg.AppSubUrl = ""
setting.Protocol = setting.HTTP2 setting.Protocol = setting.HTTP2Scheme
url := rs.getURL(path) url := rs.getURL(path)
require.Equal(t, "https://localhost:3000/"+path+"&render=1", url) require.Equal(t, "https://localhost:3000/"+path+"&render=1", url)
}) })
......
...@@ -26,34 +26,33 @@ import ( ...@@ -26,34 +26,33 @@ import (
type Scheme string type Scheme string
const ( const (
HTTP Scheme = "http" HTTPScheme Scheme = "http"
HTTPS Scheme = "https" HTTPSScheme Scheme = "https"
HTTP2 Scheme = "h2" HTTP2Scheme Scheme = "h2"
SOCKET Scheme = "socket" SocketScheme Scheme = "socket"
DEFAULT_HTTP_ADDR string = "0.0.0.0"
REDACTED_PASSWORD string = "*********"
) )
const ( const (
DEV = "development" redactedPassword = "*********"
PROD = "production" DefaultHTTPAddr = "0.0.0.0"
TEST = "test" Dev = "development"
APP_NAME = "Grafana" Prod = "production"
Test = "test"
) )
var ( var (
ERR_TEMPLATE_NAME = "error" ErrTemplateName = "error"
) )
// This constant corresponds to the default value for ldap_sync_ttl in .ini files // 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 // it is used for comparison and has to be kept in sync
const ( const (
AUTH_PROXY_SYNC_TTL = 60 AuthProxySyncTTL = 60
) )
var ( var (
// App settings. // App settings.
Env = DEV Env = Dev
AppUrl string AppUrl string
AppSubUrl string AppSubUrl string
ServeFromSubPath bool ServeFromSubPath bool
...@@ -371,7 +370,7 @@ func applyEnvVariableOverrides(file *ini.File) error { ...@@ -371,7 +370,7 @@ func applyEnvVariableOverrides(file *ini.File) error {
if len(envValue) > 0 { if len(envValue) > 0 {
key.SetValue(envValue) key.SetValue(envValue)
if shouldRedactKey(envKey) { if shouldRedactKey(envKey) {
envValue = REDACTED_PASSWORD envValue = redactedPassword
} }
if shouldRedactURLKey(envKey) { if shouldRedactURLKey(envKey) {
u, err := url.Parse(envValue) u, err := url.Parse(envValue)
...@@ -439,7 +438,7 @@ func applyCommandLineDefaultProperties(props map[string]string, file *ini.File) ...@@ -439,7 +438,7 @@ func applyCommandLineDefaultProperties(props map[string]string, file *ini.File)
if exists { if exists {
key.SetValue(value) key.SetValue(value)
if shouldRedactKey(keyString) { if shouldRedactKey(keyString) {
value = REDACTED_PASSWORD value = redactedPassword
} }
appliedCommandLineProperties = append(appliedCommandLineProperties, fmt.Sprintf("%s=%s", keyString, value)) appliedCommandLineProperties = append(appliedCommandLineProperties, fmt.Sprintf("%s=%s", keyString, value))
} }
...@@ -664,7 +663,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { ...@@ -664,7 +663,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
cfg.IsEnterprise = IsEnterprise cfg.IsEnterprise = IsEnterprise
cfg.Packaging = Packaging cfg.Packaging = Packaging
ApplicationName = APP_NAME ApplicationName = "Grafana"
Env = valueAsString(iniFile.Section(""), "app_mode", "development") Env = valueAsString(iniFile.Section(""), "app_mode", "development")
InstanceName = valueAsString(iniFile.Section(""), "instance_name", "unknown_instance_name") InstanceName = valueAsString(iniFile.Section(""), "instance_name", "unknown_instance_name")
...@@ -878,7 +877,7 @@ func (s *DynamicSection) Key(k string) *ini.Key { ...@@ -878,7 +877,7 @@ func (s *DynamicSection) Key(k string) *ini.Key {
key.SetValue(envValue) key.SetValue(envValue)
if shouldRedactKey(envKey) { if shouldRedactKey(envKey) {
envValue = REDACTED_PASSWORD envValue = redactedPassword
} }
s.Logger.Info("Config overridden from Environment variable", "var", fmt.Sprintf("%s=%s", envKey, envValue)) 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) { ...@@ -1015,7 +1014,7 @@ func readAuthSettings(iniFile *ini.File, cfg *Cfg) (err error) {
ldapSyncVal := authProxy.Key("ldap_sync_ttl").MustInt() ldapSyncVal := authProxy.Key("ldap_sync_ttl").MustInt()
syncVal := authProxy.Key("sync_ttl").MustInt() syncVal := authProxy.Key("sync_ttl").MustInt()
if ldapSyncVal != AUTH_PROXY_SYNC_TTL { if ldapSyncVal != AuthProxySyncTTL {
AuthProxySyncTtl = ldapSyncVal AuthProxySyncTtl = ldapSyncVal
cfg.Logger.Warn("[Deprecated] the configuration setting 'ldap_sync_ttl' is deprecated, please use 'sync_ttl' instead") cfg.Logger.Warn("[Deprecated] the configuration setting 'ldap_sync_ttl' is deprecated, please use 'sync_ttl' instead")
} else { } else {
...@@ -1128,26 +1127,26 @@ func readServerSettings(iniFile *ini.File, cfg *Cfg) error { ...@@ -1128,26 +1127,26 @@ func readServerSettings(iniFile *ini.File, cfg *Cfg) error {
cfg.AppSubUrl = AppSubUrl cfg.AppSubUrl = AppSubUrl
cfg.ServeFromSubPath = ServeFromSubPath cfg.ServeFromSubPath = ServeFromSubPath
Protocol = HTTP Protocol = HTTPScheme
protocolStr := valueAsString(server, "protocol", "http") protocolStr := valueAsString(server, "protocol", "http")
if protocolStr == "https" { if protocolStr == "https" {
Protocol = HTTPS Protocol = HTTPSScheme
CertFile = server.Key("cert_file").String() CertFile = server.Key("cert_file").String()
KeyFile = server.Key("cert_key").String() KeyFile = server.Key("cert_key").String()
} }
if protocolStr == "h2" { if protocolStr == "h2" {
Protocol = HTTP2 Protocol = HTTP2Scheme
CertFile = server.Key("cert_file").String() CertFile = server.Key("cert_file").String()
KeyFile = server.Key("cert_key").String() KeyFile = server.Key("cert_key").String()
} }
if protocolStr == "socket" { if protocolStr == "socket" {
Protocol = SOCKET Protocol = SocketScheme
SocketPath = server.Key("socket").String() SocketPath = server.Key("socket").String()
} }
Domain = valueAsString(server, "domain", "localhost") 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") HttpPort = valueAsString(server, "http_port", "3000")
RouterLogging = server.Key("router_logging").MustBool(false) RouterLogging = server.Key("router_logging").MustBool(false)
......
...@@ -153,7 +153,7 @@ func (e *AzureMonitorDatasource) buildQueries(queries []*tsdb.Query, timeRange * ...@@ -153,7 +153,7 @@ func (e *AzureMonitorDatasource) buildQueries(queries []*tsdb.Query, timeRange *
target = params.Encode() target = params.Encode()
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
azlog.Debug("Azuremonitor request", "params", params) azlog.Debug("Azuremonitor request", "params", params)
} }
......
...@@ -287,7 +287,7 @@ func (e *CloudMonitoringExecutor) buildQueries(tsdbQuery *tsdb.TsdbQuery) ([]*cl ...@@ -287,7 +287,7 @@ func (e *CloudMonitoringExecutor) buildQueries(tsdbQuery *tsdb.TsdbQuery) ([]*cl
sq.Target = target sq.Target = target
sq.Params = params sq.Params = params
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
slog.Debug("CloudMonitoring request", "params", params) slog.Debug("CloudMonitoring request", "params", params)
} }
......
...@@ -73,7 +73,7 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource, ...@@ -73,7 +73,7 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
formData["target"] = []string{target} formData["target"] = []string{target}
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
glog.Debug("Graphite request", "params", formData) glog.Debug("Graphite request", "params", formData)
} }
...@@ -122,7 +122,7 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource, ...@@ -122,7 +122,7 @@ func (e *GraphiteExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
Points: series.DataPoints, Points: series.DataPoints,
}) })
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
glog.Debug("Graphite response", "target", series.Target, "datapoints", len(series.DataPoints)) glog.Debug("Graphite response", "target", series.Target, "datapoints", len(series.DataPoints))
} }
} }
......
...@@ -64,7 +64,7 @@ func (e *InfluxDBExecutor) Query(ctx context.Context, dsInfo *models.DataSource, ...@@ -64,7 +64,7 @@ func (e *InfluxDBExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
return nil, err return nil, err
} }
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
glog.Debug("Influxdb query", "raw query", rawQuery) glog.Debug("Influxdb query", "raw query", rawQuery)
} }
......
...@@ -29,7 +29,7 @@ func newMssqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin ...@@ -29,7 +29,7 @@ func newMssqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin
if err != nil { if err != nil {
return nil, err return nil, err
} }
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
logger.Debug("getEngine", "connection", cnnstr) logger.Debug("getEngine", "connection", cnnstr)
} }
......
...@@ -57,7 +57,7 @@ func newMysqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin ...@@ -57,7 +57,7 @@ func newMysqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoin
cnnstr += "&tls=" + tlsConfigString cnnstr += "&tls=" + tlsConfigString
} }
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
logger.Debug("getEngine", "connection", cnnstr) logger.Debug("getEngine", "connection", cnnstr)
} }
......
...@@ -50,7 +50,7 @@ func (e *OpenTsdbExecutor) Query(ctx context.Context, dsInfo *models.DataSource, ...@@ -50,7 +50,7 @@ func (e *OpenTsdbExecutor) Query(ctx context.Context, dsInfo *models.DataSource,
tsdbQuery.Queries = append(tsdbQuery.Queries, metric) tsdbQuery.Queries = append(tsdbQuery.Queries, metric)
} }
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
plog.Debug("OpenTsdb request", "params", tsdbQuery) plog.Debug("OpenTsdb request", "params", tsdbQuery)
} }
......
...@@ -29,7 +29,7 @@ func newPostgresQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndp ...@@ -29,7 +29,7 @@ func newPostgresQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndp
return nil, err return nil, err
} }
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
logger.Debug("getEngine", "connection", cnnstr) logger.Debug("getEngine", "connection", cnnstr)
} }
......
...@@ -506,7 +506,7 @@ func (e *sqlQueryEndpoint) processRow(cfg *processCfg) error { ...@@ -506,7 +506,7 @@ func (e *sqlQueryEndpoint) processRow(cfg *processCfg) error {
series.Points = append(series.Points, tsdb.TimePoint{value, null.FloatFrom(timestamp)}) series.Points = append(series.Points, tsdb.TimePoint{value, null.FloatFrom(timestamp)})
if setting.Env == setting.DEV { if setting.Env == setting.Dev {
e.log.Debug("Rows", "metric", metric, "time", timestamp, "value", value) e.log.Debug("Rows", "metric", metric, "time", timestamp, "value", value)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment