Skip to content

Commit 7d17be6

Browse files
committed
Provide a way to define extra UserAgent fields via env vars
1 parent 6ac5f7a commit 7d17be6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

configuration/network.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package configuration
1818
import (
1919
"fmt"
2020
"net/url"
21+
"os"
2122
"runtime"
2223

2324
"github.com/arduino/arduino-cli/cli/globals"
@@ -34,12 +35,18 @@ func UserAgent(settings *viper.Viper) string {
3435
subComponent = " " + subComponent
3536
}
3637

37-
return fmt.Sprintf("%s/%s%s (%s; %s; %s) Commit:%s",
38+
extendedUA := os.Getenv("ARDUINO_CLI_USER_AGENT_EXTENSION")
39+
if extendedUA != "" {
40+
extendedUA = " " + extendedUA
41+
}
42+
43+
return fmt.Sprintf("%s/%s%s (%s; %s; %s) Commit:%s%s",
3844
globals.VersionInfo.Application,
3945
globals.VersionInfo.VersionString,
4046
subComponent,
4147
runtime.GOARCH, runtime.GOOS, runtime.Version(),
42-
globals.VersionInfo.Commit)
48+
globals.VersionInfo.Commit,
49+
extendedUA)
4350
}
4451

4552
// NetworkProxy returns the proxy configuration (mainly used by HTTP clients)

0 commit comments

Comments
 (0)