Skip to content

Commit

Permalink
Merge pull request #368 from Scalingo/fix/361/update
Browse files Browse the repository at this point in the history
Add a way to disable update checker making an http request
  • Loading branch information
EtienneM authored Jul 5, 2018
2 parents 5d1a9e9 + 3c45833 commit 118e6e4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 118e6e4

Please sign in to comment.