Skip to content

Commit

Permalink
Update dashboard to v2021.12.30.1, ref #4257
Browse files Browse the repository at this point in the history
support dynamic distro res

Signed-off-by: baurine <[email protected]>
  • Loading branch information
baurine committed Dec 30, 2021
1 parent ae23d40 commit 6254c89
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 95 deletions.
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ require (
github.com/pingcap/errors v0.11.5-0.20201126102027-b0a155152ca3
github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce
github.com/pingcap/kvproto v0.0.0-20211213085605-3329b3c5404c
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7
github.com/pingcap/log v0.0.0-20210906054005-afc726e70354
github.com/pingcap/sysutil v0.0.0-20211208032423-041a72e5860d
github.com/pingcap/tidb-dashboard v0.0.0-20211206031355-bcc43a01d537
github.com/pingcap/tidb-dashboard v0.0.0-20211230072508-b2c4a0435690
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/common v0.6.0
github.com/sasha-s/go-deadlock v0.2.0
github.com/sirupsen/logrus v1.2.0
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba
Expand All @@ -50,8 +50,9 @@ require (
go.etcd.io/bbolt v1.3.5 // indirect
go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738
go.uber.org/goleak v1.1.12
go.uber.org/zap v1.16.0
go.uber.org/zap v1.19.0
golang.org/x/tools v0.1.5
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/grpc v1.26.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gotest.tools/gotestsum v1.7.0
Expand Down
221 changes: 153 additions & 68 deletions go.sum

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pkg/dashboard/adapter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func GenDashboardConfig(srv *server.Server) (*config.Config, error) {
dashboardCfg.PublicPathPrefix = cfg.Dashboard.PublicPathPrefix
dashboardCfg.EnableTelemetry = cfg.Dashboard.EnableTelemetry
dashboardCfg.EnableExperimental = cfg.Dashboard.EnableExperimental
dashboardCfg.EnableNonRootLogin = true
if dashboardCfg.ClusterTLSConfig, err = cfg.Security.ToTLSConfig(); err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/dashboard/distro/.gitignore

This file was deleted.

41 changes: 36 additions & 5 deletions pkg/dashboard/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,46 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build dashboard_distro
// +build dashboard_distro

package distro

import (
"github.com/pingcap/tidb-dashboard/pkg/utils/distro"
"os"
"path"

"github.com/pingcap/log"
"github.com/pingcap/tidb-dashboard/util/distro"
"go.uber.org/zap"
)

func init() {
distro.Replace(Resource)
loadDistroStringsRes()
}

const (
distroResFolderName string = "distro-res"
distroStringsResFileName string = "strings.json"
)

func GetDistroResFolderPath() (string, error) {
exePath, err := os.Executable()
if err != nil {
return "", err
}

return path.Join(path.Dir(exePath), distroResFolderName), nil
}

func loadDistroStringsRes() {
distroResFolderPath, err := GetDistroResFolderPath()
if err != nil {
log.Fatal("Failed to get distro res folder full path", zap.Error(err))
}

distroStringsResPath := path.Join(distroResFolderPath, distroStringsResFileName)
distroStringsRes, err := distro.ReadResourceStringsFromFile(distroStringsResPath)
if err != nil {
log.Fatal("Failed to load distro strings res", zap.Error(err))
}

distro.ReplaceGlobal(distroStringsRes)
}
15 changes: 0 additions & 15 deletions pkg/dashboard/distro/placeholder.go

This file was deleted.

10 changes: 9 additions & 1 deletion pkg/dashboard/uiserver/embedded_assets_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,24 @@ import (
"sync"
"time"

"github.com/pingcap/log"
"github.com/pingcap/tidb-dashboard/pkg/config"
"github.com/pingcap/tidb-dashboard/pkg/uiserver"
"github.com/tikv/pd/pkg/dashboard/distro"
"go.uber.org/zap"
)

var once sync.Once

// Assets returns the Assets FileSystem of the dashboard UI
func Assets(cfg *config.Config) http.FileSystem {
once.Do(func() {
uiserver.RewriteAssets(assets, cfg, func(fs http.FileSystem, f http.File, path, newContent string, bs []byte) {
distroResFolderPath, err := distro.GetDistroResFolderPath()
if err != nil {
log.Fatal("Failed to get distro res folder full path", zap.Error(err))
}

uiserver.RewriteAssets(assets, cfg, distroResFolderPath, func(fs http.FileSystem, f http.File, path, newContent string, bs []byte) {
m := fs.(vfsgen۰FS)
fi := f.(os.FileInfo)
m[path] = &vfsgen۰CompressedFileInfo{
Expand Down

0 comments on commit 6254c89

Please sign in to comment.