Add supported Version.Check values as consts
Peter Borzov committed
Oct 7, 2014 at 09:52 UTC
9f7dc48201bd27b8f01115f9812b580d3c47207e
2 files changed
+9
-3
cmd/ipfs/ipfs.go
+3
-3
@@ -119,13 +119,13 @@ func localNode(confdir string, online bool) (*core.IpfsNode, error) {
119
return nil, err
120
}
121
122
- if cfg.Version.Check != "ignore" {
122
+ if cfg.Version.Check != config.CheckIgnore {
123
obsolete := checkForUpdates()
124
if obsolete != nil {
125
- fmt.Println(obsolete)
126
- if cfg.Version.Check == "error" {
125
+ if cfg.Version.Check == config.CheckError {
126
return nil, obsolete
127
}
128
+ fmt.Println(obsolete) // when "warn" version.check mode we just show warning message
129
}
130
}
131
config/config.go
+6
@@ -51,6 +51,12 @@ type Version struct {
51
Current string `json:"current"` // ipfs version for which config was generated
52
}
53
54
+const (
55
+ CheckError = "error" // value for Version.Check to raise error and exit if version is obsolete
56
+ CheckWarn = "warn" // value for Version.Check to show warning message if version is obsolete
57
+ CheckIgnore = "ignore" // value for Version.Check to not perform update check
58
+)
59
+
60
// Config is used to load IPFS config files.
61
type Config struct {
62
Identity Identity // local node's peer identity