diff --git a/cmd/tidb-dashboard/main.go b/cmd/tidb-dashboard/main.go index d20f417fb2..f0be488058 100644 --- a/cmd/tidb-dashboard/main.go +++ b/cmd/tidb-dashboard/main.go @@ -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" ) diff --git a/pkg/utils/distro/distro.go b/pkg/utils/distro/distro.go index 4404a6e43d..8181fe72ee 100644 --- a/pkg/utils/distro/distro.go +++ b/pkg/utils/distro/distro.go @@ -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 } diff --git a/pkg/utils/distro/populate/populate.go b/pkg/utils/distro/populate/populate.go deleted file mode 100644 index 6c76cf84c0..0000000000 --- a/pkg/utils/distro/populate/populate.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2021 PingCAP, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package populate - -import "github.com/pingcap/tidb-dashboard/pkg/utils/distro" - -func init() { - distro.Replace(distro.Resource) -}