Extract checkForUpdates to its own file
This commit is contained in:
1 parent
7a1bd27a58
commit
e1edce84d9
3 files changed
+40
-33
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/weaveworks/go-checkpoint"
|
||||
)
|
||||
|
||||
var checker *checkpoint.Checker
|
||||
var newVersion atomic.Value
|
||||
|
||||
const (
|
||||
updateCheckPeriod = 6 * time.Hour
|
||||
)
|
||||
|
||||
func checkForUpdates() {
|
||||
newVersion.Store("")
|
||||
|
||||
handleResponse := func(r *checkpoint.CheckResponse, err error) {
|
||||
if err != nil {
|
||||
Log.Printf("Error checking version: %v", err)
|
||||
return
|
||||
}
|
||||
if r.Outdated {
|
||||
newVersion.Store(r.CurrentVersion)
|
||||
Log.Printf("Weave version %s is available; please update at %s",
|
||||
r.CurrentVersion, r.CurrentDownloadURL)
|
||||
}
|
||||
}
|
||||
|
||||
// Start background version checking
|
||||
params := checkpoint.CheckParams{
|
||||
Product: "weave-net",
|
||||
Version: version,
|
||||
SignatureFile: "",
|
||||
}
|
||||
checker = checkpoint.CheckInterval(¶ms, updateCheckPeriod, handleResponse)
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/pkg/mflag"
|
||||
@@ -17,7 +16,6 @@ import (
|
||||
"github.com/pkg/profile"
|
||||
"github.com/weaveworks/mesh"
|
||||
|
||||
"github.com/weaveworks/go-checkpoint"
|
||||
"github.com/weaveworks/weave/common"
|
||||
"github.com/weaveworks/weave/common/docker"
|
||||
"github.com/weaveworks/weave/db"
|
||||
@@ -30,8 +28,6 @@ import (
|
||||
)
|
||||
|
||||
var version = "(unreleased version)"
|
||||
var checker *checkpoint.Checker
|
||||
var newVersion atomic.Value
|
||||
|
||||
var Log = common.Log
|
||||
|
||||
@@ -52,34 +48,6 @@ type dnsConfig struct {
|
||||
EffectiveListenAddress string
|
||||
}
|
||||
|
||||
const (
|
||||
updateCheckPeriod = 6 * time.Hour
|
||||
)
|
||||
|
||||
func checkForUpdates() {
|
||||
newVersion.Store("")
|
||||
|
||||
handleResponse := func(r *checkpoint.CheckResponse, err error) {
|
||||
if err != nil {
|
||||
Log.Printf("Error checking version: %v", err)
|
||||
return
|
||||
}
|
||||
if r.Outdated {
|
||||
newVersion.Store(r.CurrentVersion)
|
||||
Log.Printf("Weave version %s is available; please update at %s",
|
||||
r.CurrentVersion, r.CurrentDownloadURL)
|
||||
}
|
||||
}
|
||||
|
||||
// Start background version checking
|
||||
params := checkpoint.CheckParams{
|
||||
Product: "weave-net",
|
||||
Version: version,
|
||||
SignatureFile: "",
|
||||
}
|
||||
checker = checkpoint.CheckInterval(¶ms, updateCheckPeriod, handleResponse)
|
||||
}
|
||||
|
||||
func (c *ipamConfig) Enabled() bool {
|
||||
var (
|
||||
hasPeerCount = c.PeerCount > 0
|
||||
|
||||
+1
-1
Submodule vendor/github.com/weaveworks/go-checkpoint updated: b6cc8365a3...62324982ab.
Reference in new issue
Block a user