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

Side by Side Diff: impl/memory/info.go

Issue 1766593002: Add a MustNamespace that panics if the namespace wasn't valid (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Add MustNamespace to the interface Created 4 years, 9 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
« no previous file with comments | « impl/dummy/dummy.go ('k') | impl/memory/info_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package memory 5 package memory
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "regexp" 9 "regexp"
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return gi.namespace 49 return gi.namespace
50 } 50 }
51 51
52 func (gi *giImpl) Namespace(ns string) (ret context.Context, err error) { 52 func (gi *giImpl) Namespace(ns string) (ret context.Context, err error) {
53 if !validNamespace.MatchString(ns) { 53 if !validNamespace.MatchString(ns) {
54 return nil, fmt.Errorf("appengine: namespace %q does not match / %s/", ns, validNamespace) 54 return nil, fmt.Errorf("appengine: namespace %q does not match / %s/", ns, validNamespace)
55 } 55 }
56 return context.WithValue(gi.c, giContextKey, &globalInfoData{gi.appid, n s}), nil 56 return context.WithValue(gi.c, giContextKey, &globalInfoData{gi.appid, n s}), nil
57 } 57 }
58 58
59 func (gi *giImpl) MustNamespace(ns string) context.Context {
60 ret, err := gi.Namespace(ns)
61 if err != nil {
62 panic(err)
63 }
64 return ret
65 }
66
59 func (gi *giImpl) AppID() string { 67 func (gi *giImpl) AppID() string {
60 return gi.appid 68 return gi.appid
61 } 69 }
62 70
63 func (gi *giImpl) FullyQualifiedAppID() string { 71 func (gi *giImpl) FullyQualifiedAppID() string {
64 return gi.appid 72 return gi.appid
65 } 73 }
66 74
67 func (gi *giImpl) IsDevAppServer() bool { 75 func (gi *giImpl) IsDevAppServer() bool {
68 return true 76 return true
69 } 77 }
70 78
71 func (gi *giImpl) VersionID() string { 79 func (gi *giImpl) VersionID() string {
72 // VersionID returns X.Y where Y is autogenerated by appengine, and X is 80 // VersionID returns X.Y where Y is autogenerated by appengine, and X is
73 // whatever's in app.yaml. 81 // whatever's in app.yaml.
74 return "testVersionID.1" 82 return "testVersionID.1"
75 } 83 }
OLDNEW
« no previous file with comments | « impl/dummy/dummy.go ('k') | impl/memory/info_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698