1// Copyright 2011 Google Inc. All rights reserved. 2// Use of this source code is governed by the Apache 2.0 3// license that can be found in the LICENSE file. 4 5package internal 6 7import ( 8 "os" 9 10 netcontext "golang.org/x/net/context" 11) 12 13var ( 14 // This is set to true in identity_classic.go, which is behind the appengine build tag. 15 // The appengine build tag is set for the first generation runtimes (<= Go 1.9) but not 16 // the second generation runtimes (>= Go 1.11), so this indicates whether we're on a 17 // first-gen runtime. See IsStandard below for the second-gen check. 18 appengineStandard bool 19 20 // This is set to true in identity_flex.go, which is behind the appenginevm build tag. 21 appengineFlex bool 22) 23 24// AppID is the implementation of the wrapper function of the same name in 25// ../identity.go. See that file for commentary. 26func AppID(c netcontext.Context) string { 27 return appID(FullyQualifiedAppID(c)) 28} 29 30// IsStandard is the implementation of the wrapper function of the same name in 31// ../appengine.go. See that file for commentary. 32func IsStandard() bool { 33 // appengineStandard will be true for first-gen runtimes (<= Go 1.9) but not 34 // second-gen (>= Go 1.11). Second-gen runtimes set $GAE_ENV so we use that 35 // to check if we're on a second-gen runtime. 36 return appengineStandard || os.Getenv("GAE_ENV") == "standard" 37} 38 39// IsFlex is the implementation of the wrapper function of the same name in 40// ../appengine.go. See that file for commentary. 41func IsFlex() bool { 42 return appengineFlex 43} 44 45// IsAppEngine is the implementation of the wrapper function of the same name in 46// ../appengine.go. See that file for commentary. 47func IsAppEngine() bool { 48 return IsStandard() || IsFlex() 49} 50