Implementation for downloading charts
Implemented API to download helm chart for specified chartname
and version.
Signed-off-by: subhash kumar singh <subh.singh@samsung.com>
Change-Id: I343dc18870c81d182a728677e3b21e5fc50d84af
diff --git a/pkg/charts/chart_manager.go b/pkg/charts/chart_manager.go
index 252b2dc..75ec338 100644
--- a/pkg/charts/chart_manager.go
+++ b/pkg/charts/chart_manager.go
@@ -21,6 +21,8 @@
package charts
import (
+ "fmt"
+ "io"
"io/ioutil"
"net/http"
@@ -32,6 +34,7 @@
type IChartMgr interface {
GetCharts() (string, error)
+ DownloadChart(string, string) (io.ReadCloser, error)
}
func NewChartmgr() IChartMgr {
@@ -58,3 +61,20 @@
ricdms.Logger.Debug("response : %+v", string(respByte))
return string(respByte), nil
}
+
+func (c *ChartMgr) DownloadChart(chartName string, version string) (io.ReadCloser, error) {
+ ricdms.Logger.Debug("Download Charts invoked")
+
+ if chartName == "" || version == "" {
+ return nil, fmt.Errorf("chartname or version is empty")
+ }
+
+ ChartURL := fmt.Sprintf(ricdms.Config.DownloadChartURLFormat, chartName, version)
+
+ resp, err := http.Get(ChartURL)
+ if err != nil {
+ return nil, err
+ }
+
+ return resp.Request.Body, nil
+}