mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-26 06:18:04 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2221fb22a0 | ||
|
|
9dc3e6a12d | ||
|
|
de0024cd03 | ||
|
|
ed4e970194 | ||
|
|
b0067e31ba | ||
|
|
7e8ba4709e | ||
|
|
be7b2642fc | ||
|
|
896d9e3f72 | ||
|
|
be6666373b | ||
|
|
91df9392c0 | ||
|
|
bd058ee912 | ||
|
|
997f951d0c |
@@ -42,9 +42,11 @@ To uninstall, run:
|
|||||||
helm plugin uninstall dashboard
|
helm plugin uninstall dashboard
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: In case standard Helm plugin way did not work for you, you can just download the appropriate [release package](https://github.com/komodorio/helm-dashboard/releases) for your platform, unpack it and just run `dashboard` binary from it.
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
To use the plugin, your machine needs to have working `helm` and also `kubectl` commands.
|
To use the plugin, your machine needs to have working `helm` and also `kubectl` commands. Helm version 3.4.0+ is required.
|
||||||
|
|
||||||
After installing, start the UI by running:
|
After installing, start the UI by running:
|
||||||
|
|
||||||
|
|||||||
85
go.mod
85
go.mod
@@ -3,122 +3,43 @@ module github.com/komodorio/helm-dashboard
|
|||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aquasecurity/trivy v0.32.1
|
|
||||||
github.com/gin-gonic/gin v1.8.1
|
github.com/gin-gonic/gin v1.8.1
|
||||||
|
github.com/hashicorp/go-version v1.6.0
|
||||||
github.com/hexops/gotextdiff v1.0.3
|
github.com/hexops/gotextdiff v1.0.3
|
||||||
|
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
|
||||||
github.com/sirupsen/logrus v1.9.0
|
github.com/sirupsen/logrus v1.9.0
|
||||||
github.com/toqueteos/webbrowser v1.2.0
|
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
helm.sh/helm/v3 v3.9.4
|
helm.sh/helm/v3 v3.9.4
|
||||||
k8s.io/apimachinery v0.25.0-alpha.2
|
k8s.io/apimachinery v0.25.0-alpha.2
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/CycloneDX/cyclonedx-go v0.6.0 // indirect
|
|
||||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
|
||||||
github.com/Masterminds/semver/v3 v3.1.1 // indirect
|
github.com/Masterminds/semver/v3 v3.1.1 // indirect
|
||||||
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
|
|
||||||
github.com/Sirupsen/logrus v1.0.6 // indirect
|
|
||||||
github.com/aquasecurity/go-dep-parser v0.0.0-20220928105313-d3a51fe400e4 // indirect
|
|
||||||
github.com/aquasecurity/table v1.8.0 // indirect
|
|
||||||
github.com/aquasecurity/trivy-db v0.0.0-20220627104749-930461748b63 // indirect
|
|
||||||
github.com/aquasecurity/trivy-kubernetes v0.3.1-0.20220823151349-b90b48958b91 // indirect
|
|
||||||
github.com/caarlos0/env/v6 v6.10.0 // indirect
|
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
|
||||||
github.com/docker/libnetwork v0.5.6 // indirect
|
|
||||||
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
|
|
||||||
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
|
|
||||||
github.com/fatih/color v1.13.0 // indirect
|
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||||
github.com/go-errors/errors v1.0.1 // indirect
|
|
||||||
github.com/go-logr/logr v1.2.3 // indirect
|
github.com/go-logr/logr v1.2.3 // indirect
|
||||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
|
||||||
github.com/go-openapi/jsonreference v0.20.0 // indirect
|
|
||||||
github.com/go-openapi/swag v0.22.3 // indirect
|
|
||||||
github.com/go-playground/locales v0.14.0 // indirect
|
github.com/go-playground/locales v0.14.0 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.11.0 // indirect
|
github.com/go-playground/validator/v10 v10.11.0 // indirect
|
||||||
github.com/goccy/go-json v0.9.11 // indirect
|
github.com/goccy/go-json v0.9.11 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/google/go-cmp v0.5.8 // indirect
|
||||||
github.com/google/btree v1.0.1 // indirect
|
|
||||||
github.com/google/gnostic v0.5.7-v3refs // indirect
|
|
||||||
github.com/google/go-containerregistry v0.11.0 // indirect
|
|
||||||
github.com/google/gofuzz v1.2.0 // indirect
|
github.com/google/gofuzz v1.2.0 // indirect
|
||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
|
||||||
github.com/google/uuid v1.3.0 // indirect
|
|
||||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
|
|
||||||
github.com/huandu/xstrings v1.3.2 // indirect
|
|
||||||
github.com/imdario/mergo v0.3.13 // indirect
|
|
||||||
github.com/in-toto/in-toto-golang v0.3.4-0.20220709202702-fa494aaa0add // indirect
|
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
|
||||||
github.com/josharian/intern v1.0.0 // indirect
|
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/knqyf263/go-rpm-version v0.0.0-20220614171824-631e686d1075 // indirect
|
|
||||||
github.com/leodido/go-urn v1.2.1 // indirect
|
github.com/leodido/go-urn v1.2.1 // indirect
|
||||||
github.com/liamg/tml v0.6.0 // indirect
|
|
||||||
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
|
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
|
||||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
|
||||||
github.com/mattn/go-isatty v0.0.16 // indirect
|
github.com/mattn/go-isatty v0.0.16 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
|
||||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
|
||||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
|
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
|
||||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
|
||||||
github.com/owenrumney/go-sarif/v2 v2.1.2 // indirect
|
|
||||||
github.com/package-url/packageurl-go v0.1.1-0.20220203205134-d70459300c8a // indirect
|
|
||||||
github.com/pelletier/go-toml/v2 v2.0.3 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.3 // indirect
|
||||||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
|
||||||
github.com/rivo/uniseg v0.2.0 // indirect
|
|
||||||
github.com/samber/lo v1.27.1 // indirect
|
|
||||||
github.com/secure-systems-lab/go-securesystemslib v0.4.0 // indirect
|
|
||||||
github.com/shibumi/go-pathspec v1.3.0 // indirect
|
|
||||||
github.com/shopspring/decimal v1.2.0 // indirect
|
|
||||||
github.com/spdx/tools-golang v0.3.0 // indirect
|
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
|
||||||
github.com/spf13/cobra v1.5.0 // indirect
|
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
|
||||||
github.com/stretchr/objx v0.4.0 // indirect
|
|
||||||
github.com/stretchr/testify v1.8.0 // indirect
|
|
||||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||||
github.com/vishvananda/netlink v1.1.0 // indirect
|
|
||||||
github.com/vishvananda/netns v0.0.0-20220913150850-18c4f4234207 // indirect
|
|
||||||
github.com/xlab/treeprint v1.1.0 // indirect
|
|
||||||
go.etcd.io/bbolt v1.3.6 // indirect
|
|
||||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
|
||||||
go.uber.org/atomic v1.9.0 // indirect
|
|
||||||
go.uber.org/multierr v1.8.0 // indirect
|
|
||||||
go.uber.org/zap v1.23.0 // indirect
|
|
||||||
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
|
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect
|
||||||
golang.org/x/exp v0.0.0-20220823124025-807a23277127 // indirect
|
|
||||||
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c // indirect
|
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c // indirect
|
||||||
golang.org/x/oauth2 v0.0.0-20220718184931-c8730f7fcb92 // indirect
|
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
|
|
||||||
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect
|
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect
|
||||||
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
|
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
|
|
||||||
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
|
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
|
||||||
google.golang.org/protobuf v1.28.1 // indirect
|
google.golang.org/protobuf v1.28.1 // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
k8s.io/api v0.25.0-alpha.2 // indirect
|
|
||||||
k8s.io/cli-runtime v0.24.4 // indirect
|
|
||||||
k8s.io/client-go v0.25.0-alpha.2 // indirect
|
|
||||||
k8s.io/klog/v2 v2.70.0 // indirect
|
k8s.io/klog/v2 v2.70.0 // indirect
|
||||||
k8s.io/kube-openapi v0.0.0-20220627174259-011e075b9cb8 // indirect
|
|
||||||
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
|
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
|
||||||
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
|
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
|
||||||
sigs.k8s.io/kustomize/api v0.11.4 // indirect
|
|
||||||
sigs.k8s.io/kustomize/kyaml v0.13.6 // indirect
|
|
||||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
|
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
|
||||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
|
||||||
)
|
)
|
||||||
|
|||||||
4
main.go
4
main.go
@@ -3,8 +3,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/komodorio/helm-dashboard/pkg/dashboard"
|
"github.com/komodorio/helm-dashboard/pkg/dashboard"
|
||||||
|
"github.com/pkg/browser"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/toqueteos/webbrowser"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ func main() {
|
|||||||
|
|
||||||
if os.Getenv("HD_NOBROWSER") == "" {
|
if os.Getenv("HD_NOBROWSER") == "" {
|
||||||
log.Infof("Opening web UI: %s", address)
|
log.Infof("Opening web UI: %s", address)
|
||||||
err := webbrowser.Open(address)
|
err := browser.OpenURL(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Failed to open Web browser for URL: %s", err)
|
log.Warnf("Failed to open Web browser for URL: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func contextSetter(data *subproc.DataLayer) gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRouter(abortWeb utils.ControlChan, data *subproc.DataLayer, version string) *gin.Engine {
|
func NewRouter(abortWeb utils.ControlChan, data *subproc.DataLayer) *gin.Engine {
|
||||||
var api *gin.Engine
|
var api *gin.Engine
|
||||||
if os.Getenv("DEBUG") == "" {
|
if os.Getenv("DEBUG") == "" {
|
||||||
api = gin.New()
|
api = gin.New()
|
||||||
@@ -58,12 +58,12 @@ func NewRouter(abortWeb utils.ControlChan, data *subproc.DataLayer, version stri
|
|||||||
api.Use(errorHandler)
|
api.Use(errorHandler)
|
||||||
|
|
||||||
configureStatic(api)
|
configureStatic(api)
|
||||||
configureRoutes(abortWeb, data, api, version)
|
configureRoutes(abortWeb, data, api)
|
||||||
|
|
||||||
return api
|
return api
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureRoutes(abortWeb utils.ControlChan, data *subproc.DataLayer, api *gin.Engine, version string) {
|
func configureRoutes(abortWeb utils.ControlChan, data *subproc.DataLayer, api *gin.Engine) {
|
||||||
// server shutdown handler
|
// server shutdown handler
|
||||||
api.DELETE("/", func(c *gin.Context) {
|
api.DELETE("/", func(c *gin.Context) {
|
||||||
abortWeb <- struct{}{}
|
abortWeb <- struct{}{}
|
||||||
@@ -71,7 +71,7 @@ func configureRoutes(abortWeb utils.ControlChan, data *subproc.DataLayer, api *g
|
|||||||
})
|
})
|
||||||
|
|
||||||
api.GET("/status", func(c *gin.Context) {
|
api.GET("/status", func(c *gin.Context) {
|
||||||
c.String(http.StatusOK, version)
|
c.IndentedJSON(http.StatusOK, data.VersionInfo)
|
||||||
})
|
})
|
||||||
|
|
||||||
configureHelms(api.Group("/api/helm"), data)
|
configureHelms(api.Group("/api/helm"), data)
|
||||||
|
|||||||
@@ -248,11 +248,11 @@ func handleGetSection(data *subproc.DataLayer, section string, rDiff string, qp
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
} else {
|
}
|
||||||
|
|
||||||
res, err := functor(qp.Namespace, qp.Name, qp.Revision, flag)
|
res, err := functor(qp.Namespace, qp.Name, qp.Revision, flag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type ScannersHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *ScannersHandler) List(c *gin.Context) {
|
func (h *ScannersHandler) List(c *gin.Context) {
|
||||||
var res []string
|
res := make([]string, 0)
|
||||||
for _, scanner := range h.Data.Scanners {
|
for _, scanner := range h.Data.Scanners {
|
||||||
res = append(res, scanner.Name())
|
res = append(res, scanner.Name())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,16 @@ package dashboard
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/hashicorp/go-version"
|
||||||
"github.com/komodorio/helm-dashboard/pkg/dashboard/scanners"
|
"github.com/komodorio/helm-dashboard/pkg/dashboard/scanners"
|
||||||
"github.com/komodorio/helm-dashboard/pkg/dashboard/subproc"
|
"github.com/komodorio/helm-dashboard/pkg/dashboard/subproc"
|
||||||
"github.com/komodorio/helm-dashboard/pkg/dashboard/utils"
|
"github.com/komodorio/helm-dashboard/pkg/dashboard/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func StartServer(version string) (string, utils.ControlChan) {
|
func StartServer(version string) (string, utils.ControlChan) {
|
||||||
@@ -19,6 +22,9 @@ func StartServer(version string) (string, utils.ControlChan) {
|
|||||||
os.Exit(1) // TODO: propagate error instead?
|
os.Exit(1) // TODO: propagate error instead?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.VersionInfo = &subproc.VersionInfo{CurVer: version}
|
||||||
|
go checkUpgrade(data.VersionInfo)
|
||||||
|
|
||||||
discoverScanners(&data)
|
discoverScanners(&data)
|
||||||
|
|
||||||
address := os.Getenv("HD_BIND")
|
address := os.Getenv("HD_BIND")
|
||||||
@@ -33,7 +39,7 @@ func StartServer(version string) (string, utils.ControlChan) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abort := make(utils.ControlChan)
|
abort := make(utils.ControlChan)
|
||||||
api := NewRouter(abort, &data, version)
|
api := NewRouter(abort, &data)
|
||||||
done := startBackgroundServer(address, api, abort)
|
done := startBackgroundServer(address, api, abort)
|
||||||
|
|
||||||
return "http://" + address, done
|
return "http://" + address, done
|
||||||
@@ -75,3 +81,44 @@ func discoverScanners(data *subproc.DataLayer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkUpgrade(d *subproc.VersionInfo) {
|
||||||
|
url := "https://api.github.com/repos/komodorio/helm-dashboard/releases/latest"
|
||||||
|
type GHRelease struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var myClient = &http.Client{Timeout: 5 * time.Second}
|
||||||
|
r, err := myClient.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to check for new version: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer r.Body.Close()
|
||||||
|
|
||||||
|
target := new(GHRelease)
|
||||||
|
err = json.NewDecoder(r.Body).Decode(target)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to decode new release version: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
d.LatestVer = target.Name
|
||||||
|
|
||||||
|
v1, err := version.NewVersion(d.CurVer)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to parse version: %s", err)
|
||||||
|
v1 = &version.Version{}
|
||||||
|
}
|
||||||
|
|
||||||
|
v2, err := version.NewVersion(d.LatestVer)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Failed to parse version: %s", err)
|
||||||
|
} else {
|
||||||
|
if v1.LessThan(v2) {
|
||||||
|
log.Warnf("Newer Helm Dashboard version is available: %s", d.LatestVer)
|
||||||
|
log.Warnf("Upgrade instructions: https://github.com/komodorio/helm-dashboard#installing")
|
||||||
|
} else {
|
||||||
|
log.Debugf("Got latest version from GH: %s", d.LatestVer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ $("#upgradeModal .btn-confirm").click(function () {
|
|||||||
}).done(function (data) {
|
}).done(function (data) {
|
||||||
if (data.version) {
|
if (data.version) {
|
||||||
setHashParam("section", null)
|
setHashParam("section", null)
|
||||||
setHashParam("namespace", $("#upgradeModal .rel-ns").val())
|
const ns = $("#upgradeModal .rel-ns").val();
|
||||||
|
setHashParam("namespace", ns ? ns : "default")
|
||||||
setHashParam("chart", $("#upgradeModal .rel-name").val())
|
setHashParam("chart", $("#upgradeModal .rel-name").val())
|
||||||
setHashParam("revision", data.version)
|
setHashParam("revision", data.version)
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
})(window,document,'script','https://www.datadoghq-browser-agent.com/datadog-rum-v4.js','DD_RUM')
|
})(window,document,'script','https://www.datadoghq-browser-agent.com/datadog-rum-v4.js','DD_RUM')
|
||||||
DD_RUM.onReady(function() {
|
DD_RUM.onReady(function() {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onload = function() {
|
||||||
const version = xhr.responseText;
|
const version = JSON.parse(xhr.responseText).VerCur;
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE && version!=="dev") {
|
if (xhr.readyState === XMLHttpRequest.DONE && version!=="dev") {
|
||||||
DD_RUM.init({
|
DD_RUM.init({
|
||||||
clientToken: 'pub16d64cd1c00cf073ce85af914333bf72',
|
clientToken: 'pub16d64cd1c00cf073ce85af914333bf72',
|
||||||
|
|||||||
@@ -53,14 +53,38 @@
|
|||||||
<li class="nav-item mx-2">
|
<li class="nav-item mx-2">
|
||||||
<a class="nav-link px-3 section-repo">Repository</a>
|
<a class="nav-link px-3 section-repo">Repository</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown"
|
||||||
|
aria-expanded="false">
|
||||||
|
<span class="position-absolute top-50 start-0 translate-middle p-1 bg-danger border border-light rounded-circle new-version-pill display-none">
|
||||||
|
<span class="visually-hidden">New version</span>
|
||||||
|
</span>
|
||||||
|
Help
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu fs-80">
|
||||||
|
<li><a class="dropdown-item" href="https://komodorkommunity.slack.com/archives/C044U1B0265"
|
||||||
|
target="_blank"><i class="bi-slack"></i> Support Chat</a></li>
|
||||||
|
<li><a class="dropdown-item" href="https://github.com/komodorio/helm-dashboard" target="_blank"><i
|
||||||
|
class="bi-github"></i> Project Page</a></li>
|
||||||
|
<li>
|
||||||
|
<hr class="dropdown-divider">
|
||||||
|
</li>
|
||||||
|
<li><a class="dropdown-item disabled" href="#">Version <span id="toolVersion"></span></a></li>
|
||||||
|
<li class="">
|
||||||
|
<a class="dropdown-item position-relative" href="https://github.com/komodorio/helm-dashboard#installing" target="_blank">
|
||||||
|
<span class="position-absolute top-50 start-0 translate-middle p-1 bg-danger border border-light rounded-circle new-version-pill display-none">
|
||||||
|
<span class="visually-hidden">New version</span>
|
||||||
|
</span>
|
||||||
|
Upgrade to <span id="toolVersionUpgrade"></span>
|
||||||
|
</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<div>
|
<div>
|
||||||
<a class="btn" href="https://komodor.com/?utm_campaign=Helm-Dash&utm_source=helm-dash"><img
|
<a class="btn" href="https://komodor.com/?utm_campaign=Helm-Dash&utm_source=helm-dash"><img
|
||||||
src="https://komodor.com/wp-content/uploads/2021/05/favicon.png" alt="komodor.io"
|
src="static/komodor-logo.svg" alt="komodor.io"
|
||||||
style="height: 1.2rem; vertical-align: text-bottom; filter: grayscale(00%);"></a>
|
style="height: 1.2rem; vertical-align: text-bottom; filter: grayscale(00%);"></a>
|
||||||
|
|
||||||
<a class="btn me-2 text-muted" href="https://github.com/komodorio/helm-dashboard"
|
|
||||||
title="Project page on GitHub"><i class="bi-github"></i></a>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="separator-vertical"><span></span></div>
|
<div class="separator-vertical"><span></span></div>
|
||||||
<i class="btn bi-power text-muted p-2 m-1 mx-2" title="Shut down the Helm Dashboard application"></i>
|
<i class="btn bi-power text-muted p-2 m-1 mx-2" title="Shut down the Helm Dashboard application"></i>
|
||||||
@@ -147,6 +171,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="body"></div>
|
<div class="body"></div>
|
||||||
|
<div class="bg-white rounded shadow p-3 display-none no-charts">Looks like you don't have any charts
|
||||||
|
installed. "Repository" section may be a good place to start.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- /INSTALLED LIST -->
|
<!-- /INSTALLED LIST -->
|
||||||
</div>
|
</div>
|
||||||
@@ -251,6 +278,9 @@
|
|||||||
data-mode="diff-rev">
|
data-mode="diff-rev">
|
||||||
Diff with specific revision: <input class="form-input" size="3" id="specRev">
|
Diff with specific revision: <input class="form-input" size="3" id="specRev">
|
||||||
</label>
|
</label>
|
||||||
|
<label class="form-check-label" for="userDefinedVals">
|
||||||
|
<input class="form-check-input" type="checkbox" id="userDefinedVals"> User-defined only
|
||||||
|
</label>
|
||||||
</form>
|
</form>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ function loadChartsList() {
|
|||||||
let card = buildChartCard(elm);
|
let card = buildChartCard(elm);
|
||||||
chartsCards.append(card)
|
chartsCards.append(card)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!data.length) {
|
||||||
|
$("#installedList .no-charts").show()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ $(function () {
|
|||||||
$("#upgradeModal .btn-scan").hide()
|
$("#upgradeModal .btn-scan").hide()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$.getJSON("/status").fail(function (xhr) {
|
||||||
|
reportError("Failed to get tool version", xhr)
|
||||||
|
}).done(function (data) {
|
||||||
|
fillToolVersion(data)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function initView() {
|
function initView() {
|
||||||
@@ -45,18 +51,20 @@ function initView() {
|
|||||||
$("#topNav ul a").click(function () {
|
$("#topNav ul a").click(function () {
|
||||||
const self = $(this)
|
const self = $(this)
|
||||||
|
|
||||||
|
if (self.hasClass("section-repo")) {
|
||||||
|
setHashParam("section", "repository")
|
||||||
|
} else if (self.hasClass("section-installed")) {
|
||||||
|
setHashParam("section", null)
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
$("#topNav ul a").removeClass("active")
|
$("#topNav ul a").removeClass("active")
|
||||||
|
|
||||||
const ctx = getHashParam("context")
|
const ctx = getHashParam("context")
|
||||||
setHashParam(null, null)
|
setHashParam(null, null)
|
||||||
setHashParam("context", ctx)
|
setHashParam("context", ctx)
|
||||||
|
|
||||||
if (self.hasClass("section-repo")) {
|
|
||||||
setHashParam("section", "repository")
|
|
||||||
} else {
|
|
||||||
setHashParam("section", null)
|
|
||||||
}
|
|
||||||
|
|
||||||
initView()
|
initView()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -186,6 +194,14 @@ $(".bi-power").click(function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function isNewerVersion(oldVer, newVer) {
|
function isNewerVersion(oldVer, newVer) {
|
||||||
|
if (oldVer && oldVer[0] === 'v') {
|
||||||
|
oldVer = oldVer.substring(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newVer && newVer[0] === 'v') {
|
||||||
|
newVer = newVer.substring(1)
|
||||||
|
}
|
||||||
|
|
||||||
const oldParts = oldVer.split('.')
|
const oldParts = oldVer.split('.')
|
||||||
const newParts = newVer.split('.')
|
const newParts = newVer.split('.')
|
||||||
for (let i = 0; i < newParts.length; i++) {
|
for (let i = 0; i < newParts.length; i++) {
|
||||||
@@ -196,3 +212,11 @@ function isNewerVersion(oldVer, newVer) {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fillToolVersion(data) {
|
||||||
|
$("#toolVersion").text(data.CurVer)
|
||||||
|
if (isNewerVersion(data.CurVer, data.LatestVer)) {
|
||||||
|
$("#toolVersionUpgrade").text(data.LatestVer)
|
||||||
|
$(".new-version-pill").show()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,6 +76,10 @@
|
|||||||
min-width: 60%;
|
min-width: 60%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fs-80 {
|
||||||
|
font-size: 0.8rem!important;
|
||||||
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ type DataLayer struct {
|
|||||||
Helm string
|
Helm string
|
||||||
Kubectl string
|
Kubectl string
|
||||||
Scanners []Scanner
|
Scanners []Scanner
|
||||||
|
VersionInfo *VersionInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
type VersionInfo struct {
|
||||||
|
CurVer string
|
||||||
|
LatestVer string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataLayer) runCommand(cmd ...string) (string, error) {
|
func (d *DataLayer) runCommand(cmd ...string) (string, error) {
|
||||||
|
|||||||
96
pkg/dashboard/utils/utils_test.go
Normal file
96
pkg/dashboard/utils/utils_test.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetQueryProps(t *testing.T) {
|
||||||
|
gin.SetMode(gin.TestMode)
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
endpoint string
|
||||||
|
revRequired bool
|
||||||
|
wantErr bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Get query props - all set with revRequired true",
|
||||||
|
wantErr: false,
|
||||||
|
revRequired: true,
|
||||||
|
endpoint: "/api/v1/namespaces/komodorio/charts?name=testing&namespace=testing&revision=1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Get query props - no revision with revRequired true",
|
||||||
|
wantErr: true,
|
||||||
|
revRequired: true,
|
||||||
|
endpoint: "/api/v1/namespaces/komodorio/charts?name=testing&namespace=testing",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Get query props - no namespace with revRequired true",
|
||||||
|
wantErr: false,
|
||||||
|
revRequired: true,
|
||||||
|
endpoint: "/api/v1/namespaces/komodorio/charts?name=testing&revision=1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Get query props - no name with revRequired true",
|
||||||
|
wantErr: true,
|
||||||
|
revRequired: true,
|
||||||
|
endpoint: "/api/v1/namespaces/komodorio/charts?namespace=testing&revision=1",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
c, _ := gin.CreateTestContext(w)
|
||||||
|
c.Request = httptest.NewRequest("GET", tt.endpoint, nil)
|
||||||
|
_, err := GetQueryProps(c, tt.revRequired)
|
||||||
|
if (err != nil) != tt.wantErr {
|
||||||
|
t.Errorf("GetQueryProps() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestChartAndVersion(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
params string
|
||||||
|
wantChart string
|
||||||
|
wantVer string
|
||||||
|
wantError bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Chart and version - successfully parsing chart and version",
|
||||||
|
params: "chart-1.0.0",
|
||||||
|
wantChart: "chart",
|
||||||
|
wantVer: "1.0.0",
|
||||||
|
wantError: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Chart and version - parsing chart without version",
|
||||||
|
params: "chart",
|
||||||
|
wantError: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
a, b, err := ChartAndVersion(tt.params)
|
||||||
|
if (err != nil) != tt.wantError {
|
||||||
|
t.Errorf("ChartAndVersion() error = %v, wantErr %v", err, tt.wantError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if a != tt.wantChart {
|
||||||
|
t.Errorf("ChartAndVersion() got = %v, want %v", a, tt.wantChart)
|
||||||
|
}
|
||||||
|
|
||||||
|
if b != tt.wantVer {
|
||||||
|
t.Errorf("ChartAndVersion() got1 = %v, want %v", b, tt.wantVer)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
name: "dashboard"
|
name: "dashboard"
|
||||||
version: "0.2.0"
|
version: "0.2.1"
|
||||||
usage: "A simplified way of working with Helm"
|
usage: "A simplified way of working with Helm"
|
||||||
description: "View HELM situation in nice web UI"
|
description: "View HELM situation in nice web UI"
|
||||||
command: "$HELM_PLUGIN_DIR/bin/helm-dashboard"
|
command: "$HELM_PLUGIN_DIR/bin/helm-dashboard"
|
||||||
|
|||||||
Reference in New Issue
Block a user