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

Unified Diff: tokenserver/appengine/impl/serviceaccounts/config_validation.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/config_validation.go
diff --git a/tokenserver/appengine/impl/serviceaccounts/config_validation.go b/tokenserver/appengine/impl/serviceaccounts/config_validation.go
new file mode 100644
index 0000000000000000000000000000000000000000..907e33c085a2b8d79a0fbc7cc60e50446c48d826
--- /dev/null
+++ b/tokenserver/appengine/impl/serviceaccounts/config_validation.go
@@ -0,0 +1,34 @@
+// Copyright 2017 The LUCI Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package serviceaccounts
+
+import (
+ "github.com/luci/luci-go/common/config/validation"
+
+ "github.com/luci/luci-go/tokenserver/api/admin/v1"
+ "github.com/luci/luci-go/tokenserver/appengine/impl/utils/policy"
+)
+
+// validateConfigs validates the structure of configs fetched by fetchConfigs.
+func validateConfigs(bundle policy.ConfigBundle, ctx *validation.Context) {
+ ctx.SetFile(serviceAccountsCfg)
+ cfg, ok := bundle[serviceAccountsCfg].(*admin.ServiceAccountsPermissions)
+ if !ok {
+ ctx.Error("unexpectedly wrong proto type %T", cfg)
+ return
+ }
+
+ // TODO(vadimsh): Validate cfg.Rules.
+}

Powered by Google App Engine
This is Rietveld 408576698