forked from tikv/pd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update tidb-dashboard to 2021.12.31.1 (tikv#4502)
ref tikv#4257 support dynamic distro res make `DASHBOARD=COMPILE make pd-server` works Signed-off-by: baurine <[email protected]>
- Loading branch information
Showing
16 changed files
with
267 additions
and
203 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2021 TiKV Project Authors. | ||
// | ||
// 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 distroutil | ||
|
||
import ( | ||
"os" | ||
"path" | ||
|
||
"github.com/pingcap/log" | ||
"github.com/pingcap/tidb-dashboard/util/distro" | ||
"go.uber.org/zap" | ||
) | ||
|
||
const ( | ||
resFolderName string = "distro-res" | ||
stringsFileName string = "strings.json" | ||
) | ||
|
||
// MustGetResPath returns the default path that a distribution resource should be placed, | ||
// which is the ${BinaryPath}/distro-res. | ||
func MustGetResPath() string { | ||
exePath, err := os.Executable() | ||
if err != nil { | ||
log.Fatal("Failed to read the execution path", zap.Error(err)) | ||
return "" | ||
} | ||
return path.Join(path.Dir(exePath), resFolderName) | ||
} | ||
|
||
// MustLoadAndReplaceStrings loads the distro strings from ${BinaryPath}/distro-res/strings.json | ||
// and replace the strings in the TiDB Dashboard. If the strings file does not exist, the default | ||
// distro string will be used. | ||
func MustLoadAndReplaceStrings() { | ||
resPath := MustGetResPath() | ||
strings, err := distro.ReadResourceStringsFromFile(path.Join(resPath, stringsFileName)) | ||
if err != nil { | ||
log.Fatal("Failed to load distro strings", zap.Error(err)) | ||
} | ||
log.Info("Using distribution strings", zap.Any("strings", strings)) | ||
distro.ReplaceGlobal(strings) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters