google-cloud-env 2.1.1 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 874603cbcc635840a5fa275335b574f242b5abe3100217d561189cd8c30ab12d
4
- data.tar.gz: f8756d74ac146f9a3148d5149e29fd1b718e1ab5be177aecd81cbac3507212d9
3
+ metadata.gz: e3d2a3f33d0f33823d9203719ac4c49862ed00b6b3b288b6851d83ca3358f8dc
4
+ data.tar.gz: 16e52c76711260d41d1f0018e022c38c9421b9ce26f4f1b36e63e58c42887d2b
5
5
  SHA512:
6
- metadata.gz: 6ad688117a2b8cc86596be5d2e0ec5f592f5734927756112a0cd82116d52cc0be6c24b8e8594d9d3ea010977e88275c5916cea676b2d50016973b58a7fd52649
7
- data.tar.gz: c347078193dd1cc9cab88f1222327f57d928cf246fad899dca010ad4481f4de7d15a3df924df1dcb42bb7860139d98952b222b53f91cde0c1985319f7d18b832
6
+ metadata.gz: cbdc0b547fea96b75eefa4b07724d725334258470b2bf932fc6c476c7d8f1f4edde22de46c4eb25dee06d38d5db3fa69344df9b40d1e6c8560a386aca7f62bc7
7
+ data.tar.gz: d8fd89b5762ec717e42d6b94cfab3a11a0e19c6eee961bc6e6119738d06a4d262936442f675928654a5b50b5e977f1498deff3c535ce4e22e16ff0c85774f436
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Release History
2
2
 
3
+ ### 2.3.1 (2025-05-23)
4
+
5
+ #### Bug Fixes
6
+
7
+ * Compatibility fix for JRuby 10 on non-Windows systems ([#86](https://github.com/googleapis/ruby-cloud-env/issues/86))
8
+
9
+ ### 2.3.0 (2025-04-30)
10
+
11
+ #### Features
12
+
13
+ * updated required ruby version to 3.1 ([#84](https://github.com/googleapis/ruby-cloud-env/issues/84))
14
+
15
+ ### 2.2.2 (2025-03-13)
16
+
17
+ #### Bug Fixes
18
+
19
+ * Updated dependencies to include base64 for Ruby 3.4 ([#81](https://github.com/googleapis/ruby-cloud-env/issues/81))
20
+
21
+ ### 2.2.1 (2024-10-04)
22
+
23
+ #### Bug Fixes
24
+
25
+ * Fixed edge cases in token expiration extraction ([#73](https://github.com/googleapis/ruby-cloud-env/issues/73))
26
+
27
+ ### 2.2.0 (2024-08-22)
28
+
29
+ #### Features
30
+
31
+ * Provide a query for whether a logging agent is expected in the current environment ([#70](https://github.com/googleapis/ruby-cloud-env/issues/70))
32
+ * Require Ruby 3.0 or later ([#71](https://github.com/googleapis/ruby-cloud-env/issues/71))
33
+
3
34
  ### 2.1.1 (2024-02-01)
4
35
 
5
36
  #### Bug Fixes
data/README.md CHANGED
@@ -10,7 +10,7 @@ Metadata Server.
10
10
 
11
11
  ## Supported Ruby Versions
12
12
 
13
- This library is supported on Ruby 2.7+.
13
+ This library is supported on Ruby 3.0+.
14
14
 
15
15
  In general, Google provides official support for CRuby versions that are
16
16
  actively supported by the Ruby Core team -- that is, Ruby versions that are
@@ -14,6 +14,7 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
+ require "base64"
17
18
  require "faraday"
18
19
  require "json"
19
20
 
@@ -670,6 +671,7 @@ module Google
670
671
  Errno::ETIMEDOUT,
671
672
  Timeout::Error
672
673
  ].freeze
674
+ private_constant :TRANSIENT_EXCEPTIONS
673
675
 
674
676
  ##
675
677
  # @private
@@ -693,6 +695,7 @@ module Google
693
695
  # than the previous old token. See internal issue b/311414224.
694
696
  #
695
697
  TOKEN_EXPIRY_BUFFER = 210
698
+ private_constant :TOKEN_EXPIRY_BUFFER
696
699
 
697
700
  ##
698
701
  # @private
@@ -806,7 +809,7 @@ module Google
806
809
  #
807
810
  def access_token_lifetime data
808
811
  json = JSON.parse data rescue nil
809
- return 0 unless json&.key? "expires_in"
812
+ return 0 unless json.respond_to?(:key?) && json.key?("expires_in")
810
813
  lifetime = json["expires_in"].to_i - TOKEN_EXPIRY_BUFFER
811
814
  lifetime = 0 if lifetime.negative?
812
815
  lifetime
@@ -818,9 +821,9 @@ module Google
818
821
  #
819
822
  def identity_token_lifetime data
820
823
  return 0 unless data =~ /^[\w=-]+\.([\w=-]+)\.[\w=-]+$/
821
- base64 = Base64.decode64 Regexp.last_match[1]
824
+ base64 = Base64.urlsafe_decode64 Regexp.last_match[1]
822
825
  json = JSON.parse base64 rescue nil
823
- return 0 unless json&.key? "exp"
826
+ return 0 unless json.respond_to?(:key?) && json&.key?("exp")
824
827
  lifetime = json["exp"].to_i - Time.now.to_i - TOKEN_EXPIRY_BUFFER
825
828
  lifetime = 0 if lifetime.negative?
826
829
  lifetime
@@ -119,11 +119,20 @@ module Google
119
119
  private_constant :WINDOWS_KEYPATH, :WINDOWS_KEYNAME, :LINUX_FILEPATH
120
120
 
121
121
  def load_product_name
122
- require "win32/registry"
123
- Win32::Registry::HKEY_LOCAL_MACHINE.open WINDOWS_KEYPATH do |reg|
124
- return [reg[WINDOWS_KEYNAME].to_s, :windows]
122
+ begin
123
+ require "win32/registry"
124
+ Win32::Registry::HKEY_LOCAL_MACHINE.open WINDOWS_KEYPATH do |reg|
125
+ return [reg[WINDOWS_KEYNAME].to_s, :windows]
126
+ end
127
+ rescue LoadError
128
+ # Fall through to the Linux routine
129
+ rescue StandardError => e
130
+ # With JRuby 10, a Fiddle::DLError is raised, In the case the fiddle gem is not
131
+ # loadable, safely assert the error type without relying on the Fiddle namespace
132
+ # having been loaded.
133
+ raise e unless e.class.name == "Fiddle::DLError" # rubocop:disable Style/ClassEqualityComparison
134
+ # Fall through to the Linux routine
125
135
  end
126
- rescue LoadError
127
136
  begin
128
137
  File.open LINUX_FILEPATH do |file|
129
138
  return [file.readline(chomp: true), :linux]
@@ -20,7 +20,7 @@ module Google
20
20
  # Library version
21
21
  # @return [String]
22
22
  #
23
- VERSION = "2.1.1".freeze
23
+ VERSION = "2.3.1".freeze
24
24
  end
25
25
  end
26
26
  end
@@ -497,6 +497,19 @@ module Google
497
497
  end
498
498
  alias container_engine_namespace_id kubernetes_engine_namespace_id
499
499
 
500
+ ##
501
+ # Determine whether the application is running in an environment where a
502
+ # Google Cloud logging agent is expected to be running. In such an
503
+ # environment, we expect that the standard output and error streams are
504
+ # likely to be parsed by the logging agent and log entries are written to
505
+ # the Google Cloud Logging service.
506
+ #
507
+ # @return [boolean]
508
+ #
509
+ def logging_agent_expected?
510
+ compute_engine? && !cloud_shell? && (app_engine? || knative? || kubernetes_engine?)
511
+ end
512
+
500
513
  ##
501
514
  # Returns the global instance of {Google::Cloud::Env}.
502
515
  #
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-02-01 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base64
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.2'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: faraday
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -59,11 +72,10 @@ homepage: https://github.com/googleapis/ruby-cloud-env
59
72
  licenses:
60
73
  - Apache-2.0
61
74
  metadata:
62
- changelog_uri: https://rubydoc.info/gems/google-cloud-env/2.1.1/CHANGELOG.md
75
+ changelog_uri: https://rubydoc.info/gems/google-cloud-env/2.3.1/CHANGELOG.md
63
76
  source_code_uri: https://github.com/googleapis/ruby-cloud-env
64
77
  bug_tracker_uri: https://github.com/googleapis/ruby-cloud-env/issues
65
- documentation_uri: https://rubydoc.info/gems/google-cloud-env/2.1.1
66
- post_install_message:
78
+ documentation_uri: https://rubydoc.info/gems/google-cloud-env/2.3.1
67
79
  rdoc_options: []
68
80
  require_paths:
69
81
  - lib
@@ -71,15 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
83
  requirements:
72
84
  - - ">="
73
85
  - !ruby/object:Gem::Version
74
- version: '2.7'
86
+ version: '3.1'
75
87
  required_rubygems_version: !ruby/object:Gem::Requirement
76
88
  requirements:
77
89
  - - ">="
78
90
  - !ruby/object:Gem::Version
79
91
  version: '0'
80
92
  requirements: []
81
- rubygems_version: 3.5.3
82
- signing_key:
93
+ rubygems_version: 3.6.9
83
94
  specification_version: 4
84
95
  summary: Google Cloud Platform hosting environment information.
85
96
  test_files: []