Skip to content

Commit 681907d

Browse files
author
Yushu.Kozaki
committed
fix: retain existing variables and mark them deprecated
1 parent 6e25048 commit 681907d

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

constant.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ package gcpen
33
const (
44
EnvKeyProjectID = "GCP_PROJECT" // for Google Cloud Functions
55
EnvKeyGoogleCloudProject = "GOOGLE_CLOUD_PROJECT" // for Google App Engine
6-
EnvKeyGAEServiceName = "GAE_SERVICE" // for Google App Engine
7-
EnvKeyGAEServiceVersion = "GAE_VERSION" // for Google App Engine
8-
EnvKeyRUNServiceName = "K_SERVICE" // for Google Cloud Run
9-
EnvKeyRUNServiceRevision = "K_REVISION" // for Google Cloud Run
6+
7+
// Deprecated
8+
EnvKeyServiceName = "GAE_SERVICE" // for Google App Engine
9+
// Deprecated
10+
EnvKeyServiceVersion = "GAE_VERSION" // for Google App Engine
11+
12+
EnvKeyGAEServiceName = "GAE_SERVICE" // for Google App Engine
13+
EnvKeyGAEServiceVersion = "GAE_VERSION" // for Google App Engine
14+
EnvKeyRUNServiceName = "K_SERVICE" // for Google Cloud Run
15+
EnvKeyRUNServiceRevision = "K_REVISION" // for Google Cloud Run
1016
)

environ.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ import (
77
var (
88
// ProjectID - Google Cloud Platform Project ID
99
ProjectID = getProjectID()
10+
11+
// ServiceName - Google App Engine service name
12+
// Deprecated
13+
ServiceName = os.Getenv(EnvKeyServiceName)
14+
15+
// ServiceVersion - Google App Engine service version
16+
// Deprecated
17+
ServiceVersion = os.Getenv(EnvKeyServiceVersion)
18+
1019
// GAEServiceName - Google App Engine service name
1120
GAEServiceName = os.Getenv(EnvKeyGAEServiceName)
1221
// GAEServiceVersion - Google App Engine service version
@@ -34,6 +43,14 @@ func getProjectID() string {
3443
// Reload - Reload environment variables.
3544
func Reload() {
3645
ProjectID = getProjectID()
46+
47+
// Deprecated
48+
// ServiceName - Deprecated
49+
ServiceName = os.Getenv(EnvKeyServiceName)
50+
// Deprecated
51+
// ServiceVersion - Deprecated
52+
ServiceVersion = os.Getenv(EnvKeyServiceVersion)
53+
3754
GAEServiceName = os.Getenv(EnvKeyGAEServiceName)
3855
GAEServiceVersion = os.Getenv(EnvKeyGAEServiceVersion)
3956
RUNServiceName = os.Getenv(EnvKeyRUNServiceName)

environ_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ func TestEnviron(t *testing.T) {
2626
if ProjectID != testProject {
2727
t.Fatalf("unexpected, expected: %s, actual: %#v", testProject, ProjectID)
2828
}
29+
30+
// Deprecated
31+
if ServiceName != testGAEService {
32+
t.Fatalf("unexpected, expected: %s, actual: %#v", testGAEService, ServiceName)
33+
}
34+
// Deprecated
35+
if ServiceVersion != testGAEVersion {
36+
t.Fatalf("unexpected, expected: %s, actual: %#v", testGAEVersion, ServiceVersion)
37+
}
38+
2939
if GAEServiceName != testGAEService {
3040
t.Fatalf("unexpected, expected: %s, actual: %#v", testGAEService, GAEServiceName)
3141
}

0 commit comments

Comments
 (0)