google-cloud-env 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +2 -2
- data/lib/google/cloud/env.rb +57 -10
- data/lib/google/cloud/env/version.rb +1 -1
- metadata +23 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fe4fb0b390a089e7efb8cde45fb7f6df9e86b25ab81b84292a67fe481341137
|
4
|
+
data.tar.gz: 5efcbb333c4796812b99332cfc9919ae00f1e39104f092edc1392ba558d40caf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b74d450efba00970ed06f659dbedca0391f3128bb9ce6e0abb7d5580c18d55fd58a65ac81ffb6be5a10bc4b07ca41c9121f32df1ef87de455b96993d716150f0
|
7
|
+
data.tar.gz: 2dde707316115cda0096dbc949d8a6f8dae5f4110540a986bcb89aa1cbd258aebc496ca159b4a47f17fc2dda4277ac0d83c332a9519186451ec027f67633ca0d
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -24,7 +24,7 @@ be able to accept your pull requests.
|
|
24
24
|
In order to use the google-cloud-env console and run the project's tests,
|
25
25
|
there is a small amount of setup:
|
26
26
|
|
27
|
-
1. Install Ruby. google-cloud-env requires Ruby 2.
|
27
|
+
1. Install Ruby. google-cloud-env requires Ruby 2.4+. You may choose to
|
28
28
|
manage your Ruby and gem installations with [RVM](https://rvm.io/),
|
29
29
|
[rbenv](https://github.com/rbenv/rbenv), or
|
30
30
|
[chruby](https://github.com/postmodern/chruby).
|
data/README.md
CHANGED
@@ -7,11 +7,11 @@ apps running on Google Cloud Platform.
|
|
7
7
|
|
8
8
|
## Supported Ruby Versions
|
9
9
|
|
10
|
-
This library is supported on Ruby 2.
|
10
|
+
This library is supported on Ruby 2.4+.
|
11
11
|
|
12
12
|
Google provides official support for Ruby versions that are actively supported
|
13
13
|
by Ruby Core—that is, Ruby versions that are either in normal maintenance or in
|
14
|
-
security maintenance, and not end of life. Currently, this means Ruby 2.
|
14
|
+
security maintenance, and not end of life. Currently, this means Ruby 2.4 and
|
15
15
|
later. Older versions of Ruby _may_ still work, but are unsupported and not
|
16
16
|
recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
|
17
17
|
about the Ruby support schedule.
|
data/lib/google/cloud/env.rb
CHANGED
@@ -114,8 +114,17 @@ module Google
|
|
114
114
|
@retry_backoff_factor = retry_backoff_factor
|
115
115
|
@retry_max_interval = retry_max_interval
|
116
116
|
request_opts = { timeout: request_timeout, open_timeout: open_timeout }
|
117
|
-
@connection = connection ||
|
118
|
-
|
117
|
+
@connection = connection || ::Faraday.new(url: METADATA_HOST, request: request_opts)
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# Determine whether the application is running on a Knative-based
|
122
|
+
# hosting platform, such as Cloud Run or Cloud Functions.
|
123
|
+
#
|
124
|
+
# @return [Boolean]
|
125
|
+
#
|
126
|
+
def knative?
|
127
|
+
env["K_SERVICE"] ? true : false
|
119
128
|
end
|
120
129
|
|
121
130
|
##
|
@@ -127,6 +136,26 @@ module Google
|
|
127
136
|
env["GAE_INSTANCE"] ? true : false
|
128
137
|
end
|
129
138
|
|
139
|
+
##
|
140
|
+
# Determine whether the application is running on Google App Engine
|
141
|
+
# Flexible Environment.
|
142
|
+
#
|
143
|
+
# @return [Boolean]
|
144
|
+
#
|
145
|
+
def app_engine_flexible?
|
146
|
+
app_engine? && env["GAE_ENV"] != "standard"
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Determine whether the application is running on Google App Engine
|
151
|
+
# Standard Environment.
|
152
|
+
#
|
153
|
+
# @return [Boolean]
|
154
|
+
#
|
155
|
+
def app_engine_standard?
|
156
|
+
app_engine? && env["GAE_ENV"] == "standard"
|
157
|
+
end
|
158
|
+
|
130
159
|
##
|
131
160
|
# Determine whether the application is running on Google Kubernetes
|
132
161
|
# Engine (GKE).
|
@@ -171,7 +200,7 @@ module Google
|
|
171
200
|
# @return [Boolean]
|
172
201
|
#
|
173
202
|
def raw_compute_engine?
|
174
|
-
!app_engine? && !cloud_shell? && metadata? && !kubernetes_engine?
|
203
|
+
!knative? && !app_engine? && !cloud_shell? && metadata? && !kubernetes_engine?
|
175
204
|
end
|
176
205
|
|
177
206
|
##
|
@@ -181,8 +210,7 @@ module Google
|
|
181
210
|
# @return [String,nil]
|
182
211
|
#
|
183
212
|
def project_id
|
184
|
-
env["GCLOUD_PROJECT"] || env["DEVSHELL_PROJECT_ID"] ||
|
185
|
-
lookup_metadata("project", "project-id")
|
213
|
+
env["GCLOUD_PROJECT"] || env["DEVSHELL_PROJECT_ID"] || lookup_metadata("project", "project-id")
|
186
214
|
end
|
187
215
|
|
188
216
|
##
|
@@ -284,6 +312,27 @@ module Google
|
|
284
312
|
lookup_metadata "instance", "attributes/#{key}"
|
285
313
|
end
|
286
314
|
|
315
|
+
##
|
316
|
+
# Returns the name of the running Knative service, or `nil` if the
|
317
|
+
# current code is not running on Knative.
|
318
|
+
#
|
319
|
+
# @return [String,nil]
|
320
|
+
#
|
321
|
+
def knative_service_id
|
322
|
+
env["K_SERVICE"]
|
323
|
+
end
|
324
|
+
alias knative_service_name knative_service_id
|
325
|
+
|
326
|
+
##
|
327
|
+
# Returns the revision of the running Knative service, or `nil` if the
|
328
|
+
# current code is not running on Knative.
|
329
|
+
#
|
330
|
+
# @return [String,nil]
|
331
|
+
#
|
332
|
+
def knative_service_revision
|
333
|
+
env["K_REVISION"]
|
334
|
+
end
|
335
|
+
|
287
336
|
##
|
288
337
|
# Returns the name of the running App Engine service, or `nil` if the
|
289
338
|
# current code is not running in App Engine.
|
@@ -293,6 +342,7 @@ module Google
|
|
293
342
|
def app_engine_service_id
|
294
343
|
env["GAE_SERVICE"]
|
295
344
|
end
|
345
|
+
alias app_engine_service_name app_engine_service_id
|
296
346
|
|
297
347
|
##
|
298
348
|
# Returns the version of the running App Engine service, or `nil` if the
|
@@ -340,8 +390,7 @@ module Google
|
|
340
390
|
# below is set in some older versions of GKE, and the file below is
|
341
391
|
# present in Kubernetes as of version 1.9, but it is possible that
|
342
392
|
# alternatives will need to be found in the future.
|
343
|
-
env["GKE_NAMESPACE_ID"] ||
|
344
|
-
::IO.read("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
393
|
+
env["GKE_NAMESPACE_ID"] || ::IO.read("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
|
345
394
|
rescue SystemCallError
|
346
395
|
nil
|
347
396
|
end
|
@@ -415,9 +464,7 @@ module Google
|
|
415
464
|
if retries_remaining >= 0
|
416
465
|
sleep retry_interval
|
417
466
|
retry_interval *= @retry_backoff_factor
|
418
|
-
if retry_interval > @retry_max_interval
|
419
|
-
retry_interval = @retry_max_interval
|
420
|
-
end
|
467
|
+
retry_interval = @retry_max_interval if retry_interval > @retry_max_interval
|
421
468
|
retry
|
422
469
|
end
|
423
470
|
error_result
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -25,63 +25,63 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: autotest-suffix
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: google-style
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.24.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.24.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
56
|
+
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '5.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '5.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest-
|
70
|
+
name: minitest-autotest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: minitest-focus
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
@@ -95,33 +95,33 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.1'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: minitest-rg
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '5.2'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '5.2'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: redcarpet
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: '3.0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: '3.0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: simplecov
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,14 +195,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
195
|
requirements:
|
196
196
|
- - ">="
|
197
197
|
- !ruby/object:Gem::Version
|
198
|
-
version: 2.
|
198
|
+
version: '2.4'
|
199
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
200
|
requirements:
|
201
201
|
- - ">="
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
|
-
rubygems_version: 3.0.
|
205
|
+
rubygems_version: 3.0.6
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: Google Cloud Platform hosting environment information.
|