Display UI indication if chart is upgradable (#211)

This commit is contained in:
Andrey Pokhilko
2023-02-10 12:36:40 +00:00
committed by GitHub
parent ac690b6332
commit 61b67f8bed
2 changed files with 38 additions and 20 deletions

View File

@@ -527,35 +527,39 @@ type RepoChartElement struct {
AppVersion string `json:"app_version"` AppVersion string `json:"app_version"`
Description string `json:"description"` Description string `json:"description"`
InstalledNamespace string `json:"installed_namespace"` // custom addition on top of Helm InstalledNamespace string `json:"installed_namespace"`
InstalledName string `json:"installed_name"` // custom addition on top of Helm InstalledName string `json:"installed_name"`
Repository string `json:"repository"` Repository string `json:"repository"`
} }
func HReleaseToJSON(o *release.Release) *ReleaseElement { func HReleaseToJSON(o *release.Release) *ReleaseElement {
return &ReleaseElement{ return &ReleaseElement{
Name: o.Name, Name: o.Name,
Namespace: o.Namespace, Namespace: o.Namespace,
Revision: strconv.Itoa(o.Version), Revision: strconv.Itoa(o.Version),
Updated: o.Info.LastDeployed, Updated: o.Info.LastDeployed,
Status: o.Info.Status, Status: o.Info.Status,
Chart: fmt.Sprintf("%s-%s", o.Chart.Name(), o.Chart.Metadata.Version), Chart: fmt.Sprintf("%s-%s", o.Chart.Name(), o.Chart.Metadata.Version),
AppVersion: o.Chart.AppVersion(), ChartName: o.Chart.Name(),
Icon: o.Chart.Metadata.Icon, ChartVersion: o.Chart.Metadata.Version,
Description: o.Chart.Metadata.Description, AppVersion: o.Chart.AppVersion(),
Icon: o.Chart.Metadata.Icon,
Description: o.Chart.Metadata.Description,
} }
} }
type ReleaseElement struct { type ReleaseElement struct {
Name string `json:"name"` Name string `json:"name"`
Namespace string `json:"namespace"` Namespace string `json:"namespace"`
Revision string `json:"revision"` Revision string `json:"revision"`
Updated helmtime.Time `json:"updated"` Updated helmtime.Time `json:"updated"`
Status release.Status `json:"status"` Status release.Status `json:"status"`
Chart string `json:"chart"` Chart string `json:"chart"`
AppVersion string `json:"app_version"` ChartName string `json:"chartName"`
Icon string `json:"icon"` ChartVersion string `json:"chartVersion"`
Description string `json:"description"` AppVersion string `json:"app_version"`
Icon string `json:"icon"`
Description string `json:"description"`
} }
type RepositoryElement struct { type RepositoryElement struct {

View File

@@ -79,6 +79,20 @@ function buildChartCard(elm) {
loadChartHistory(chart.namespace, chart.name, elm.chart_name) loadChartHistory(chart.namespace, chart.name, elm.chart_name)
}) })
// check if upgrade is possible
$.getJSON("/api/helm/repositories/latestver?name=" + elm.chartName).fail(function (xhr) {
reportError("Failed to find chart in repo", xhr)
}).done(function (data) {
if (!data || !data.length) {
return
}
if (isNewerVersion(elm.chartVersion, data[0].version)) {
card.find(".rel-name span").append("<span class='bi-arrow-up-circle-fill ms-2 text-success' title='Upgrade available: "+data[0].version+"'></span>")
}
})
return card; return card;
} }