diff options
author | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2019-05-01 16:03:47 -0700 |
---|---|---|
committer | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2019-05-01 16:03:51 -0700 |
commit | 2eec43edc8b9a438865422fcf6ae340c2aec036d (patch) | |
tree | 08e9abcca67aca551e8de138f771d2341095ecbd /src | |
parent | 619ccde3c59cdbf5066a667d2bbea465d4a68984 (diff) |
Merge cloudregionid and connectionname
Merge cloudregionid and connectionname to form cloudregion
Issue-ID: MULTICLOUD-292
Change-Id: If775ec5841636de37e1c10bc6d093c16a36c28dc
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/k8splugin/internal/connection/connection.go | 13 | ||||
-rw-r--r-- | src/k8splugin/internal/connection/connectionhandler.go | 10 |
2 files changed, 8 insertions, 15 deletions
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 |