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
This commit is contained in:
Abhishek K 2023-10-19 08:59:36 +04:00 committed by GitHub
parent 64d2a4820c
commit 675c4ec34c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 1 deletions

View file

@ -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

View file

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

View file

@ -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
}