Browse Source

NET-641: Enable/Disable Auto Update From UI (#2622)

* add support to disable/enable autoupdate on a host

* setting to older version for QA to test
Abhishek K 1 year ago
parent
commit
675c4ec34c
3 changed files with 4 additions and 1 deletions
  1. 0 1
      logic/hosts.go
  2. 1 0
      main.go
  3. 3 0
      models/api_host.go

+ 0 - 1
logic/hosts.go

@@ -199,7 +199,6 @@ func UpdateHost(newHost, currentHost *models.Host) {
 	newHost.Nodes = currentHost.Nodes
 	newHost.PublicKey = currentHost.PublicKey
 	newHost.TrafficKeyPublic = currentHost.TrafficKeyPublic
-
 	// changeable fields
 	if len(newHost.Version) == 0 {
 		newHost.Version = currentHost.Version

+ 1 - 0
main.go

@@ -28,6 +28,7 @@ import (
 	"golang.org/x/exp/slog"
 )
 
+
 var version = "v0.21.2"
 
 // Start DB Connection and start API Request Handler

+ 3 - 0
models/api_host.go

@@ -32,6 +32,7 @@ type ApiHost struct {
 	RelayedHosts        []string `json:"relay_hosts"           yaml:"relay_hosts"           bson:"relay_hosts"`
 	NatType             string   `json:"nat_type"              yaml:"nat_type"`
 	PersistentKeepalive int      `json:"persistentkeepalive"   yaml:"persistentkeepalive"`
+	AutoUpdate          bool     `json:"autoupdate"              yaml:"autoupdate"`
 }
 
 // Host.ConvertNMHostToAPI - converts a Netmaker host to an API editable host
@@ -60,6 +61,7 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
 	a.IsDefault = h.IsDefault
 	a.NatType = h.NatType
 	a.PersistentKeepalive = int(h.PersistentKeepalive.Seconds())
+	a.AutoUpdate = h.AutoUpdate
 	return &a
 }
 
@@ -98,5 +100,6 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
 	h.NatType = currentHost.NatType
 	h.TurnEndpoint = currentHost.TurnEndpoint
 	h.PersistentKeepalive = time.Duration(a.PersistentKeepalive) * time.Second
+	h.AutoUpdate = a.AutoUpdate
 	return &h
 }