Browse Source

Merge pull request #1499 from k4s0/develop

added new controller for creating custom ExtClient
Alex Feiszli 2 years ago
parent
commit
a95e0d25c6
2 changed files with 12 additions and 1 deletions
  1. 7 1
      controllers/ext_client.go
  2. 5 0
      models/structs.go

+ 7 - 1
controllers/ext_client.go

@@ -248,9 +248,9 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
 	w.Header().Set("Content-Type", "application/json")
 	w.Header().Set("Content-Type", "application/json")
 
 
 	var params = mux.Vars(r)
 	var params = mux.Vars(r)
-
 	networkName := params["network"]
 	networkName := params["network"]
 	nodeid := params["nodeid"]
 	nodeid := params["nodeid"]
+	
 	ingressExists := checkIngressExists(nodeid)
 	ingressExists := checkIngressExists(nodeid)
 	if !ingressExists {
 	if !ingressExists {
 		err := errors.New("ingress does not exist")
 		err := errors.New("ingress does not exist")
@@ -261,6 +261,12 @@ func createExtClient(w http.ResponseWriter, r *http.Request) {
 	}
 	}
 
 
 	var extclient models.ExtClient
 	var extclient models.ExtClient
+	var CustomExtClient models.CustomExtClient
+	
+	err := json.NewDecoder(r.Body).Decode(&CustomExtClient);
+	
+	if err == nil { extclient.ClientID = CustomExtClient.ClientID }
+	
 	extclient.Network = networkName
 	extclient.Network = networkName
 	extclient.IngressGatewayID = nodeid
 	extclient.IngressGatewayID = nodeid
 	node, err := logic.GetNodeByID(nodeid)
 	node, err := logic.GetNodeByID(nodeid)

+ 5 - 0
models/structs.go

@@ -10,6 +10,11 @@ import (
 const PLACEHOLDER_KEY_TEXT = "ACCESS_KEY"
 const PLACEHOLDER_KEY_TEXT = "ACCESS_KEY"
 const PLACEHOLDER_TOKEN_TEXT = "ACCESS_TOKEN"
 const PLACEHOLDER_TOKEN_TEXT = "ACCESS_TOKEN"
 
 
+// CustomExtClient - struct for CustomExtClient params
+type CustomExtClient struct {
+	ClientID string `json:"clientid"`
+}
+
 // AuthParams - struct for auth params
 // AuthParams - struct for auth params
 type AuthParams struct {
 type AuthParams struct {
 	MacAddress string `json:"macaddress"`
 	MacAddress string `json:"macaddress"`