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

Unified Diff: tokenserver/appengine/impl/serviceaccounts/rpc_import_service_accounts_configs.go

Issue 2993023002: tokenserver: Boilerplate for loading and serving service_accounts.cfg. (Closed)
Patch Set: add test Created 3 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 side-by-side diff with in-line comments
Download patch
Index: tokenserver/appengine/impl/serviceaccounts/rpc_import_service_accounts_configs.go
diff --git a/tokenserver/appengine/impl/serviceaccounts/rpc_import_service_accounts_configs.go b/tokenserver/appengine/impl/serviceaccounts/rpc_import_service_accounts_configs.go
index a2a31acfe0e70576a4c847b2afb9479b94960e89..0466ad8418b9c820579123d40872d68769bbc484 100644
--- a/tokenserver/appengine/impl/serviceaccounts/rpc_import_service_accounts_configs.go
+++ b/tokenserver/appengine/impl/serviceaccounts/rpc_import_service_accounts_configs.go
@@ -10,15 +10,23 @@ import (
"google.golang.org/grpc/codes"
"github.com/golang/protobuf/ptypes/empty"
+
+ "github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/tokenserver/api/admin/v1"
)
-// ImportServiceAccountsConfigsRPC implements Admin.ImportServiceAccountsConfigs
+// ImportServiceAccountsConfigsRPC implements admin.ImportServiceAccountsConfigs
// method.
type ImportServiceAccountsConfigsRPC struct {
+ RulesCache *RulesCache // usually GlobalRulesCache, but replaced in tests
}
// ImportServiceAccountsConfigs fetches configs from from luci-config right now.
func (r *ImportServiceAccountsConfigsRPC) ImportServiceAccountsConfigs(c context.Context, _ *empty.Empty) (*admin.ImportedConfigs, error) {
- return nil, grpc.Errorf(codes.Unavailable, "not implemented")
+ rev, err := r.RulesCache.ImportConfigs(c)
+ if err != nil {
+ logging.WithError(err).Errorf(c, "Failed to fetch service accounts configs")
+ return nil, grpc.Errorf(codes.Internal, err.Error())
+ }
+ return &admin.ImportedConfigs{Revision: rev}, nil
}

Powered by Google App Engine
This is Rietveld 408576698