google-cloud-env 2.1.1 → 2.2.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: 90efc7ff417c91cb62cbb85b70f1a16f25ad41b84effa31e7a753d64d0f541a8
4
+ data.tar.gz: 6925442cc3d569125696bf34112b8ce4fce1030295c48b259533219c6577e6c4
5
5
  SHA512:
6
- metadata.gz: 6ad688117a2b8cc86596be5d2e0ec5f592f5734927756112a0cd82116d52cc0be6c24b8e8594d9d3ea010977e88275c5916cea676b2d50016973b58a7fd52649
7
- data.tar.gz: c347078193dd1cc9cab88f1222327f57d928cf246fad899dca010ad4481f4de7d15a3df924df1dcb42bb7860139d98952b222b53f91cde0c1985319f7d18b832
6
+ metadata.gz: 5076fb608c2552701f6f267f641a83ae0301b8a7d6b3103613046b67179bed1e9c32ea65d238c3f81776ce1f7a77883c906fb3c421b1c4f4e9edb0a567f1dfe6
7
+ data.tar.gz: 81a486aa7b6c23c143a6af6cab570cd7ce3af5a22966303dccaf3081ff90e05e9a9f94a50356d860f03d2f03afffc74089abf71b4ea3a19b9dd87ebcb223dcaf
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Release History
2
2
 
3
+ ### 2.2.1 (2024-10-04)
4
+
5
+ #### Bug Fixes
6
+
7
+ * Fixed edge cases in token expiration extraction ([#73](https://github.com/googleapis/ruby-cloud-env/issues/73))
8
+
9
+ ### 2.2.0 (2024-08-22)
10
+
11
+ #### Features
12
+
13
+ * Provide a query for whether a logging agent is expected in the current environment ([#70](https://github.com/googleapis/ruby-cloud-env/issues/70))
14
+ * Require Ruby 3.0 or later ([#71](https://github.com/googleapis/ruby-cloud-env/issues/71))
15
+
3
16
  ### 2.1.1 (2024-02-01)
4
17
 
5
18
  #### 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
@@ -806,7 +806,7 @@ module Google
806
806
  #
807
807
  def access_token_lifetime data
808
808
  json = JSON.parse data rescue nil
809
- return 0 unless json&.key? "expires_in"
809
+ return 0 unless json.respond_to?(:key?) && json.key?("expires_in")
810
810
  lifetime = json["expires_in"].to_i - TOKEN_EXPIRY_BUFFER
811
811
  lifetime = 0 if lifetime.negative?
812
812
  lifetime
@@ -818,9 +818,9 @@ module Google
818
818
  #
819
819
  def identity_token_lifetime data
820
820
  return 0 unless data =~ /^[\w=-]+\.([\w=-]+)\.[\w=-]+$/
821
- base64 = Base64.decode64 Regexp.last_match[1]
821
+ base64 = Base64.urlsafe_decode64 Regexp.last_match[1]
822
822
  json = JSON.parse base64 rescue nil
823
- return 0 unless json&.key? "exp"
823
+ return 0 unless json.respond_to?(:key?) && json&.key?("exp")
824
824
  lifetime = json["exp"].to_i - Time.now.to_i - TOKEN_EXPIRY_BUFFER
825
825
  lifetime = 0 if lifetime.negative?
826
826
  lifetime
@@ -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.2.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,14 +1,14 @@
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.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-01 00:00:00.000000000 Z
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -59,10 +59,10 @@ homepage: https://github.com/googleapis/ruby-cloud-env
59
59
  licenses:
60
60
  - Apache-2.0
61
61
  metadata:
62
- changelog_uri: https://rubydoc.info/gems/google-cloud-env/2.1.1/CHANGELOG.md
62
+ changelog_uri: https://rubydoc.info/gems/google-cloud-env/2.2.1/CHANGELOG.md
63
63
  source_code_uri: https://github.com/googleapis/ruby-cloud-env
64
64
  bug_tracker_uri: https://github.com/googleapis/ruby-cloud-env/issues
65
- documentation_uri: https://rubydoc.info/gems/google-cloud-env/2.1.1
65
+ documentation_uri: https://rubydoc.info/gems/google-cloud-env/2.2.1
66
66
  post_install_message:
67
67
  rdoc_options: []
68
68
  require_paths:
@@ -71,14 +71,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: '2.7'
74
+ version: '3.0'
75
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
- rubygems_version: 3.5.3
81
+ rubygems_version: 3.5.6
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: Google Cloud Platform hosting environment information.