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

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

Issue 2537743002: Add HTTP User Agent flag for cipd. (Closed)
Patch Set: Clarify help text 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 a94381f4d331650370cb23342c0a927426b71be5..bfad54021d40538197958fbb828dd9b0148cb759 100644
--- a/cipd/client/cmd/cipd/main.go
+++ b/cipd/client/cmd/cipd/main.go
@@ -235,10 +235,13 @@ 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{})
}
@@ -252,9 +255,14 @@ func (opts *ClientOptions) makeCipdClient(ctx context.Context, root string) (cip
if err != nil {
return nil, err
}
+ ua := cipd.UserAgent
+ if opts.userAgent != "" {
+ ua = fmt.Sprintf("%s/%s", opts.userAgent, ua)
+ }
return cipd.NewClient(cipd.ClientOptions{
ServiceURL: opts.serviceURL,
Root: root,
+ UserAgent: ua,
CacheDir: opts.cacheDir,
AuthenticatedClient: client,
AnonymousClient: http.DefaultClient,
« 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