Skip to content

Commit

Permalink
Add a way to disable update checker making an http request
Browse files Browse the repository at this point in the history
Fixes #361
  • Loading branch information
Soulou committed Jul 5, 2018
1 parent 41809bd commit 3c45833
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -33,6 +33,15 @@ http_proxy=http://<proxy host>:<proxy port>
https_proxy=https://<proxy host>:<proxy port>
```

## Disable update checking

By default the CLI is making an HTTP request to learn if a newer version is available.
To disable this feature, define the environment variable:

```
DISABLE_UPDATE_CHECKER=true
```

## Command help

```
Expand Down
27 changes: 14 additions & 13 deletions config/config.go
Expand Up @@ -16,19 +16,20 @@ import (
)

type Config struct {
ScalingoApiUrl string
apiHost string
TokenGenerator scalingo.TokenGenerator
ApiVersion string
DisableInteractive bool
SshHost string
UnsecureSsl bool
RollbarToken string
ConfigDir string
AuthFile string
LogFile string
logFile *os.File
Logger *log.Logger
ScalingoApiUrl string
apiHost string
TokenGenerator scalingo.TokenGenerator
ApiVersion string
DisableInteractive bool
DisableUpdateChecker bool
SshHost string
UnsecureSsl bool
RollbarToken string
ConfigDir string
AuthFile string
LogFile string
logFile *os.File
Logger *log.Logger
}

var (
Expand Down
11 changes: 10 additions & 1 deletion update/check.go
Expand Up @@ -15,11 +15,16 @@ import (
var (
lastVersionURL = "https://cli-dl.scalingo.io/version"
lastVersion = ""
cancelUpdate = make(chan struct{})
gotLastVersion = make(chan struct{})
gotAnError = false
)

func init() {
if config.C.DisableUpdateChecker {
close(cancelUpdate)
return
}
go func() {
var err error
lastVersion, err = getLastVersion()
Expand All @@ -39,7 +44,11 @@ func Check() error {
return nil
}

<-gotLastVersion
select {
case <-cancelUpdate:
return nil
case <-gotLastVersion:
}

if gotAnError {
return errgo.New("Update checker: connection error")
Expand Down

0 comments on commit 3c45833

Please sign in to comment.