From cd9644049545a47676e87ad279833ced1b0f9c1a Mon Sep 17 00:00:00 2001 From: Kiran Kamineni Date: Wed, 28 Nov 2018 12:21:09 -0800 Subject: Add resource bundle profile api Add CRUD api for uploading profiles for specific definition resource bundles. - Adding unit tests Issue-ID: ONAPARC-348 Change-Id: Ic43724b4e2c035e7989c827612f1b2800fc49a69 Signed-off-by: Kiran Kamineni --- src/k8splugin/rb/definition.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/k8splugin/rb/definition.go') diff --git a/src/k8splugin/rb/definition.go b/src/k8splugin/rb/definition.go index 460dc7a6..eb7a12fc 100644 --- a/src/k8splugin/rb/definition.go +++ b/src/k8splugin/rb/definition.go @@ -29,9 +29,9 @@ import ( // Definition contains the parameters needed for resource bundle (rb) definitions // It implements the interface for managing the definitions type Definition struct { + UUID string `json:"uuid,omitempty"` Name string `json:"name"` Description string `json:"description"` - UUID string `json:"uuid,omitempty"` ServiceType string `json:"service-type"` } @@ -87,11 +87,12 @@ func (v *DefinitionClient) List() ([]Definition, error) { var results []Definition for key, value := range res { + //value is a byte array if len(value) > 0 { def := Definition{} err = db.DBconn.Unmarshal(value, &def) if err != nil { - log.Printf("Error Unmarshaling value for: %s", key) + log.Printf("[Definition] Error Unmarshaling value for: %s", key) continue } results = append(results, def) @@ -108,6 +109,7 @@ func (v *DefinitionClient) Get(id string) (Definition, error) { return Definition{}, pkgerrors.Wrap(err, "Get Resource Bundle definition") } + //value is a byte array if value != nil { def := Definition{} err = db.DBconn.Unmarshal(value, &def) @@ -124,7 +126,7 @@ func (v *DefinitionClient) Get(id string) (Definition, error) { func (v *DefinitionClient) Delete(id string) error { err := db.DBconn.Delete(v.storeName, id, v.tagMeta) if err != nil { - return pkgerrors.Wrap(err, "Delete Resource Bundle Definitions") + return pkgerrors.Wrap(err, "Delete Resource Bundle Definition") } return nil @@ -136,7 +138,7 @@ func (v *DefinitionClient) Upload(id string, inp []byte) error { //ignore the returned data here _, err := v.Get(id) if err != nil { - return pkgerrors.Errorf("Invalid ID provided: %s", err.Error()) + return pkgerrors.Errorf("Invalid Definition ID provided: %s", err.Error()) } err = isTarGz(bytes.NewBuffer(inp)) -- cgit 1.2.3-korg