File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import (
1515 "runtime/debug"
1616 "slices"
1717 "sort"
18+ "strconv"
1819 "sync"
1920
2021 "github.com/Masterminds/semver/v3"
@@ -25,8 +26,9 @@ import (
2526const defaultURL = "https://dbc-cdn.columnar.tech"
2627
2728var (
28- baseURL = defaultURL
29- Version = "unknown"
29+ baseURL = defaultURL
30+ Version = "unknown"
31+ userAgent string
3032)
3133
3234func init () {
@@ -38,6 +40,16 @@ func init() {
3840 if val := os .Getenv ("DBC_BASE_URL" ); val != "" {
3941 baseURL = val
4042 }
43+
44+ userAgent = fmt .Sprintf ("dbc-cli/%s (%s; %s)" ,
45+ Version , runtime .GOOS , runtime .GOARCH )
46+
47+ // many CI systems set CI=true in the env so let's check for that
48+ if ci := os .Getenv ("CI" ); ci != "" {
49+ if val , _ := strconv .ParseBool (ci ); val {
50+ userAgent += " CI"
51+ }
52+ }
4153}
4254
4355func makereq (u string ) (resp * http.Response , err error ) {
@@ -50,8 +62,7 @@ func makereq(u string) (resp *http.Response, err error) {
5062 Method : http .MethodGet ,
5163 URL : uri ,
5264 Header : http.Header {
53- "User-Agent" : []string {fmt .Sprintf ("dbc-cli/%s (%s; %s)" ,
54- Version , runtime .GOOS , runtime .GOARCH )},
65+ "User-Agent" : []string {userAgent },
5566 },
5667 }
5768
You can’t perform that action at this time.
0 commit comments