-
Notifications
You must be signed in to change notification settings - Fork 124
/
cli_update.go
38 lines (32 loc) · 913 Bytes
/
cli_update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package data
import (
"context"
"net/http"
"github.com/evergreen-ci/evergreen"
"github.com/evergreen-ci/evergreen/rest/model"
"github.com/evergreen-ci/gimlet"
)
// GetCLIUpdate fetches the current cli version and the urls to download
func GetCLIUpdate(ctx context.Context, env evergreen.Environment) (*model.APICLIUpdate, error) {
update := &model.APICLIUpdate{}
config := env.ClientConfig()
if config == nil {
return nil, gimlet.ErrorResponse{
StatusCode: http.StatusInternalServerError,
Message: "no clients configured",
}
}
flags, err := evergreen.GetServiceFlags(ctx)
if err != nil {
return nil, gimlet.ErrorResponse{
StatusCode: http.StatusInternalServerError,
Message: err.Error(),
}
}
if flags.S3BinaryDownloadsDisabled {
config.S3ClientBinaries = nil
}
update.BuildFromService(*config)
update.IgnoreUpdate = flags.CLIUpdatesDisabled
return update, nil
}