mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 08:47:35 +08:00
client infrastructure to support updates
This commit is contained in:

committed by
0xdcarns

parent
ef82ac4af5
commit
ab9f0f05e0
34
netclient/functions/clientconfig.go
Normal file
34
netclient/functions/clientconfig.go
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package functions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gravitl/netmaker/logger"
|
||||||
|
"github.com/gravitl/netmaker/netclient/config"
|
||||||
|
"github.com/gravitl/netmaker/netclient/ncutils"
|
||||||
|
)
|
||||||
|
|
||||||
|
var updateRequired = false
|
||||||
|
|
||||||
|
// UpdateClientConfig - function is called on daemon start to update clientConfig if required
|
||||||
|
// Usage : set update required to true and and update logic to function
|
||||||
|
func UpdateClientConfig() {
|
||||||
|
if !updateRequired {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
networks, _ := ncutils.GetSystemNetworks()
|
||||||
|
if len(networks) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, network := range networks {
|
||||||
|
cfg := config.ClientConfig{}
|
||||||
|
cfg.Network = network
|
||||||
|
cfg.ReadConfig()
|
||||||
|
//update any new fields
|
||||||
|
logger.Log(0, "updating clientConfig for network", cfg.Network)
|
||||||
|
//insert update logic here
|
||||||
|
if err := config.Write(&cfg, cfg.Network); err != nil {
|
||||||
|
logger.Log(0, "failed to update clientConfig for ", cfg.Network, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//reset so future calls will return immediately
|
||||||
|
updateRequired = false
|
||||||
|
}
|
@@ -42,6 +42,7 @@ type cachedMessage struct {
|
|||||||
|
|
||||||
// Daemon runs netclient daemon from command line
|
// Daemon runs netclient daemon from command line
|
||||||
func Daemon() error {
|
func Daemon() error {
|
||||||
|
UpdateClientConfig()
|
||||||
serverSet := make(map[string]bool)
|
serverSet := make(map[string]bool)
|
||||||
// == initial pull of all networks ==
|
// == initial pull of all networks ==
|
||||||
networks, _ := ncutils.GetSystemNetworks()
|
networks, _ := ncutils.GetSystemNetworks()
|
||||||
|
Reference in New Issue
Block a user