Browse Source

change env to var

0xdcarns 3 years ago
parent
commit
9c6c6ef176
2 changed files with 12 additions and 4 deletions
  1. 10 2
      servercfg/serverconf.go
  2. 2 2
      serverctl/serverctl.go

+ 10 - 2
servercfg/serverconf.go

@@ -12,7 +12,10 @@ import (
 	"github.com/gravitl/netmaker/config"
 )
 
-var Version = "dev"
+var (
+	Version = "dev"
+	commsID = ""
+)
 
 // SetHost - sets the host ip
 func SetHost() error {
@@ -270,7 +273,12 @@ func GetCommsCIDR() string {
 
 // GetCommsID - gets the grpc port
 func GetCommsID() string {
-	return os.Getenv("COMMS_ID")
+	return commsID
+}
+
+// SetCommsID - sets the commsID
+func SetCommsID(newCommsID string) {
+	commsID = newCommsID
 }
 
 // GetMessageQueueEndpoint - gets the message queue endpoint

+ 2 - 2
serverctl/serverctl.go

@@ -52,11 +52,11 @@ func setCommsID() {
 			logger.FatalLog("something went wrong when configuring comms id")
 		}
 		COMMS_NETID = commsid
-		os.Setenv("COMMS_ID", COMMS_NETID)
+		servercfg.SetCommsID(COMMS_NETID)
 		return
 	}
 	COMMS_NETID = currentid
-	os.Setenv("COMMS_ID", COMMS_NETID)
+	servercfg.SetCommsID(COMMS_NETID)
 }
 
 // InitServerNetclient - intializes the server netclient