mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-24 11:48:04 +00:00
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -149,10 +150,10 @@ func (h *HelmHandler) Resources(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
info, err := app.K8s.GetResourceInfo(obj.Kind, ns, obj.Name)
|
info, err := app.K8s.GetResourceInfo(obj.Kind, ns, obj.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
log.Warnf("Failed to get resource info for %s %s/%s: %+v", obj.Name, ns, obj.Name, err)
|
||||||
return
|
info = &v1.Carp{}
|
||||||
}
|
}
|
||||||
obj.Status = *EnhanceStatus(info)
|
obj.Status = *EnhanceStatus(info, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,12 +56,12 @@ func (h *KubeHandler) GetResourceInfo(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
EnhanceStatus(res)
|
EnhanceStatus(res, nil)
|
||||||
|
|
||||||
c.IndentedJSON(http.StatusOK, res)
|
c.IndentedJSON(http.StatusOK, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EnhanceStatus(res *v12.Carp) *v12.CarpStatus {
|
func EnhanceStatus(res *v12.Carp, err error) *v12.CarpStatus {
|
||||||
s := res.Status
|
s := res.Status
|
||||||
if s.Conditions == nil {
|
if s.Conditions == nil {
|
||||||
s.Conditions = []v12.CarpCondition{}
|
s.Conditions = []v12.CarpCondition{}
|
||||||
@@ -75,7 +75,10 @@ func EnhanceStatus(res *v12.Carp) *v12.CarpStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// custom logic to provide most meaningful status for the resource
|
// custom logic to provide most meaningful status for the resource
|
||||||
if s.Phase == "Error" {
|
if err != nil {
|
||||||
|
c.Reason = "ErrorGettingStatus"
|
||||||
|
c.Message = err.Error()
|
||||||
|
} else if s.Phase == "Error" {
|
||||||
c.Status = Unhealthy
|
c.Status = Unhealthy
|
||||||
} else if slices.Contains([]string{"Available", "Active", "Established", "Bound", "Ready"}, string(s.Phase)) {
|
} else if slices.Contains([]string{"Available", "Active", "Established", "Bound", "Ready"}, string(s.Phase)) {
|
||||||
c.Status = Healthy
|
c.Status = Healthy
|
||||||
|
|||||||
@@ -188,7 +188,9 @@ function showResources(namespace, chart, revision) {
|
|||||||
const cond = res.status.conditions[k]
|
const cond = res.status.conditions[k]
|
||||||
|
|
||||||
const badge = $("<span class='badge me-2 fw-normal'></span>").text(cond.reason);
|
const badge = $("<span class='badge me-2 fw-normal'></span>").text(cond.reason);
|
||||||
if (cond.status === "Healthy") {
|
if (cond.status === "Unknown") {
|
||||||
|
badge.addClass("bg-secondary text-danger")
|
||||||
|
} else if (cond.status === "Healthy") {
|
||||||
badge.addClass("bg-success text-dark")
|
badge.addClass("bg-success text-dark")
|
||||||
} else if (cond.status === "Progressing") {
|
} else if (cond.status === "Progressing") {
|
||||||
badge.addClass("bg-warning")
|
badge.addClass("bg-warning")
|
||||||
|
|||||||
Reference in New Issue
Block a user