Display resource health aggregate icons on list of releases (#235)

* Display aggregate resource health status

* Reuse old API request, show icons

* Take progress indication from deployment conditions

* Improve status

* Cleanup

* Fixups

* Squares approach
This commit is contained in:
Andrey Pokhilko
2023-03-13 12:56:31 +00:00
committed by GitHub
parent 47dae4d35a
commit 57d4d073e9
7 changed files with 175 additions and 51 deletions

View File

@@ -136,6 +136,26 @@ func (h *HelmHandler) Resources(c *gin.Context) {
return
}
if c.Query("health") != "" { // we need to query k8s for health status
app := h.GetApp(c)
if app == nil {
_ = c.AbortWithError(http.StatusInternalServerError, err)
return
}
for _, obj := range res {
ns := obj.Namespace
if ns == "" {
ns = c.Param("ns")
}
info, err := app.K8s.GetResourceInfo(obj.Kind, ns, obj.Name)
if err != nil {
_ = c.AbortWithError(http.StatusInternalServerError, err)
return
}
obj.Status = *EnhanceStatus(info)
}
}
c.IndentedJSON(http.StatusOK, res)
}
@@ -587,23 +607,24 @@ func (h *HelmHandler) repoFromArtifactHub(name string) (string, error) {
return true
}
// more popular
if ri.Stars != rj.Stars {
return ri.Stars > rj.Stars
}
// or from verified publishers
if ri.Repository.VerifiedPublisher && !rj.Repository.VerifiedPublisher {
return true
}
// or just more popular
if ri.Stars > rj.Stars {
return true
}
// or with more recent app version
if semver.Compare("v"+ri.AppVersion, "v"+rj.AppVersion) > 0 {
return true
c := semver.Compare("v"+ri.AppVersion, "v"+rj.AppVersion)
if c != 0 {
return c > 0
}
return false
// shorter repo name is usually closer to officials
return len(ri.Repository.Name) < len(rj.Repository.Name)
})
r := results[0]