From d8ba9d6c175596d5517faeeb51246a6e5f925e31 Mon Sep 17 00:00:00 2001 From: Dave Day Date: Thu, 22 Jan 2015 16:09:47 +1100 Subject: [PATCH] google/appengine: change managed VMs context to context.Context This follows the change to the google.golang.org/appengine packages to use the standard context.Context type throughout. Change-Id: I91b456105ee29f2088c3646145ea0a940f8ffaf4 Reviewed-on: https://go-review.googlesource.com/3172 Reviewed-by: Burcu Dogan Reviewed-by: David Symonds --- google/appengine.go | 2 +- google/appenginevm.go | 5 +++-- google/source_appengine.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/google/appengine.go b/google/appengine.go index 24ffad0..3fb36b4 100644 --- a/google/appengine.go +++ b/google/appengine.go @@ -19,7 +19,7 @@ import ( // If you are implementing a 3-legged OAuth 2.0 flow on App Engine // that involves user accounts, see oauth2.Config instead. // -// You are required to provide a valid appengine.Context as context. +// The provided context must have come from appengine.NewContext. func AppEngineTokenSource(ctx oauth2.Context, scope ...string) oauth2.TokenSource { return &appEngineTokenSource{ ctx: ctx, diff --git a/google/appenginevm.go b/google/appenginevm.go index f31f0d3..daf9a9f 100644 --- a/google/appenginevm.go +++ b/google/appenginevm.go @@ -9,6 +9,7 @@ package google import ( "time" + "golang.org/x/net/context" "golang.org/x/oauth2" "google.golang.org/appengine" ) @@ -18,7 +19,7 @@ import ( // If you are implementing a 3-legged OAuth 2.0 flow on App Engine // that involves user accounts, see oauth2.Config instead. // -// You are required to provide a valid appengine.Context as context. +// The provided context must have come from appengine.NewContext. func AppEngineTokenSource(ctx oauth2.Context, scope ...string) oauth2.TokenSource { return &appEngineTokenSource{ ctx: ctx, @@ -28,7 +29,7 @@ func AppEngineTokenSource(ctx oauth2.Context, scope ...string) oauth2.TokenSourc } var aeVMFetcherFunc = func(ctx oauth2.Context, scope ...string) (string, time.Time, error) { - c, ok := ctx.(appengine.Context) + c, ok := ctx.(context.Context) if !ok { return "", time.Time{}, errInvalidContext } diff --git a/google/source_appengine.go b/google/source_appengine.go index d0eb3da..689a1c7 100644 --- a/google/source_appengine.go +++ b/google/source_appengine.go @@ -21,7 +21,7 @@ var ( aeTokens = make(map[string]*tokenLock) // key is '\0'-separated scopes ) -var errInvalidContext = errors.New("oauth2: a valid appengine.Context is required") +var errInvalidContext = errors.New("oauth2: context must come from appengine.NewContext") type tokenLock struct { mu sync.Mutex // guards t; held while updating t