| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 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 serviceaccounts | 5 package serviceaccounts |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "golang.org/x/net/context" | 8 "golang.org/x/net/context" |
| 9 "google.golang.org/grpc" | 9 "google.golang.org/grpc" |
| 10 "google.golang.org/grpc/codes" | 10 "google.golang.org/grpc/codes" |
| 11 | 11 |
| 12 "github.com/golang/protobuf/ptypes/empty" | 12 "github.com/golang/protobuf/ptypes/empty" |
| 13 |
| 14 "github.com/luci/luci-go/common/logging" |
| 13 "github.com/luci/luci-go/tokenserver/api/admin/v1" | 15 "github.com/luci/luci-go/tokenserver/api/admin/v1" |
| 14 ) | 16 ) |
| 15 | 17 |
| 16 // ImportServiceAccountsConfigsRPC implements Admin.ImportServiceAccountsConfigs | 18 // ImportServiceAccountsConfigsRPC implements admin.ImportServiceAccountsConfigs |
| 17 // method. | 19 // method. |
| 18 type ImportServiceAccountsConfigsRPC struct { | 20 type ImportServiceAccountsConfigsRPC struct { |
| 21 RulesCache *RulesCache // usually GlobalRulesCache, but replaced in test
s |
| 19 } | 22 } |
| 20 | 23 |
| 21 // ImportServiceAccountsConfigs fetches configs from from luci-config right now. | 24 // ImportServiceAccountsConfigs fetches configs from from luci-config right now. |
| 22 func (r *ImportServiceAccountsConfigsRPC) ImportServiceAccountsConfigs(c context
.Context, _ *empty.Empty) (*admin.ImportedConfigs, error) { | 25 func (r *ImportServiceAccountsConfigsRPC) ImportServiceAccountsConfigs(c context
.Context, _ *empty.Empty) (*admin.ImportedConfigs, error) { |
| 23 » return nil, grpc.Errorf(codes.Unavailable, "not implemented") | 26 » rev, err := r.RulesCache.ImportConfigs(c) |
| 27 » if err != nil { |
| 28 » » logging.WithError(err).Errorf(c, "Failed to fetch service accoun
ts configs") |
| 29 » » return nil, grpc.Errorf(codes.Internal, err.Error()) |
| 30 » } |
| 31 » return &admin.ImportedConfigs{Revision: rev}, nil |
| 24 } | 32 } |
| OLD | NEW |