google-cloud-env 1.3.0 → 1.5.0

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: 2fe4fb0b390a089e7efb8cde45fb7f6df9e86b25ab81b84292a67fe481341137
4
- data.tar.gz: 5efcbb333c4796812b99332cfc9919ae00f1e39104f092edc1392ba558d40caf
3
+ metadata.gz: 3cc8828b19648ebf3ddbf107e0752ca0dfec854602d7f295ee5a96a3f9a87552
4
+ data.tar.gz: 4cd7a33f479ea15c423695b4652ce82f1f411d33954b8102dea32aef19ee7b6e
5
5
  SHA512:
6
- metadata.gz: b74d450efba00970ed06f659dbedca0391f3128bb9ce6e0abb7d5580c18d55fd58a65ac81ffb6be5a10bc4b07ca41c9121f32df1ef87de455b96993d716150f0
7
- data.tar.gz: 2dde707316115cda0096dbc949d8a6f8dae5f4110540a986bcb89aa1cbd258aebc496ca159b4a47f17fc2dda4277ac0d83c332a9519186451ec027f67633ca0d
6
+ metadata.gz: a2ec60debebb19dfb788b07124fec5855ce2baf795f7d97a9e2d0c43bbcc0a3f599d8a84e85592283dda5a1b735c170fbfd702fb48fdd5645e469340a684c864
7
+ data.tar.gz: 1615868a96d4f5d3ebbc064b99e29b79cc3446a253c1becd94abe27c71a6e60c1e59b4b2b3ec9a5c4bff52ff1f1c6fbd4acaf60a9b55ea7c4aa5e4310b633630
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Release History
2
2
 
3
+ ### 1.5.0 (2021-03-08)
4
+
5
+ #### Features
6
+
7
+ * Drop support for Ruby 2.4 and add support for Ruby 3.0
8
+
9
+ ### 1.4.0 / 2020-10-12
10
+
11
+ #### Features
12
+
13
+ * Honor GCE_METADATA_HOST environment variable
14
+
15
+ ### 1.3.3 / 2020-07-10
16
+
17
+ #### Bug Fixes
18
+
19
+ * Project ID logic honors GOOGLE_CLOUD_PROJECT
20
+
21
+ ### 1.3.2 / 2020-05-28
22
+
23
+ #### Documentation
24
+
25
+ * Fix a few broken links
26
+
27
+ ### 1.3.1 / 2020-03-02
28
+
29
+ #### Bug Fixes
30
+
31
+ * support faraday 1.x
32
+
3
33
  ### 1.3.0 / 2019-10-23
4
34
 
5
35
  Now requires Ruby 2.4 or later.
data/CONTRIBUTING.md CHANGED
@@ -1,4 +1,4 @@
1
- # Contributing to Google Cloud hosting environment
1
+ # Contributing to Google Cloud Ruby Client
2
2
 
3
3
  1. **Sign one of the contributor license agreements below.**
4
4
  2. Fork the repo, develop and test your code changes.
@@ -6,118 +6,66 @@
6
6
 
7
7
  ## Contributor License Agreements
8
8
 
9
- Before we can accept your pull requests you'll need to sign a Contributor
10
- License Agreement (CLA):
9
+ Before we can accept your pull requests you'll need to sign a Contributor License Agreement (CLA):
11
10
 
12
- - **If you are an individual writing original source code** and **you own the
13
- intellectual property**, then you'll need to sign an [individual
14
- CLA](https://developers.google.com/open-source/cla/individual).
15
- - **If you work for a company that wants to allow you to contribute your work**,
16
- then you'll need to sign a [corporate
17
- CLA](https://developers.google.com/open-source/cla/corporate).
11
+ - **If you are an individual writing original source code** and **you own the intellectual property**, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual).
12
+ - **If you work for a company that wants to allow you to contribute your work**, then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate).
18
13
 
19
- You can sign these electronically (just scroll to the bottom). After that, we'll
20
- be able to accept your pull requests.
14
+ You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests.
21
15
 
22
16
  ## Setup
23
17
 
24
- In order to use the google-cloud-env console and run the project's tests,
25
- there is a small amount of setup:
18
+ In order to use the google-cloud-ruby console and run the project's tests, there is a
19
+ small amount of setup:
26
20
 
27
- 1. Install Ruby. google-cloud-env requires Ruby 2.4+. You may choose to
28
- manage your Ruby and gem installations with [RVM](https://rvm.io/),
29
- [rbenv](https://github.com/rbenv/rbenv), or
30
- [chruby](https://github.com/postmodern/chruby).
21
+ 1. Install Ruby.
22
+ google-cloud-env requires Ruby 2.4+. You may choose to manage your Ruby and gem installations with [RVM](https://rvm.io/), [rbenv](https://github.com/rbenv/rbenv), or [chruby](https://github.com/postmodern/chruby).
31
23
 
32
- 2. Install [Bundler](http://bundler.io/).
24
+ 2. Install [Bundler](http://bundler.io/).
33
25
 
34
- ```sh
35
- $ gem install bundler
36
- ```
26
+ ```sh
27
+ $ gem install bundler
28
+ ```
37
29
 
38
- 3. Install the top-level project dependencies.
30
+ 3. Install the project dependencies.
39
31
 
40
- ```sh
41
- $ bundle install
42
- ```
32
+ ```sh
33
+ $ bundle install
34
+ ```
43
35
 
44
- 4. Install the hosting environment dependencies.
36
+ ## Tests
45
37
 
46
- ```sh
47
- $ cd google-cloud-env/
48
- $ bundle exec rake bundleupdate
49
- ```
38
+ All contributions should include tests that ensure the contributed code behaves as expected.
50
39
 
51
- ## Console
52
-
53
- In order to run code interactively, you can automatically load
54
- google-cloud-env and its dependencies in IRB. This requires that your
55
- developer environment has already been configured by following the steps
56
- described in the {file:AUTHENTICATION.md Authentication Guide}. An IRB console
57
- can be created with:
58
-
59
- ```sh
60
- $ cd google-cloud-env/
61
- $ bundle exec rake console
62
- ```
63
-
64
- ## hosting environment Tests
65
-
66
- Tests are very important part of google-cloud-env. All contributions
67
- should include tests that ensure the contributed code behaves as expected.
68
-
69
- To run the unit tests, documentation tests, and code style checks together for a
70
- package:
40
+ To run the tests and code style checks together:
71
41
 
72
42
  ``` sh
73
- $ cd google-cloud-env/
74
43
  $ bundle exec rake ci
75
44
  ```
76
45
 
77
- To run the command above, plus all acceptance tests, use `rake ci:acceptance` or
78
- its handy alias, `rake ci:a`.
79
-
80
- ### hosting environment Unit Tests
81
-
46
+ ### Unit Tests
82
47
 
83
- The project uses the [minitest](https://github.com/seattlerb/minitest) library,
84
- including [specs](https://github.com/seattlerb/minitest#specs),
85
- [mocks](https://github.com/seattlerb/minitest#mocks) and
86
- [minitest-autotest](https://github.com/seattlerb/minitest-autotest).
48
+ The project uses the [minitest](https://github.com/seattlerb/minitest) library, including [specs](https://github.com/seattlerb/minitest#specs), [mocks](https://github.com/seattlerb/minitest#mocks) and [minitest-autotest](https://github.com/seattlerb/minitest-autotest).
87
49
 
88
- To run the hosting environment unit tests:
50
+ To run the unit tests for a package:
89
51
 
90
52
  ``` sh
91
- $ cd google-cloud-env/
92
53
  $ bundle exec rake test
93
54
  ```
94
55
 
95
- ### hosting environment Documentation Tests
56
+ ### Coding Style
96
57
 
97
- The project tests the code examples in the gem's
98
- [YARD](https://github.com/lsegal/yard)-based documentation.
58
+ Please follow the established coding style in the library. The style is is largely based on [The Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide) with a few exceptions based on seattle-style:
99
59
 
100
- The example testing functions in a way that is very similar to unit testing, and
101
- in fact the library providing it,
102
- [yard-doctest](https://github.com/p0deje/yard-doctest), is based on the
103
- project's unit test library, [minitest](https://github.com/seattlerb/minitest).
60
+ * Avoid parenthesis when possible, including in method definitions.
61
+ * Always use double quotes strings. ([Option B](https://github.com/bbatsov/ruby-style-guide#strings))
104
62
 
105
- To run the hosting environment documentation tests:
63
+ You can check your code against these rules by running Rubocop like so:
106
64
 
107
- ``` sh
108
- $ cd google-cloud-env/
109
- $ bundle exec rake doctest
65
+ ```sh
66
+ $ bundle exec rake rubocop
110
67
  ```
111
68
 
112
- If you add, remove or modify documentation examples when working on a pull
113
- request, you may need to update the setup for the tests. The stubs and mocks
114
- required to run the tests are located in `support/doctest_helper.rb`. Please
115
- note that much of the setup is matched by the title of the
116
- [`@example`](http://www.rubydoc.info/gems/yard/file/docs/Tags.md#example) tag.
117
- If you alter an example's title, you may encounter breaking tests.
118
-
119
69
  ## Code of Conduct
120
70
 
121
- Please note that this project is released with a Contributor Code of Conduct. By
122
- participating in this project you agree to abide by its terms. See
123
- {file:CODE_OF_CONDUCT.md Code of Conduct} for more information.
71
+ Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct](CODE_OF_CONDUCT.md) for more information.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Apache License
2
2
  Version 2.0, January 2004
3
- https://www.apache.org/licenses/
3
+ http://www.apache.org/licenses/
4
4
 
5
5
  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
6
 
@@ -192,7 +192,7 @@
192
192
  you may not use this file except in compliance with the License.
193
193
  You may obtain a copy of the License at
194
194
 
195
- https://www.apache.org/licenses/LICENSE-2.0
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
196
 
197
197
  Unless required by applicable law or agreed to in writing, software
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
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.4+.
10
+ This library is supported on Ruby 2.5+.
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.4 and
14
+ security maintenance, and not end of life. Currently, this means Ruby 2.5 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.
@@ -82,6 +82,9 @@ module Google
82
82
  # well as mocking for testing.
83
83
  #
84
84
  # @param [Hash] env Mock environment variables.
85
+ # @param [String] host The hostname or IP address of the metadata server.
86
+ # Optional. If not specified, uses the `GCE_METADATA_HOST`,
87
+ # environment variable or falls back to `169.254.167.254`.
85
88
  # @param [Hash,false] metadata_cache The metadata cache. You may pass
86
89
  # a prepopuated cache, an empty cache (the default) or `false` to
87
90
  # disable the cache completely.
@@ -102,7 +105,7 @@ module Google
102
105
  # If specified, overrides the `request_timeout` and `open_timeout`
103
106
  # settings.
104
107
  #
105
- def initialize env: nil, connection: nil, metadata_cache: nil,
108
+ def initialize env: nil, host: nil, connection: nil, metadata_cache: nil,
106
109
  open_timeout: 0.1, request_timeout: 1.0,
107
110
  retry_count: 2, retry_interval: 0.1,
108
111
  retry_backoff_factor: 1.5, retry_max_interval: 0.5
@@ -114,7 +117,9 @@ module Google
114
117
  @retry_backoff_factor = retry_backoff_factor
115
118
  @retry_max_interval = retry_max_interval
116
119
  request_opts = { timeout: request_timeout, open_timeout: open_timeout }
117
- @connection = connection || ::Faraday.new(url: METADATA_HOST, request: request_opts)
120
+ host ||= @env["GCE_METADATA_HOST"] || METADATA_HOST
121
+ host = "http://#{host}" unless host.start_with? "http://"
122
+ @connection = connection || ::Faraday.new(url: host, request: request_opts)
118
123
  end
119
124
 
120
125
  ##
@@ -210,7 +215,10 @@ module Google
210
215
  # @return [String,nil]
211
216
  #
212
217
  def project_id
213
- env["GCLOUD_PROJECT"] || env["DEVSHELL_PROJECT_ID"] || lookup_metadata("project", "project-id")
218
+ env["GOOGLE_CLOUD_PROJECT"] ||
219
+ env["GCLOUD_PROJECT"] ||
220
+ env["DEVSHELL_PROJECT_ID"] ||
221
+ lookup_metadata("project", "project-id")
214
222
  end
215
223
 
216
224
  ##
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  class Env
19
- VERSION = "1.3.0".freeze
19
+ VERSION = "1.5.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.5.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-10-24 00:00:00.000000000 Z
11
+ date: 2021-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.17.3
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '0.11'
22
+ version: '2.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.17.3
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '0.11'
32
+ version: '2.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: autotest-suffix
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +50,14 @@ dependencies:
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: 1.24.0
53
+ version: 1.25.1
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: 1.24.0
60
+ version: 1.25.1
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: minitest
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -195,14 +201,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
195
201
  requirements:
196
202
  - - ">="
197
203
  - !ruby/object:Gem::Version
198
- version: '2.4'
204
+ version: '2.5'
199
205
  required_rubygems_version: !ruby/object:Gem::Requirement
200
206
  requirements:
201
207
  - - ">="
202
208
  - !ruby/object:Gem::Version
203
209
  version: '0'
204
210
  requirements: []
205
- rubygems_version: 3.0.6
211
+ rubygems_version: 3.2.13
206
212
  signing_key:
207
213
  specification_version: 4
208
214
  summary: Google Cloud Platform hosting environment information.