diff options
author | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2018-11-28 12:21:09 -0800 |
---|---|---|
committer | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2019-01-17 12:47:04 -0800 |
commit | cd9644049545a47676e87ad279833ced1b0f9c1a (patch) | |
tree | e400e1afc580cef33a95a17a5e6b019d00a07fef /src/k8splugin/rb/definition.go | |
parent | 1fa0e21ea6d3c5fb060daba19a0cb6c1f26f1364 (diff) |
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 <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/rb/definition.go')
-rw-r--r-- | src/k8splugin/rb/definition.go | 10 |
1 files changed, 6 insertions, 4 deletions
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)) |