Fix get charts API 56/9256/1
authorsubhash kumar singh <subh.singh@samsung.com>
Thu, 13 Oct 2022 09:24:47 +0000 (09:24 +0000)
committersubhash kumar singh <subh.singh@samsung.com>
Thu, 13 Oct 2022 09:24:47 +0000 (09:24 +0000)
Fixed the charts API to return the response in JSON format.

Signed-off-by: subhash kumar singh <subh.singh@samsung.com>
Change-Id: Ic9b41e40345db0fe8b4b50d61a4015cbb02d8368

pkg/charts/chart_manager.go

index c0308dd..6a3fc8e 100644 (file)
@@ -34,7 +34,7 @@ type ChartMgr struct {
 }
 
 type IChartMgr interface {
-       GetCharts() (string, error)
+       GetCharts() (map[string]interface{}, error)
        DownloadChart(string, string) (io.ReadCloser, error)
        GetChartsByName(name string) ([]map[string]interface{}, error)
        GetChartsByNameAndVersion(name, version string) (map[string]interface{}, error)
@@ -44,13 +44,13 @@ func NewChartmgr() IChartMgr {
        return &ChartMgr{}
 }
 
-func (c *ChartMgr) GetCharts() (string, error) {
+func (c *ChartMgr) GetCharts() (map[string]interface{}, error) {
        ricdms.Logger.Debug("GetCharts invoked")
 
        resp, err := http.Get(ricdms.Config.GetChartsURL)
        if err != nil {
                ricdms.Logger.Debug("Error in getting charts : %+v", err)
-               return "", err
+               return make(map[string]interface{}, 0), err
        }
 
        defer resp.Body.Close()
@@ -58,11 +58,14 @@ func (c *ChartMgr) GetCharts() (string, error) {
 
        if err != nil {
                ricdms.Logger.Debug("error in response: %+v", respByte)
-               return "", err
+               return make(map[string]interface{}, 0), err
        }
 
        ricdms.Logger.Debug("response : %+v", string(respByte))
-       return string(respByte), nil
+
+       v := make(map[string]interface{}, 0)
+       json.Unmarshal(respByte, &v)
+       return v, nil
 }
 
 func (c *ChartMgr) DownloadChart(chartName string, version string) (io.ReadCloser, error) {