Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: cipd/client/cmd/cipd/main.go

Issue 2537983002: Make user agent set via envvar, not CLI option (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cipd/client/cmd/cipd/main.go
diff --git a/cipd/client/cmd/cipd/main.go b/cipd/client/cmd/cipd/main.go
index bfad54021d40538197958fbb828dd9b0148cb759..6be94e10375a565a17e9854374ae7946c7a40065 100644
--- a/cipd/client/cmd/cipd/main.go
+++ b/cipd/client/cmd/cipd/main.go
@@ -235,13 +235,10 @@ type ClientOptions struct {
authFlags authcli.Flags
serviceURL string
cacheDir string
- userAgent string
}
func (opts *ClientOptions) registerFlags(f *flag.FlagSet) {
f.StringVar(&opts.serviceURL, "service-url", "", "URL of a backend to use instead of the default one.")
- f.StringVar(&opts.userAgent, "http-user-agent", "",
- "User Agent text to add. If specified, the UA will be '<this_option>/"+cipd.UserAgent+"'.")
f.StringVar(&opts.cacheDir, "cache-dir", "", "Directory for shared cache")
opts.authFlags.Register(f, auth.Options{})
}
@@ -256,8 +253,8 @@ func (opts *ClientOptions) makeCipdClient(ctx context.Context, root string) (cip
return nil, err
}
ua := cipd.UserAgent
- if opts.userAgent != "" {
- ua = fmt.Sprintf("%s/%s", opts.userAgent, ua)
+ if prefix := os.Getenv("CIPD_HTTP_USER_AGENT_PREFIX"); prefix != "" {
+ ua = fmt.Sprintf("%s/%s", prefix, ua)
}
return cipd.NewClient(cipd.ClientOptions{
ServiceURL: opts.serviceURL,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698