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

Side by Side Diff: logdog/server/service/service.go

Issue 2219023003: Update APIs to use new Google cloud paths. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package service 5 package service
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
(...skipping 14 matching lines...) Expand all
25 "github.com/luci/luci-go/common/logging/gologger" 25 "github.com/luci/luci-go/common/logging/gologger"
26 "github.com/luci/luci-go/common/tsmon" 26 "github.com/luci/luci-go/common/tsmon"
27 "github.com/luci/luci-go/common/tsmon/target" 27 "github.com/luci/luci-go/common/tsmon/target"
28 "github.com/luci/luci-go/grpc/prpc" 28 "github.com/luci/luci-go/grpc/prpc"
29 "github.com/luci/luci-go/logdog/api/config/svcconfig" 29 "github.com/luci/luci-go/logdog/api/config/svcconfig"
30 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/services/v1" 30 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/services/v1"
31 "github.com/luci/luci-go/logdog/common/storage" 31 "github.com/luci/luci-go/logdog/common/storage"
32 "github.com/luci/luci-go/logdog/common/storage/bigtable" 32 "github.com/luci/luci-go/logdog/common/storage/bigtable"
33 "github.com/luci/luci-go/logdog/server/retryServicesClient" 33 "github.com/luci/luci-go/logdog/server/retryServicesClient"
34 "github.com/luci/luci-go/logdog/server/service/config" 34 "github.com/luci/luci-go/logdog/server/service/config"
35
36 "cloud.google.com/go/compute/metadata"
35 "golang.org/x/net/context" 37 "golang.org/x/net/context"
36 » "google.golang.org/cloud" 38 » "google.golang.org/api/option"
37 » "google.golang.org/cloud/compute/metadata"
38 ) 39 )
39 40
40 var ( 41 var (
41 // ErrInvalidConfig is an error that is returned when the supplied 42 // ErrInvalidConfig is an error that is returned when the supplied
42 // configuration is invalid. 43 // configuration is invalid.
43 ErrInvalidConfig = errors.New("invalid configuration") 44 ErrInvalidConfig = errors.New("invalid configuration")
44 45
45 // CoordinatorScopes is the set of OAuth2 scopes to use for the Coordina tor 46 // CoordinatorScopes is the set of OAuth2 scopes to use for the Coordina tor
46 // client. 47 // client.
47 CoordinatorScopes = []string{ 48 CoordinatorScopes = []string{
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 }) 386 })
386 if err != nil { 387 if err != nil {
387 log.WithError(err).Errorf(c, "Failed to create BigTable Authenti cator.") 388 log.WithError(err).Errorf(c, "Failed to create BigTable Authenti cator.")
388 return nil, err 389 return nil, err
389 } 390 }
390 391
391 bt, err := bigtable.New(c, bigtable.Options{ 392 bt, err := bigtable.New(c, bigtable.Options{
392 Project: btcfg.Project, 393 Project: btcfg.Project,
393 Instance: btcfg.Instance, 394 Instance: btcfg.Instance,
394 LogTable: btcfg.LogTableName, 395 LogTable: btcfg.LogTableName,
395 » » ClientOptions: []cloud.ClientOption{ 396 » » ClientOptions: []option.ClientOption{
396 » » » cloud.WithTokenSource(a.TokenSource()), 397 » » » option.WithTokenSource(a.TokenSource()),
397 }, 398 },
398 }) 399 })
399 if err != nil { 400 if err != nil {
400 return nil, err 401 return nil, err
401 } 402 }
402 return bt, nil 403 return bt, nil
403 } 404 }
404 405
405 // GSClient returns an authenticated Google Storage client instance. 406 // GSClient returns an authenticated Google Storage client instance.
406 func (s *Service) GSClient(c context.Context) (gs.Client, error) { 407 func (s *Service) GSClient(c context.Context) (gs.Client, error) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // 455 //
455 // An optional permutation functon can be provided to modify those Options 456 // An optional permutation functon can be provided to modify those Options
456 // before the Authenticator is created. 457 // before the Authenticator is created.
457 func (s *Service) AuthenticatedClient(c context.Context, f func(o *auth.Options) ) (*http.Client, error) { 458 func (s *Service) AuthenticatedClient(c context.Context, f func(o *auth.Options) ) (*http.Client, error) {
458 a, err := s.Authenticator(c, f) 459 a, err := s.Authenticator(c, f)
459 if err != nil { 460 if err != nil {
460 return nil, err 461 return nil, err
461 } 462 }
462 return a.Client() 463 return a.Client()
463 } 464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698