diff --git a/.goreleaser.yml b/.goreleaser.yml index dff891a..2c09b14 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -3,7 +3,7 @@ builds: - main: ./main.go binary: helm-dashboard - ldflags: -s -w -X main.version={{.Version}} -X main.version={{.Version}} -X main.version={{.Version}} -X main.date={{.Date}} + ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} goos: - windows - darwin diff --git a/README.md b/README.md index 74d61ac..72d87f6 100644 --- a/README.md +++ b/README.md @@ -70,3 +70,4 @@ Adding new repository Recognise & show ArgoCD-originating charts/objects Have cleaner idea on the web API structure See if we can build in Chechov or Validkube validation +Show manifest/describe upon clicking on resource \ No newline at end of file diff --git a/pkg/dashboard/api.go b/pkg/dashboard/api.go index 19b7969..06b2c21 100644 --- a/pkg/dashboard/api.go +++ b/pkg/dashboard/api.go @@ -205,6 +205,23 @@ func configureKubectls(api *gin.Engine, data *DataLayer) { c.IndentedJSON(http.StatusOK, res) }) + + api.GET("/api/kube/describe/:kind", func(c *gin.Context) { + cName := c.Query("name") + cNamespace := c.Query("namespace") + if cName == "" { + _ = c.AbortWithError(http.StatusBadRequest, errors.New("missing required query string parameter: name")) + return + } + + res, err := data.DescribeResource(cNamespace, c.Param("kind"), cName) + if err != nil { + _ = c.AbortWithError(http.StatusInternalServerError, err) + return + } + + c.String(http.StatusOK, res) + }) } func configureStatic(api *gin.Engine) { diff --git a/pkg/dashboard/data.go b/pkg/dashboard/data.go index 2225127..8bd2a4d 100644 --- a/pkg/dashboard/data.go +++ b/pkg/dashboard/data.go @@ -317,6 +317,14 @@ func (d *DataLayer) GetResource(namespace string, def *GenericResource) (*Generi return &res, nil } +func (d *DataLayer) DescribeResource(namespace string, kind string, name string) (string, error) { + out, err := d.runCommandKubectl("describe", strings.ToLower(kind), name, "--namespace", namespace) + if err != nil { + return "", err + } + return out, nil +} + func RevisionDiff(functor SectionFn, ext string, namespace string, name string, revision1 int, revision2 int, flag bool) (string, error) { if revision1 == 0 || revision2 == 0 { log.Debugf("One of revisions is zero: %d %d", revision1, revision2) diff --git a/pkg/dashboard/static/index.html b/pkg/dashboard/static/index.html index f671174..c958593 100644 --- a/pkg/dashboard/static/index.html +++ b/pkg/dashboard/static/index.html @@ -123,7 +123,20 @@ +