summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/api
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2019-03-26 09:01:17 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-26 09:01:17 +0000
commit25682fe21ea85e807490229c2e8c8fd6a5963d25 (patch)
tree1b4e982f05af3db0c2c1f87cc2f0456a7eb1605f /src/k8splugin/api
parent967ff89e7dd42a374e5313447e92489bf27ac2d0 (diff)
parent037cfda2181e4995e4e2a47db6f1121b532b686b (diff)
Merge "Add support for composite keys"
Diffstat (limited to 'src/k8splugin/api')
-rw-r--r--src/k8splugin/api/handler.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/k8splugin/api/handler.go b/src/k8splugin/api/handler.go
index 4d6abe27..b1cc6709 100644
--- a/src/k8splugin/api/handler.go
+++ b/src/k8splugin/api/handler.go
@@ -35,6 +35,14 @@ import (
var storeName = "rbinst"
var tagData = "data"
+type instanceKey struct {
+ Key string
+}
+
+func (dk instanceKey) String() string {
+ return dk.Key
+}
+
// GetVNFClient retrieves the client used to communicate with a Kubernetes Cluster
var GetVNFClient = func(kubeConfigPath string) (kubernetes.Clientset, error) {
client, err := helper.GetKubeClient(kubeConfigPath)
@@ -130,7 +138,7 @@ func CreateHandler(w http.ResponseWriter, r *http.Request) {
// key: cloud1-default-uuid
// value: "{"deployment":<>,"service":<>}"
- err = db.DBconn.Create(storeName, internalVNFID, tagData, resourceNameMap)
+ err = db.DBconn.Create(storeName, instanceKey{Key: internalVNFID}, tagData, resourceNameMap)
if err != nil {
werr := pkgerrors.Wrap(err, "Create VNF deployment DB error")
http.Error(w, werr.Error(), http.StatusInternalServerError)
@@ -202,7 +210,7 @@ func DeleteHandler(w http.ResponseWriter, r *http.Request) {
// key: cloud1-default-uuid
// value: "{"deployment":<>,"service":<>}"
- res, err := db.DBconn.Read(storeName, internalVNFID, tagData)
+ res, err := db.DBconn.Read(storeName, instanceKey{Key: internalVNFID}, tagData)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -237,7 +245,7 @@ func DeleteHandler(w http.ResponseWriter, r *http.Request) {
return
}
- err = db.DBconn.Delete(storeName, internalVNFID, tagData)
+ err = db.DBconn.Delete(storeName, instanceKey{Key: internalVNFID}, tagData)
if err != nil {
werr := pkgerrors.Wrap(err, "Delete VNF db record error")
http.Error(w, werr.Error(), http.StatusInternalServerError)
@@ -330,7 +338,7 @@ func GetHandler(w http.ResponseWriter, r *http.Request) {
// key: cloud1-default-uuid
// value: "{"deployment":<>,"service":<>}"
- res, err := db.DBconn.Read(storeName, internalVNFID, tagData)
+ res, err := db.DBconn.Read(storeName, instanceKey{Key: internalVNFID}, tagData)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return