Skip to content

Commit

Permalink
tweak: add fallback to keep compatibility in scenarios without inject…
Browse files Browse the repository at this point in the history
… distro info (pingcap#976)
  • Loading branch information
shhdgit committed Sep 2, 2021
1 parent 29034af commit fa64d96
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
1 change: 0 additions & 1 deletion cmd/tidb-dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import (
keyvisualregion "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region"
"github.com/pingcap/tidb-dashboard/pkg/swaggerserver"
"github.com/pingcap/tidb-dashboard/pkg/uiserver"
_ "github.com/pingcap/tidb-dashboard/pkg/utils/distro/populate"
"github.com/pingcap/tidb-dashboard/pkg/utils/version"
)

Expand Down
11 changes: 10 additions & 1 deletion pkg/utils/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ func Replace(distro introData) {
}

func Data(k string) string {
d := data.Load().(introData)
var d introData
atomd := data.Load()
// we need a fallback to keep compatibility in scenarios without inject distro info
// related issue: https://github.com/pingcap/tidb-dashboard/issues/975
if d == nil {
d = Resource
} else {
d = atomd.(introData)
}

if d[k] == "" {
return k
}
Expand Down
21 changes: 0 additions & 21 deletions pkg/utils/distro/populate/populate.go

This file was deleted.

0 comments on commit fa64d96

Please sign in to comment.