OLD | NEW |
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 prod | 5 package prod |
6 | 6 |
7 import ( | 7 import ( |
8 "time" | 8 "time" |
9 | 9 |
10 » "github.com/luci/gae" | 10 » "github.com/luci/gae/service/info" |
11 "golang.org/x/net/context" | 11 "golang.org/x/net/context" |
12 "google.golang.org/appengine" | 12 "google.golang.org/appengine" |
13 ) | 13 ) |
14 | 14 |
15 // useGI adds a gae.GlobalInfo implementation to context, accessible | 15 // useGI adds a gae.GlobalInfo implementation to context, accessible |
16 // by gae.GetGI(c) | 16 // by gae.GetGI(c) |
17 func useGI(c context.Context) context.Context { | 17 func useGI(c context.Context) context.Context { |
18 » return gae.SetGIFactory(c, func(ci context.Context) gae.GlobalInfo { | 18 » return info.SetFactory(c, func(ci context.Context) info.Interface { |
19 return giImpl{ci} | 19 return giImpl{ci} |
20 }) | 20 }) |
21 } | 21 } |
22 | 22 |
23 type giImpl struct{ context.Context } | 23 type giImpl struct{ context.Context } |
24 | 24 |
25 func (g giImpl) AccessToken(scopes ...string) (token string, expiry time.Time, e
rr error) { | 25 func (g giImpl) AccessToken(scopes ...string) (token string, expiry time.Time, e
rr error) { |
26 return appengine.AccessToken(g, scopes...) | 26 return appengine.AccessToken(g, scopes...) |
27 } | 27 } |
28 func (g giImpl) AppID() string { | 28 func (g giImpl) AppID() string { |
(...skipping 19 matching lines...) Expand all Loading... |
48 } | 48 } |
49 func (g giImpl) ModuleHostname(module, version, instance string) (string, error)
{ | 49 func (g giImpl) ModuleHostname(module, version, instance string) (string, error)
{ |
50 return appengine.ModuleHostname(g, module, version, instance) | 50 return appengine.ModuleHostname(g, module, version, instance) |
51 } | 51 } |
52 func (g giImpl) ModuleName() (name string) { | 52 func (g giImpl) ModuleName() (name string) { |
53 return appengine.ModuleName(g) | 53 return appengine.ModuleName(g) |
54 } | 54 } |
55 func (g giImpl) Namespace(namespace string) (context.Context, error) { | 55 func (g giImpl) Namespace(namespace string) (context.Context, error) { |
56 return appengine.Namespace(g, namespace) | 56 return appengine.Namespace(g, namespace) |
57 } | 57 } |
58 func (g giImpl) PublicCertificates() ([]gae.GICertificate, error) { | 58 func (g giImpl) PublicCertificates() ([]info.Certificate, error) { |
59 certs, err := appengine.PublicCertificates(g) | 59 certs, err := appengine.PublicCertificates(g) |
60 if err != nil { | 60 if err != nil { |
61 return nil, err | 61 return nil, err |
62 } | 62 } |
63 » ret := make([]gae.GICertificate, len(certs)) | 63 » ret := make([]info.Certificate, len(certs)) |
64 for i, c := range certs { | 64 for i, c := range certs { |
65 » » ret[i] = (gae.GICertificate)(c) | 65 » » ret[i] = info.Certificate(c) |
66 } | 66 } |
67 return ret, nil | 67 return ret, nil |
68 } | 68 } |
69 func (g giImpl) RequestID() string { | 69 func (g giImpl) RequestID() string { |
70 return appengine.RequestID(g) | 70 return appengine.RequestID(g) |
71 } | 71 } |
72 func (g giImpl) ServerSoftware() string { | 72 func (g giImpl) ServerSoftware() string { |
73 return appengine.ServerSoftware() | 73 return appengine.ServerSoftware() |
74 } | 74 } |
75 func (g giImpl) ServiceAccount() (string, error) { | 75 func (g giImpl) ServiceAccount() (string, error) { |
76 return appengine.ServiceAccount(g) | 76 return appengine.ServiceAccount(g) |
77 } | 77 } |
78 func (g giImpl) SignBytes(bytes []byte) (keyName string, signature []byte, err e
rror) { | 78 func (g giImpl) SignBytes(bytes []byte) (keyName string, signature []byte, err e
rror) { |
79 return appengine.SignBytes(g, bytes) | 79 return appengine.SignBytes(g, bytes) |
80 } | 80 } |
81 func (g giImpl) VersionID() string { | 81 func (g giImpl) VersionID() string { |
82 return appengine.VersionID(g) | 82 return appengine.VersionID(g) |
83 } | 83 } |
OLD | NEW |