remove comms network leftovers

Signed-off-by: Matthew R. Kasun <mkasun@nusak.ca>
This commit is contained in:
Matthew R. Kasun
2022-04-22 05:21:35 -04:00
parent e1b590d43f
commit 747d6bc692
16 changed files with 55 additions and 186 deletions

View File

@@ -10,36 +10,11 @@ import (
"github.com/gravitl/netmaker/netclient/ncutils"
)
// JoinComms -- Join the message queue comms network if it doesn't have it
// tries to ping if already found locally, if fail ping pull for best effort for communication
func JoinComms(cfg *config.ClientConfig) error {
commsCfg := &config.ClientConfig{}
commsCfg.Server.AccessKey = cfg.Server.AccessKey
commsCfg.Server.CoreDNSAddr = cfg.Server.CoreDNSAddr
if commsCfg.ConfigFileExists() {
return nil
}
commsCfg.ReadConfig()
if len(commsCfg.Node.Name) == 0 {
if err := functions.JoinNetwork(commsCfg, "", true); err != nil {
return err
}
} else { // check if comms is currently reachable
if err := functions.PingServer(commsCfg); err != nil {
if err = Pull(commsCfg); err != nil {
return err
}
}
}
return nil
}
// Join - join command to run from cli
func Join(cfg *config.ClientConfig, privateKey string) error {
var err error
//join network
err = functions.JoinNetwork(cfg, privateKey, false)
err = functions.JoinNetwork(cfg, privateKey)
if err != nil && !cfg.DebugOn {
if !strings.Contains(err.Error(), "ALREADY_INSTALLED") {
logger.Log(1, "error installing: ", err.Error())
@@ -89,13 +64,6 @@ func Leave(cfg *config.ClientConfig, force bool) error {
} else {
logger.Log(0, "success")
}
//nets, err := ncutils.GetSystemNetworks()
//if err == nil && len(nets) == 1 {
//if nets[0] == cfg.Node.CommID {
//logger.Log(1, "detected comms as remaining network, removing...")
//err = functions.LeaveNetwork(nets[0], true)
//}
//}
return err
}