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

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

Issue 1838303002: Use native Pub/Sub library primitives. (Closed) Base URL: https://github.com/luci/luci-go@logdog-go1.6
Patch Set: Use "Topic" instead of "NewTopic" ... don't want to create :) Created 4 years, 9 months 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 | « appengine/tsmon/middleware.go ('k') | client/cmd/logdog_butler/output_pubsub.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/logdog_butler/main.go
diff --git a/client/cmd/logdog_butler/main.go b/client/cmd/logdog_butler/main.go
index e4a39c7e8fbba611650282d743a7ca3cec08f7fb..fcd50a4e8028d446b9466d63933ffda5d4dd9faf 100644
--- a/client/cmd/logdog_butler/main.go
+++ b/client/cmd/logdog_butler/main.go
@@ -29,6 +29,7 @@ import (
"github.com/luci/luci-go/common/paniccatcher"
"github.com/maruel/subcommands"
"golang.org/x/net/context"
+ "golang.org/x/oauth2"
)
const (
@@ -117,15 +118,23 @@ func (a *application) addFlags(fs *flag.FlagSet) {
"of wire-format efficiency.")
}
+func (a *application) authenticator(ctx context.Context) (*auth.Authenticator, error) {
+ opts, err := a.authFlags.Options()
+ if err != nil {
+ return nil, err
+ }
+ opts.Context = ctx
+ return auth.NewAuthenticator(auth.SilentLogin, opts), nil
+}
+
func (a *application) authenticatedClient(ctx context.Context) (*http.Client, error) {
if a.client == nil {
- opts, err := a.authFlags.Options()
+ authenticator, err := a.authenticator(ctx)
if err != nil {
return nil, err
}
- opts.Context = ctx
- client, err := auth.NewAuthenticator(auth.SilentLogin, opts).Client()
+ client, err := authenticator.Client()
if err != nil {
return nil, err
}
@@ -134,6 +143,14 @@ func (a *application) authenticatedClient(ctx context.Context) (*http.Client, er
return a.client, nil
}
+func (a *application) tokenSource(ctx context.Context) (oauth2.TokenSource, error) {
+ authenticator, err := a.authenticator(ctx)
+ if err != nil {
+ return nil, err
+ }
+ return authenticator.TokenSource(), nil
+}
+
func (a *application) configOutput() (output.Output, error) {
factory := a.outputConfig.getFactory()
if factory == nil {
« no previous file with comments | « appengine/tsmon/middleware.go ('k') | client/cmd/logdog_butler/output_pubsub.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698