Skip to content

Commit

Permalink
add env config
Browse files Browse the repository at this point in the history
Signed-off-by: mornyx <[email protected]>
  • Loading branch information
mornyx committed Sep 25, 2024
1 parent 8a0a952 commit 9a2853b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/dashboard/adapter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
package adapter

import (
"os"
"strings"

"github.com/pingcap/tidb-dashboard/pkg/config"

"github.com/tikv/pd/server"
)

const (
envTidbDashboardDisableCustomPromAddr = "TIDB_DASHBOARD_DISABLE_CUSTOM_PROM_ADDR"
)

// GenDashboardConfig generates a configuration for Dashboard Server.
func GenDashboardConfig(srv *server.Server) (*config.Config, error) {
cfg := srv.GetConfig()
Expand Down Expand Up @@ -47,5 +54,11 @@ func GenDashboardConfig(srv *server.Server) (*config.Config, error) {

dashboardCfg.NormalizePublicPathPrefix()

// Allow setting DisableCustomPromAddr via environment variable.
disableCustomPromAddr := strings.ToLower(os.Getenv(envTidbDashboardDisableCustomPromAddr))
if disableCustomPromAddr == "true" || disableCustomPromAddr == "1" {
dashboardCfg.DisableCustomPromAddr = true
}

return dashboardCfg, nil
}

0 comments on commit 9a2853b

Please sign in to comment.