Browse Source

logic.Is_EE --> systemcfg.Is_EE

Matthew R. Kasun 2 years ago
parent
commit
5f7d6ea1ef
5 changed files with 22 additions and 20 deletions
  1. 2 1
      controllers/limits.go
  2. 16 16
      controllers/server.go
  3. 2 1
      logic/auth.go
  4. 1 1
      mq/handlers.go
  5. 1 1
      mq/publishers.go

+ 2 - 1
controllers/limits.go

@@ -6,6 +6,7 @@ import (
 	"github.com/gravitl/netmaker/database"
 	"github.com/gravitl/netmaker/database"
 	"github.com/gravitl/netmaker/logic"
 	"github.com/gravitl/netmaker/logic"
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
+	"github.com/gravitl/netmaker/servercfg"
 )
 )
 
 
 // limit consts
 // limit consts
@@ -22,7 +23,7 @@ func checkFreeTierLimits(limit_choice int, next http.Handler) http.HandlerFunc {
 			Code: http.StatusUnauthorized, Message: "free tier limits exceeded on networks",
 			Code: http.StatusUnauthorized, Message: "free tier limits exceeded on networks",
 		}
 		}
 
 
-		if logic.Free_Tier && logic.Is_EE { // check that free tier limits not exceeded
+		if logic.Free_Tier && servercfg.Is_EE { // check that free tier limits not exceeded
 			if limit_choice == networks_l {
 			if limit_choice == networks_l {
 				currentNetworks, err := logic.GetNetworks()
 				currentNetworks, err := logic.GetNetworks()
 				if (err != nil && !database.IsEmptyRecord(err)) || len(currentNetworks) >= logic.Networks_Limit {
 				if (err != nil && !database.IsEmptyRecord(err)) || len(currentNetworks) >= logic.Networks_Limit {

+ 16 - 16
controllers/server.go

@@ -54,13 +54,13 @@ func allowUsers(next http.Handler) http.HandlerFunc {
 //
 //
 // Get the server configuration.
 // Get the server configuration.
 //
 //
-//		Schemes: https
+//			Schemes: https
 //
 //
-// 		Security:
-//   		oauth
+//			Security:
+//	  		oauth
 //
 //
-//		Responses:
-//			200: serverConfigResponse
+//			Responses:
+//				200: serverConfigResponse
 func getServerInfo(w http.ResponseWriter, r *http.Request) {
 func getServerInfo(w http.ResponseWriter, r *http.Request) {
 	// Set header
 	// Set header
 	w.Header().Set("Content-Type", "application/json")
 	w.Header().Set("Content-Type", "application/json")
@@ -75,13 +75,13 @@ func getServerInfo(w http.ResponseWriter, r *http.Request) {
 //
 //
 // Get the server configuration.
 // Get the server configuration.
 //
 //
-//		Schemes: https
+//			Schemes: https
 //
 //
-// 		Security:
-//   		oauth
+//			Security:
+//	  		oauth
 //
 //
-//		Responses:
-//			200: serverConfigResponse
+//			Responses:
+//				200: serverConfigResponse
 func getConfig(w http.ResponseWriter, r *http.Request) {
 func getConfig(w http.ResponseWriter, r *http.Request) {
 	// Set header
 	// Set header
 	w.Header().Set("Content-Type", "application/json")
 	w.Header().Set("Content-Type", "application/json")
@@ -90,7 +90,7 @@ func getConfig(w http.ResponseWriter, r *http.Request) {
 
 
 	scfg := servercfg.GetServerConfig()
 	scfg := servercfg.GetServerConfig()
 	scfg.IsEE = "no"
 	scfg.IsEE = "no"
-	if logic.Is_EE {
+	if servercfg.Is_EE {
 		scfg.IsEE = "yes"
 		scfg.IsEE = "yes"
 	}
 	}
 	json.NewEncoder(w).Encode(scfg)
 	json.NewEncoder(w).Encode(scfg)
@@ -101,13 +101,13 @@ func getConfig(w http.ResponseWriter, r *http.Request) {
 //
 //
 // Registers a client with the server and return the Certificate Authority and certificate.
 // Registers a client with the server and return the Certificate Authority and certificate.
 //
 //
-//		Schemes: https
+//			Schemes: https
 //
 //
-// 		Security:
-//   		oauth
+//			Security:
+//	  		oauth
 //
 //
-//		Responses:
-//			200: registerResponse
+//			Responses:
+//				200: registerResponse
 func register(w http.ResponseWriter, r *http.Request) {
 func register(w http.ResponseWriter, r *http.Request) {
 	logger.Log(2, "processing registration request")
 	logger.Log(2, "processing registration request")
 	w.Header().Set("Content-Type", "application/json")
 	w.Header().Set("Content-Type", "application/json")

+ 2 - 1
logic/auth.go

@@ -12,6 +12,7 @@ import (
 	"github.com/gravitl/netmaker/logic/pro"
 	"github.com/gravitl/netmaker/logic/pro"
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/models/promodels"
 	"github.com/gravitl/netmaker/models/promodels"
+	"github.com/gravitl/netmaker/servercfg"
 	"golang.org/x/crypto/bcrypt"
 	"golang.org/x/crypto/bcrypt"
 )
 )
 
 
@@ -140,7 +141,7 @@ func CreateUser(user models.User) (models.User, error) {
 
 
 		// legacy
 		// legacy
 		if StringSliceContains(user.Networks, currentNets[i].NetID) {
 		if StringSliceContains(user.Networks, currentNets[i].NetID) {
-			if !Is_EE {
+			if !servercfg.Is_EE {
 				newUser.AccessLevel = pro.NET_ADMIN
 				newUser.AccessLevel = pro.NET_ADMIN
 			}
 			}
 		}
 		}

+ 1 - 1
mq/handlers.go

@@ -98,7 +98,7 @@ func UpdateNode(client mqtt.Client, msg mqtt.Message) {
 
 
 // UpdateMetrics  message Handler -- handles updates from client nodes for metrics
 // UpdateMetrics  message Handler -- handles updates from client nodes for metrics
 func UpdateMetrics(client mqtt.Client, msg mqtt.Message) {
 func UpdateMetrics(client mqtt.Client, msg mqtt.Message) {
-	if logic.Is_EE {
+	if servercfg.Is_EE {
 		go func() {
 		go func() {
 			id, err := getID(msg.Topic())
 			id, err := getID(msg.Topic())
 			if err != nil {
 			if err != nil {

+ 1 - 1
mq/publishers.go

@@ -184,7 +184,7 @@ func ServerStartNotify() error {
 
 
 // function to collect and store metrics for server nodes
 // function to collect and store metrics for server nodes
 func collectServerMetrics(networks []models.Network) {
 func collectServerMetrics(networks []models.Network) {
-	if !logic.Is_EE {
+	if !servercfg.Is_EE {
 		return
 		return
 	}
 	}
 	if len(networks) > 0 {
 	if len(networks) > 0 {