mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-24 03:38:04 +00:00
* Start working on web server * Some restructure * Serving static works * Fix linter complaint * Enable local dev * Static files served fine * Tidy
51 lines
1017 B
Go
51 lines
1017 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/komodorio/helm-dashboard/pkg/dashboard"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/toqueteos/webbrowser"
|
|
"os"
|
|
)
|
|
|
|
var (
|
|
version = "dev"
|
|
commit = "none"
|
|
date = "unknown"
|
|
)
|
|
|
|
func main() {
|
|
setupLogging()
|
|
|
|
// TODO: proper command-line parsing
|
|
if len(os.Args) > 1 { // dirty thing to allow --help to work
|
|
os.Exit(0)
|
|
}
|
|
|
|
address, webServerDone := dashboard.StartServer()
|
|
|
|
if os.Getenv("HD_NOBROWSER") == "" {
|
|
log.Infof("Opening web UI: %s", address)
|
|
err := webbrowser.Open(address)
|
|
if err != nil {
|
|
log.Warnf("Failed to open Web browser for URL: %s", err)
|
|
}
|
|
} else {
|
|
log.Infof("Access web UI at: %s", address)
|
|
}
|
|
|
|
<-webServerDone
|
|
log.Infof("Done.")
|
|
}
|
|
|
|
func setupLogging() {
|
|
if os.Getenv("DEBUG") == "" {
|
|
log.SetLevel(log.InfoLevel)
|
|
gin.SetMode(gin.ReleaseMode)
|
|
} else {
|
|
log.SetLevel(log.DebugLevel)
|
|
gin.SetMode(gin.DebugMode)
|
|
}
|
|
log.Infof("Helm Dashboard by Komodor, version %s (%s @ %s)", version, commit, date)
|
|
}
|