Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to disable update checker making an http request #368

Merged
merged 1 commit into from
Jul 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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