mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-24 11:48:04 +00:00
Show describe modal (#7)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -123,7 +123,20 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal" id="describeModal"
|
||||
tabindex="-1" aria-labelledby="describeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog modal-dialog-scrollable modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="describeModalLabel"></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body" id="describeModalBody">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa"
|
||||
|
||||
@@ -341,9 +341,12 @@ function showResources(namespace, chart, revision) {
|
||||
badge.addClass("bg-danger")
|
||||
}
|
||||
|
||||
resBlock.find(".form-control").empty().append(badge).append("<span class='text-muted small'>" + (data.status.message ? data.status.message : '') + "</span>")
|
||||
})
|
||||
resBlock.find(".form-control.col-sm-4").empty().append(badge).append("<span class='text-muted small'>" + (data.status.message ? data.status.message : '') + "</span>").prepend("<i class=\"btn fa fa-search-plus float-end text-muted\"></i>")
|
||||
|
||||
resBlock.find(".fa-search-plus").click(function () {
|
||||
showDescribe(ns, res.kind, res.metadata.name)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -357,3 +360,17 @@ $(".fa-power-off").click(function () {
|
||||
window.close();
|
||||
})
|
||||
})
|
||||
|
||||
function showDescribe(ns, kind, name) {
|
||||
$("#describeModalLabel").text("Describe " + kind + ": " + ns + " / " + name)
|
||||
$("#describeModalBody").empty().append("<i class='fa fa-spin fa-spinner fa-2x'></i>")
|
||||
|
||||
const myModal = new bootstrap.Modal(document.getElementById('describeModal'), {});
|
||||
myModal.show()
|
||||
$.get("/api/kube/describe/" + kind.toLowerCase() + "?name=" + name + "&namespace=" + ns).fail(function () {
|
||||
reportError("Failed to describe resource")
|
||||
}).done(function (data) {
|
||||
data = hljs.highlight(data, {language: 'yaml'}).value
|
||||
$("#describeModalBody").empty().append("<pre class='bg-white rounded p-3'></pre>").find("pre").html(data)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user