summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/rb/profile.go
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-01-18 12:09:56 -0800
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-01-28 15:22:58 -0800
commitecd18ef2315095601454332dd44a8dbc3329c394 (patch)
treeca6d97b8f0d47965425464b5fa8a1ad5e5f68bb0 /src/k8splugin/internal/rb/profile.go
parentf2eca1cca86160a2087b6bcbb8581898f8e77b1e (diff)
Add support for downloading content
Add support for downloading content for creating the merged helm charts. This api will be used mainly by the profile api to create a converged chart which will then be created by the instantiation code P2: Add unit tests for archive.go Add download method for profile.go Update comments for download method P3: Add unit test for empty files P4: Add unit tests for Download functions P5: Rebase against new folder structure Issue-ID: MULTICLOUD-291 Change-Id: I9779eaf95366f527f0360eaddea663722c13b196 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/internal/rb/profile.go')
-rw-r--r--src/k8splugin/internal/rb/profile.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/k8splugin/internal/rb/profile.go b/src/k8splugin/internal/rb/profile.go
index a0245af1..2456ad2d 100644
--- a/src/k8splugin/internal/rb/profile.go
+++ b/src/k8splugin/internal/rb/profile.go
@@ -183,3 +183,34 @@ func (v *ProfileClient) Upload(id string, inp []byte) error {
return nil
}
+
+// Download the contents of the resource bundle profile from DB
+// Returns a byte array of the contents which is used by the
+// ExtractTarBall code to create the folder structure on disk
+func (v *ProfileClient) Download(id string) ([]byte, error) {
+
+ //ignore the returned data here
+ //Check if id is valid
+ _, err := v.Get(id)
+ if err != nil {
+ return nil, pkgerrors.Errorf("Invalid Profile ID provided: %s", err.Error())
+ }
+
+ value, err := db.DBconn.Read(v.storeName, id, v.tagContent)
+ if err != nil {
+ return nil, pkgerrors.Wrap(err, "Get Resource Bundle Profile content")
+ }
+
+ if value != nil {
+ //Decode the string from base64
+ out, err := base64.StdEncoding.DecodeString(string(value))
+ if err != nil {
+ return nil, pkgerrors.Wrap(err, "Decode base64 string")
+ }
+
+ if out != nil && len(out) != 0 {
+ return out, nil
+ }
+ }
+ return nil, pkgerrors.New("Error downloading Profile content")
+}