diff --git a/google/appengine.go b/google/appengine.go index 4243f4c..50d918b 100644 --- a/google/appengine.go +++ b/google/appengine.go @@ -14,8 +14,8 @@ import ( "golang.org/x/oauth2" ) -// Set at init time by appenginevm_hook.go. If true, we are on App Engine Managed VMs. -var appengineVM bool +// appengineFlex is set at init time by appengineflex_hook.go. If true, we are on App Engine Flex. +var appengineFlex bool // Set at init time by appengine_hook.go. If nil, we're not on App Engine. var appengineTokenFunc func(c context.Context, scopes ...string) (token string, expiry time.Time, err error) diff --git a/google/appengine_hook.go b/google/appengine_hook.go index 6f66411..56669ea 100644 --- a/google/appengine_hook.go +++ b/google/appengine_hook.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build appengine +// +build appengine appenginevm package google diff --git a/google/appengineflex_hook.go b/google/appengineflex_hook.go new file mode 100644 index 0000000..5d0231a --- /dev/null +++ b/google/appengineflex_hook.go @@ -0,0 +1,11 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build appenginevm + +package google + +func init() { + appengineFlex = true // Flex doesn't support appengine.AccessToken; depend on metadata server. +} diff --git a/google/appenginevm_hook.go b/google/appenginevm_hook.go deleted file mode 100644 index 1074780..0000000 --- a/google/appenginevm_hook.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The oauth2 Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build appenginevm - -package google - -import "google.golang.org/appengine" - -func init() { - appengineVM = true - appengineTokenFunc = appengine.AccessToken - appengineAppIDFunc = appengine.AppID -} diff --git a/google/default.go b/google/default.go index b45e796..004ed4e 100644 --- a/google/default.go +++ b/google/default.go @@ -81,7 +81,7 @@ func FindDefaultCredentials(ctx context.Context, scope ...string) (*DefaultCrede } // Third, if we're on Google App Engine use those credentials. - if appengineTokenFunc != nil && !appengineVM { + if appengineTokenFunc != nil && !appengineFlex { return &DefaultCredentials{ ProjectID: appengineAppIDFunc(ctx), TokenSource: AppEngineTokenSource(ctx, scope...),