From: Kiran Kamineni Date: Wed, 1 May 2019 23:03:47 +0000 (-0700) Subject: Merge cloudregionid and connectionname X-Git-Tag: 0.1.0~2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=2eec43edc8b9a438865422fcf6ae340c2aec036d;p=multicloud%2Fk8s.git Merge cloudregionid and connectionname Merge cloudregionid and connectionname to form cloudregion Issue-ID: MULTICLOUD-292 Change-Id: If775ec5841636de37e1c10bc6d093c16a36c28dc Signed-off-by: Kiran Kamineni --- diff --git a/src/k8splugin/internal/connection/connection.go b/src/k8splugin/internal/connection/connection.go index 3faa74bd..dbd1c2e1 100644 --- a/src/k8splugin/internal/connection/connection.go +++ b/src/k8splugin/internal/connection/connection.go @@ -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") diff --git a/src/k8splugin/internal/connection/connectionhandler.go b/src/k8splugin/internal/connection/connectionhandler.go index ddb43f57..0f8014fa 100644 --- a/src/k8splugin/internal/connection/connectionhandler.go +++ b/src/k8splugin/internal/connection/connectionhandler.go @@ -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