Merge cloudregionid and connectionname 54/86754/1
authorKiran Kamineni <kiran.k.kamineni@intel.com>
Wed, 1 May 2019 23:03:47 +0000 (16:03 -0700)
committerKiran Kamineni <kiran.k.kamineni@intel.com>
Wed, 1 May 2019 23:03:51 +0000 (16:03 -0700)
Merge cloudregionid and connectionname to form cloudregion

Issue-ID: MULTICLOUD-292
Change-Id: If775ec5841636de37e1c10bc6d093c16a36c28dc
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
src/k8splugin/internal/connection/connection.go
src/k8splugin/internal/connection/connectionhandler.go

index 3faa74b..dbd1c2e 100644 (file)
@@ -25,16 +25,15 @@ import (
 
 // Connection contains the parameters needed for Connection information for a Cloud region
 type Connection struct {
-       ConnectionName        string                 `json:"name"`
+       CloudRegion           string                 `json:"cloud-region"`
        CloudOwner            string                 `json:"cloud-owner"`
-       CloudRegionID         string                 `json:"cloud-region-id"`
        Kubeconfig            map[string]interface{} `json:"kubeconfig"`
        OtherConnectivityList map[string]interface{} `json:"other-connectivity-list"`
 }
 
 // ConnectionKey is the key structure that is used in the database
 type ConnectionKey struct {
-       ConnectionName string `json:"connection-name"`
+       CloudRegion string `json:"cloud-region"`
 }
 
 // We will use json marshalling to convert to string to
@@ -75,10 +74,10 @@ func NewConnectionClient() *ConnectionClient {
 func (v *ConnectionClient) Create(c Connection) (Connection, error) {
 
        //Construct composite key consisting of name
-       key := ConnectionKey{ConnectionName: c.ConnectionName}
+       key := ConnectionKey{CloudRegion: c.CloudRegion}
 
        //Check if this Connection already exists
-       _, err := v.Get(c.ConnectionName)
+       _, err := v.Get(c.CloudRegion)
        if err == nil {
                return Connection{}, pkgerrors.New("Connection already exists")
        }
@@ -95,7 +94,7 @@ func (v *ConnectionClient) Create(c Connection) (Connection, error) {
 func (v *ConnectionClient) Get(name string) (Connection, error) {
 
        //Construct the composite key to select the entry
-       key := ConnectionKey{ConnectionName: name}
+       key := ConnectionKey{CloudRegion: name}
        value, err := db.DBconn.Read(v.storeName, key, v.tagMeta)
        if err != nil {
                return Connection{}, pkgerrors.Wrap(err, "Get Connection")
@@ -118,7 +117,7 @@ func (v *ConnectionClient) Get(name string) (Connection, error) {
 func (v *ConnectionClient) Delete(name string) error {
 
        //Construct the composite key to select the entry
-       key := ConnectionKey{ConnectionName: name}
+       key := ConnectionKey{CloudRegion: name}
        err := db.DBconn.Delete(v.storeName, key, v.tagMeta)
        if err != nil {
                return pkgerrors.Wrap(err, "Delete Connection")
index ddb43f5..0f8014f 100644 (file)
@@ -47,7 +47,7 @@ func (h ConnectionHandler) CreateHandler(w http.ResponseWriter, r *http.Request)
        }
 
        // Name is required.
-       if v.ConnectionName == "" {
+       if v.CloudRegion == "" {
                http.Error(w, "Missing name in POST request", http.StatusBadRequest)
                return
        }
@@ -58,13 +58,7 @@ func (h ConnectionHandler) CreateHandler(w http.ResponseWriter, r *http.Request)
                return
        }
 
-       // CloudRegionID is required.
-       if v.CloudRegionID == "" {
-               http.Error(w, "Missing CloudRegionID in POST request", http.StatusBadRequest)
-               return
-       }
-
-       // CloudRegionID is required.
+       // Kubeconfig is required.
        if v.Kubeconfig == nil {
                http.Error(w, "Missing Kubeconfig in POST request", http.StatusBadRequest)
                return