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

Unified Diff: service/info/support/namespace.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: Lightning talk licenses. Created 4 years, 3 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 | « service/info/interface.go ('k') | service/info/wrapper.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/info/support/namespace.go
diff --git a/service/info/support/namespace.go b/service/info/support/namespace.go
new file mode 100644
index 0000000000000000000000000000000000000000..6cb2e90ebf5ac5a29fb6b3a0cca2a6b4e92f16f1
--- /dev/null
+++ b/service/info/support/namespace.go
@@ -0,0 +1,24 @@
+// Copyright 2015 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+// Package support provides Info-related support functionality. It is designed
+// to be used by implementing packages.
+package support
+
+import (
+ "fmt"
+ "regexp"
+)
+
+// validNamespace matches valid namespace names.
+var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`)
+
+// ValidNamespace will return an error if the supplied string is not a valid
+// namespace.
+func ValidNamespace(ns string) error {
+ if validNamespace.MatchString(ns) {
+ return nil
+ }
+ return fmt.Errorf("appengine: namespace %q does not match /%s/", ns, validNamespace)
+}
« no previous file with comments | « service/info/interface.go ('k') | service/info/wrapper.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698