mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 15:26:40 +00:00
Merge branch 'feat/auto-upgrade' into auto-upgrade-mod
This commit is contained in:
@@ -74,11 +74,6 @@ func NewUpdateManager(statusRecorder *peer.Status, stateManager *statemanager.Ma
|
||||
return manager
|
||||
}
|
||||
|
||||
func (u *UpdateManager) WithCustomVersionUpdate(versionUpdate UpdateInterface) *UpdateManager {
|
||||
u.update = versionUpdate
|
||||
return u
|
||||
}
|
||||
|
||||
func (u *UpdateManager) StartWithTimeout(ctx context.Context, timeout time.Duration) {
|
||||
if u.cancel != nil {
|
||||
log.Errorf("UpdateManager already started")
|
||||
@@ -180,10 +175,12 @@ func (u *UpdateManager) Stop() {
|
||||
}
|
||||
|
||||
u.cancel()
|
||||
u.expectedVersionMutex.Lock()
|
||||
if u.update != nil {
|
||||
u.update.StopWatch()
|
||||
u.update = nil
|
||||
}
|
||||
u.expectedVersionMutex.Unlock()
|
||||
|
||||
u.wg.Wait()
|
||||
}
|
||||
@@ -219,6 +216,9 @@ func (u *UpdateManager) handleUpdate(ctx context.Context) {
|
||||
var updateVersion *v.Version
|
||||
|
||||
u.expectedVersionMutex.Lock()
|
||||
if u.update == nil {
|
||||
return
|
||||
}
|
||||
expectedVersion := u.expectedVersion
|
||||
useLatest := u.updateToLatestVersion
|
||||
curLatestVersion := u.update.LatestVersion()
|
||||
@@ -244,7 +244,7 @@ func (u *UpdateManager) handleUpdate(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithDeadline(ctx, time.Now().Add(time.Minute))
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Minute)
|
||||
defer cancel()
|
||||
|
||||
u.lastTrigger = time.Now()
|
||||
|
||||
@@ -11,6 +11,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func (u *UpdateManager) WithCustomVersionUpdate(versionUpdate UpdateInterface) *UpdateManager {
|
||||
u.update = versionUpdate
|
||||
return u
|
||||
}
|
||||
|
||||
type versionUpdateMock struct {
|
||||
latestVersion *v.Version
|
||||
onUpdate func()
|
||||
|
||||
10
client/internal/updatemanager/update_js.go
Normal file
10
client/internal/updatemanager/update_js.go
Normal file
@@ -0,0 +1,10 @@
|
||||
//go:build js
|
||||
|
||||
package updatemanager
|
||||
|
||||
import "context"
|
||||
|
||||
func triggerUpdate(ctx context.Context, targetVersion string) error {
|
||||
// TODO: Implement
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user