summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/k8splugin/internal/connection/connection.go13
-rw-r--r--src/k8splugin/internal/connection/connectionhandler.go10
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