Enhancement/show chart icon and description (#70)

* New API to fetch chart.yaml for an installec chart

* Show icon and description for installed chart list

Co-authored-by: Harshit Mehta <harshitm@nvidia.com>
This commit is contained in:
Harshit Mehta
2022-11-09 13:53:44 +05:30
committed by GitHub
parent b9392ab4c9
commit 76d55f8e44
5 changed files with 75 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ import (
"github.com/komodorio/helm-dashboard/pkg/dashboard/utils"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/release"
v1 "k8s.io/apimachinery/pkg/apis/testapigroup/v1"
)
@@ -449,6 +450,33 @@ func (d *DataLayer) ShowValues(chart string, ver string) (string, error) {
return d.runCommandHelm("show", "values", chart, "--version", ver)
}
func (d *DataLayer) ShowChart(chartName string) ([]*chart.Metadata, error) {
out, err := d.runCommandHelm("show", "chart", chartName)
if err != nil {
return nil, err
}
deccoder := yaml.NewDecoder(bytes.NewReader([]byte(out)))
res := make([]*chart.Metadata, 0)
var tmp interface{}
for deccoder.Decode(&tmp) == nil {
jsoned, err := json.Marshal(tmp)
if err != nil {
return nil, err
}
var resjson chart.Metadata
err = json.Unmarshal(jsoned, &resjson)
if err != nil {
return nil, err
}
res = append(res, &resjson)
}
return res, nil
}
func (d *DataLayer) ChartRepoList() (res []RepositoryElement, err error) {
out, err := d.runCommandHelm("repo", "list", "--output", "json")
if err != nil {