mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 16:26:38 +00:00
actually commit my changes this time...
This commit is contained in:
@@ -61,6 +61,9 @@ type UpdateManager struct {
|
|||||||
|
|
||||||
// updateMutex protect update and expectedVersion fields
|
// updateMutex protect update and expectedVersion fields
|
||||||
updateMutex sync.Mutex
|
updateMutex sync.Mutex
|
||||||
|
|
||||||
|
// updateFunc is used for testing to mock the triggerUpdate behavior
|
||||||
|
updateFunc func(ctx context.Context, targetVersion string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUpdateManager(statusRecorder *peer.Status, stateManager *statemanager.Manager) *UpdateManager {
|
func NewUpdateManager(statusRecorder *peer.Status, stateManager *statemanager.Manager) *UpdateManager {
|
||||||
@@ -79,7 +82,6 @@ func NewUpdateManager(statusRecorder *peer.Status, stateManager *statemanager.Ma
|
|||||||
// CheckUpdateSuccess checks if the update was successful. It works without to start the update manager.
|
// CheckUpdateSuccess checks if the update was successful. It works without to start the update manager.
|
||||||
func (u *UpdateManager) CheckUpdateSuccess(ctx context.Context) {
|
func (u *UpdateManager) CheckUpdateSuccess(ctx context.Context) {
|
||||||
u.updateStateManager(ctx)
|
u.updateStateManager(ctx)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UpdateManager) Start(ctx context.Context) {
|
func (u *UpdateManager) Start(ctx context.Context) {
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
||||||
|
// Use test function if set (for testing only)
|
||||||
|
if u.updateFunc != nil {
|
||||||
|
return u.updateFunc(ctx, targetVersion)
|
||||||
|
}
|
||||||
|
|
||||||
cmd := exec.CommandContext(ctx, "pkgutil", "--pkg-info", "io.netbird.client")
|
cmd := exec.CommandContext(ctx, "pkgutil", "--pkg-info", "io.netbird.client")
|
||||||
outBytes, err := cmd.Output()
|
outBytes, err := cmd.Output()
|
||||||
if err != nil && cmd.ProcessState.ExitCode() == 1 {
|
if err != nil && cmd.ProcessState.ExitCode() == 1 {
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ package updatemanager
|
|||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
||||||
|
// Use test function if set (for testing purposes)
|
||||||
|
if u.updateFunc != nil {
|
||||||
|
return u.updateFunc(ctx, targetVersion)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ package updatemanager
|
|||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
||||||
|
// Use test function if set (for testing purposes)
|
||||||
|
if u.updateFunc != nil {
|
||||||
|
return u.updateFunc(ctx, targetVersion)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ package updatemanager
|
|||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
||||||
|
// Use test function if set (for testing purposes)
|
||||||
|
if u.updateFunc != nil {
|
||||||
|
return u.updateFunc(ctx, targetVersion)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ const (
|
|||||||
type installerType string
|
type installerType string
|
||||||
|
|
||||||
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
|
||||||
|
// Use test function if set (for testing purposes)
|
||||||
|
if u.updateFunc != nil {
|
||||||
|
return u.updateFunc(ctx, targetVersion)
|
||||||
|
}
|
||||||
|
|
||||||
method := installation()
|
method := installation()
|
||||||
return install(ctx, method, targetVersion)
|
return install(ctx, method, targetVersion)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user