fog-google 1.7.1 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.travis.yml +0 -3
  4. data/CHANGELOG.md +45 -1
  5. data/CONTRIBUTING.md +11 -5
  6. data/README.md +0 -2
  7. data/fog-google.gemspec +4 -5
  8. data/lib/fog/bin/google.rb +4 -0
  9. data/lib/fog/compute/google/models/addresses.rb +9 -3
  10. data/lib/fog/compute/google/models/backend_services.rb +3 -2
  11. data/lib/fog/compute/google/models/disk_types.rb +5 -6
  12. data/lib/fog/compute/google/models/disks.rb +10 -4
  13. data/lib/fog/compute/google/models/firewalls.rb +3 -2
  14. data/lib/fog/compute/google/models/forwarding_rules.rb +8 -12
  15. data/lib/fog/compute/google/models/global_addresses.rb +3 -2
  16. data/lib/fog/compute/google/models/global_forwarding_rules.rb +3 -2
  17. data/lib/fog/compute/google/models/http_health_checks.rb +4 -3
  18. data/lib/fog/compute/google/models/images.rb +23 -12
  19. data/lib/fog/compute/google/models/instance_group_managers.rb +10 -7
  20. data/lib/fog/compute/google/models/instance_groups.rb +21 -15
  21. data/lib/fog/compute/google/models/instance_templates.rb +3 -2
  22. data/lib/fog/compute/google/models/machine_types.rb +13 -4
  23. data/lib/fog/compute/google/models/networks.rb +3 -2
  24. data/lib/fog/compute/google/models/operations.rb +8 -8
  25. data/lib/fog/compute/google/models/projects.rb +3 -2
  26. data/lib/fog/compute/google/models/regions.rb +3 -2
  27. data/lib/fog/compute/google/models/routes.rb +3 -2
  28. data/lib/fog/compute/google/models/servers.rb +7 -7
  29. data/lib/fog/compute/google/models/snapshots.rb +5 -4
  30. data/lib/fog/compute/google/models/ssl_certificates.rb +4 -3
  31. data/lib/fog/compute/google/models/subnetworks.rb +13 -7
  32. data/lib/fog/compute/google/models/target_http_proxies.rb +3 -2
  33. data/lib/fog/compute/google/models/target_https_proxies.rb +3 -2
  34. data/lib/fog/compute/google/models/target_instances.rb +8 -8
  35. data/lib/fog/compute/google/models/target_pools.rb +7 -10
  36. data/lib/fog/compute/google/models/url_maps.rb +3 -2
  37. data/lib/fog/compute/google/models/zones.rb +4 -2
  38. data/lib/fog/compute/google/real.rb +2 -0
  39. data/lib/fog/compute/google/requests/list_aggregated_instance_groups.rb +1 -2
  40. data/lib/fog/dns/google/real.rb +1 -0
  41. data/lib/fog/google/models/sql/instances.rb +4 -1
  42. data/lib/fog/google/monitoring/real.rb +1 -0
  43. data/lib/fog/google/pubsub/real.rb +1 -0
  44. data/lib/fog/google/shared.rb +15 -1
  45. data/lib/fog/google/sql/real.rb +1 -0
  46. data/lib/fog/google/version.rb +1 -1
  47. data/lib/fog/storage/google_json/real.rb +2 -0
  48. data/test/helpers/integration_test_helper.rb +2 -0
  49. data/test/helpers/test_collection.rb +26 -3
  50. data/test/integration/compute/core_compute/test_client_options.rb +12 -0
  51. data/test/integration/compute/core_compute/test_disk_types.rb +9 -0
  52. data/test/integration/compute/core_compute/test_images.rb +21 -0
  53. data/test/integration/compute/core_compute/test_machine_types.rb +13 -0
  54. data/test/integration/compute/core_compute/test_operations.rb +19 -1
  55. data/test/integration/compute/instance_groups/test_instance_group_managers.rb +1 -1
  56. data/test/integration/factories/addresses_factory.rb +4 -0
  57. data/test/integration/factories/collection_factory.rb +1 -1
  58. data/test/integration/factories/disks_factory.rb +4 -0
  59. data/test/integration/factories/forwarding_rules_factory.rb +4 -0
  60. data/test/integration/factories/images_factory.rb +4 -0
  61. data/test/integration/factories/instance_group_manager_factory.rb +8 -0
  62. data/test/integration/factories/instance_groups_factory.rb +4 -0
  63. data/test/integration/factories/servers_factory.rb +8 -0
  64. data/test/integration/factories/subnetworks_factory.rb +4 -0
  65. data/test/integration/factories/target_instances_factory.rb +4 -0
  66. data/test/integration/factories/target_pools_factory.rb +4 -0
  67. data/test/unit/compute/test_common_collections.rb +19 -8
  68. data/test/unit/compute/test_common_models.rb +10 -11
  69. data/test/unit/compute/test_server.rb +2 -1
  70. data/test/unit/dns/test_common_collections.rb +43 -0
  71. data/test/unit/monitoring/test_comon_collections.rb +44 -0
  72. data/test/unit/pubsub/test_common_collections.rb +35 -0
  73. data/test/unit/sql/test_common_collections.rb +46 -0
  74. data/test/unit/storage/test_common_json_collections.rb +38 -0
  75. data/test/unit/storage/test_common_xml_collections.rb +39 -0
  76. metadata +33 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ef0c77cc212c88e05b3b2ba96a93a50b4e7ec6a
4
- data.tar.gz: 3d052f7c4ae45331d3284fe06ab4b5c6387a2505
3
+ metadata.gz: c56136ffcc21e614018a5157077bcaf6315c740f
4
+ data.tar.gz: b9da25d90e07d29a3b1645d98776e7897206155a
5
5
  SHA512:
6
- metadata.gz: b769db3c40da12eb211331bf3c00f73b7a938aeea5f09a1672cc142c68044b05303e79919b4dc611bce66684b6bf8b4255d3532e615c412357e58b80ca95fc9f
7
- data.tar.gz: 775be1007e7030acbb089441297345e78d9afa106659be6d47d4017ad86f3db36c4ca9ab96eec0bb4a181d1bb8aebaef431cd730a0e6ccdee9b3ec8c90c7d546
6
+ metadata.gz: 855a091e79a21628ce05c763310ea92b2bf1eb281316fedca9cb6cd6a166097064d2c9d7795f04950201e0c6478d7bd0ba4461215770b72b4e786e0fef380370
7
+ data.tar.gz: 95925fcea76bdec54634581318827e87c7d03b98acea750bedfed767437dbd0a03e5f520ac7e635177fcc9ff7d286a2e8443d8578646e94583dcf840d3976915
@@ -6,6 +6,9 @@ Style/ConditionalAssignment:
6
6
  SingleLineConditionsOnly: true
7
7
  EnforcedStyle: assign_inside_condition
8
8
 
9
+ Style/RedundantReturn:
10
+ Enabled: false
11
+
9
12
  Style/FormatString:
10
13
  Enabled: false
11
14
 
@@ -12,9 +12,6 @@ matrix:
12
12
  - rvm: 2.5
13
13
  - rvm: jruby-head
14
14
  allow_failures:
15
- # allow 2.5 to fail until Travis CI is fixed.
16
- # See travis-ci/travis-ci#8969
17
- - rvm: 2.5
18
15
  - rvm: jruby-head
19
16
  notifications:
20
17
  email: false
@@ -1,6 +1,50 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
- The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
3
+ The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
4
+
5
+ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## 1.8.0
8
+
9
+ ### User-facing
10
+
11
+ #### Added
12
+ - \#418 Reintroduce client options for proxy support, etc. [AlexanderZagaynov]
13
+
14
+ #### Fixed
15
+
16
+ - \#419 Locked down fog upstream dependencies to alleviate deprecation warnings
17
+ until they can be properly dealt with. [temikus]
18
+ - \#400 Small `%Collection%.get` and `%Collection%.all` behaviour fixes [temikus]
19
+ - `Fog::Google::SQL::Instances.get(nil)` no longer returns an invalid
20
+ `sql#instancesList` object.
21
+ - `Fog::Compute::Google::InstanceGroups.get` and `.all` methods now support
22
+ more than just `:filter` option, fixed `.all` output without `zone` option.
23
+ - Fix a typo causing `Operations.get(region:REGION)` to fail.
24
+ - `Fog::Compute::Google::Images.get(IMAGE, PROJECT)`, now returns `nil` if
25
+ image is not found rather than throwing `Google::Apis::ClientError`.
26
+
27
+ ### Development changes
28
+
29
+ #### Added
30
+
31
+ - \#400 Additional test coverage [temikus]
32
+ - Expanded tests for `%Collection%.get` behavior - scoped requests
33
+ (e.g. `get(zone:ZONE)`) and their corresponding code paths are now also
34
+ properly tested.
35
+ - Increase `Fog::Compute::Google::Images` integration test coverage.
36
+ - Unit tests now work without a `~/.fog` config file set up.
37
+ - Expanded unit test coverage.
38
+ - \#424 Add simple integration tests to check client proxy options being
39
+ applied.
40
+
41
+ #### Changed
42
+
43
+ - \#400 Refactored most compute `get()` and `all()` methods to common format. [temikus]
44
+
45
+ #### Fixed
46
+
47
+ - \#400 Removed the Travis Ruby 2.5 workaround. [temikus]
4
48
 
5
49
  ## 1.7.1
6
50
 
@@ -101,20 +101,26 @@ test:
101
101
  Then you can run all the live tests:
102
102
 
103
103
  ```shell
104
- $ rake test
104
+ $ bundle exec rake test
105
105
  ```
106
106
 
107
107
  or just one API:
108
108
 
109
109
  ```
110
- $ rake test:compute
110
+ $ bundle exec rake test:compute
111
111
  ```
112
112
  (See `rake -T` for all available tasks)
113
113
 
114
- or just one file:
114
+ or just one test:
115
115
 
116
116
  ```shell
117
- $ rake test TEST=test/integration/compute/test_servers.rb TESTOPTS="--name=TestServers#test_bootstrap_ssh_destroy"
117
+ $ bundle exec rake test TESTOPTS="--name=TestServers#test_bootstrap_ssh_destroy"
118
+ ```
119
+
120
+ or a series of tests by name:
121
+
122
+ ```
123
+ $ bundle exec rake test TESTOPTS="--name=/test_nil_get/"
118
124
  ```
119
125
 
120
126
  #### Unit tests
@@ -133,7 +139,7 @@ We're in progress of extending the library with more unit tests and contribution
133
139
  #### The transition from `shindo` to Minitest
134
140
 
135
141
  Previously, [shindo](https://github.com/geemus/shindo) was the primary testing framework.
136
- We've started moving away from it, and to Minitest, but some artifacts may remain.
142
+ We've moved away from it, and to Minitest, but some artifacts may remain.
137
143
 
138
144
  For more information on transition, read [#50](https://github.com/fog/fog-google/issues/50).
139
145
 
data/README.md CHANGED
@@ -42,8 +42,6 @@ We are always looking for people to improve our code and test coverage, so pleas
42
42
 
43
43
  ## Pubsub
44
44
 
45
- Note: You **must** have a version of google-api-client > 0.8.5 to use the Pub/Sub API; previous versions will not work.
46
-
47
45
  Fog mostly implements [v1](https://cloud.google.com/pubsub/docs/reference/rest/) of the Google Cloud Pub/Sub API; however some less common API methods are missing. Pull requests for additions would be greatly appreciated.
48
46
 
49
47
  ## Installation
@@ -20,15 +20,14 @@ Gem::Specification.new do |spec|
20
20
  # As of 0.1.1
21
21
  spec.required_ruby_version = "~> 2.0"
22
22
 
23
- spec.add_dependency "fog-core"
24
- spec.add_dependency "fog-json"
25
- spec.add_dependency "fog-xml"
23
+ # Locked until https://github.com/fog/fog-google/issues/417 is resolved
24
+ spec.add_dependency "fog-core", ">= 2.0", "<= 2.1.0"
25
+ spec.add_dependency "fog-json", "~> 1.2.0"
26
+ spec.add_dependency "fog-xml", "~> 0.1.0"
26
27
 
27
28
  # Hard Requirement as of 1.0
28
29
  spec.add_dependency "google-api-client", "~> 0.23.0"
29
30
 
30
- spec.add_development_dependency "mime-types"
31
-
32
31
  # Debugger
33
32
  spec.add_development_dependency "pry"
34
33
  spec.add_development_dependency "pry-byebug"
@@ -15,6 +15,8 @@ module Google
15
15
  Fog::Storage::Google
16
16
  when :sql
17
17
  Fog::Google::SQL
18
+ when :pubsub
19
+ Fog::Google::Pubsub
18
20
  else
19
21
  raise ArgumentError, "Unsupported #{self} service: #{key}"
20
22
  end
@@ -33,6 +35,8 @@ module Google
33
35
  Fog::Google::Monitoring.new
34
36
  when :sql
35
37
  Fog::Google::SQL.new
38
+ when :pubsub
39
+ Fog::Google::Pubsub.new
36
40
  when :storage
37
41
  Fog::Logger.warning("Google[:storage] is not recommended, use Storage[:google] for portability")
38
42
  Fog::Storage.new(:provider => "Google")
@@ -23,9 +23,15 @@ module Fog
23
23
  load(data.map(&:to_h))
24
24
  end
25
25
 
26
- def get(identity, region)
27
- if address = service.get_address(identity, region).to_h
28
- new(address)
26
+ def get(identity, region = nil)
27
+ if region
28
+ address = service.get_address(identity, region).to_h
29
+ return new(address)
30
+ elsif identity
31
+ response = all(:filter => "name eq #{identity}",
32
+ :max_results => 1)
33
+ address = response.first unless response.empty?
34
+ return address
29
35
  end
30
36
  rescue ::Google::Apis::ClientError => e
31
37
  raise e unless e.status_code == 404
@@ -10,8 +10,9 @@ module Fog
10
10
  end
11
11
 
12
12
  def get(identity)
13
- if backend_service = service.get_backend_service(identity)
14
- new(backend_service.to_h)
13
+ if identity
14
+ backend_service = service.get_backend_service(identity).to_h
15
+ return new(backend_service)
15
16
  end
16
17
  rescue ::Google::Apis::ClientError => e
17
18
  raise e unless e.status_code == 404
@@ -24,15 +24,14 @@ module Fog
24
24
  end
25
25
 
26
26
  def get(identity, zone = nil)
27
- response = nil
28
27
  if zone
29
- response = service.get_disk_type(identity, zone).to_h
28
+ disk_type = service.get_disk_type(identity, zone).to_h
29
+ return new(disk_type)
30
30
  else
31
- disk_types = all(:filter => "name eq .*#{identity}")
32
- response = disk_types.first.attributes unless disk_types.empty?
31
+ response = all(:filter => "name eq .*#{identity}")
32
+ disk_type = response.first unless response.empty?
33
+ return disk_type
33
34
  end
34
- return nil if response.nil?
35
- new(response)
36
35
  rescue ::Google::Apis::ClientError => e
37
36
  raise e unless e.status_code == 404
38
37
  nil
@@ -23,10 +23,16 @@ module Fog
23
23
  load(data.map(&:to_h))
24
24
  end
25
25
 
26
- def get(identity, zone)
27
- response = service.get_disk(identity, zone)
28
- return nil if response.nil?
29
- new(response.to_h)
26
+ def get(identity, zone = nil)
27
+ if zone
28
+ disk = service.get_disk(identity, zone).to_h
29
+ return new(disk)
30
+ elsif identity
31
+ response = all(:filter => "name eq #{identity}",
32
+ :max_results => 1)
33
+ disk = response.first unless response.empty?
34
+ return disk
35
+ end
30
36
  rescue ::Google::Apis::ClientError => e
31
37
  raise e unless e.status_code == 404
32
38
  nil
@@ -10,8 +10,9 @@ module Fog
10
10
  end
11
11
 
12
12
  def get(identity)
13
- if firewall = service.get_firewall(identity)
14
- new(firewall.to_h)
13
+ if identity
14
+ firewall = service.get_firewall(identity).to_h
15
+ return new(firewall)
15
16
  end
16
17
  rescue ::Google::Apis::ClientError => e
17
18
  raise e unless e.status_code == 404
@@ -4,9 +4,7 @@ module Fog
4
4
  class ForwardingRules < Fog::Collection
5
5
  model Fog::Compute::Google::ForwardingRule
6
6
 
7
- def all(region: nil, filter: nil, max_results: nil,
8
- order_by: nil, page_token: nil)
9
-
7
+ def all(region: nil, filter: nil, max_results: nil, order_by: nil, page_token: nil)
10
8
  opts = {
11
9
  :filter => filter,
12
10
  :max_results => max_results,
@@ -15,7 +13,7 @@ module Fog
15
13
  }
16
14
 
17
15
  if region
18
- data = service.list_forwarding_rules(region, opts).items
16
+ data = service.list_forwarding_rules(region, opts).items || []
19
17
  else
20
18
  data = []
21
19
  service.list_aggregated_forwarding_rules(opts).items
@@ -29,18 +27,16 @@ module Fog
29
27
  end
30
28
 
31
29
  def get(identity, region = nil)
32
- response = nil
33
30
  if region
34
- response = service.get_forwarding_rule(identity, region).to_h
35
- else
31
+ forwarding_rule = service.get_forwarding_rule(identity, region).to_h
32
+ return new(forwarding_rule)
33
+ elsif identity
36
34
  response = all(
37
35
  :filter => "name eq #{identity}", :max_results => 1
38
- ).first
39
- response = response.attributes unless response.nil?
36
+ )
37
+ forwarding_rule = response.first unless response.empty?
38
+ return forwarding_rule
40
39
  end
41
-
42
- return nil if response.nil?
43
- new(response)
44
40
  end
45
41
  end
46
42
  end
@@ -10,8 +10,9 @@ module Fog
10
10
  end
11
11
 
12
12
  def get(identity)
13
- if address = service.get_global_address(identity).to_h
14
- new(address)
13
+ if identity
14
+ address = service.get_global_address(identity).to_h
15
+ return new(address)
15
16
  end
16
17
  rescue ::Google::Apis::ClientError => e
17
18
  raise e unless e.status_code == 404
@@ -10,8 +10,9 @@ module Fog
10
10
  end
11
11
 
12
12
  def get(identity)
13
- if rule = service.get_global_forwarding_rule(identity).to_h
14
- new(rule)
13
+ if identity
14
+ rule = service.get_global_forwarding_rule(identity).to_h
15
+ return new(rule)
15
16
  end
16
17
  rescue ::Google::Apis::ClientError => e
17
18
  raise e unless e.status_code == 404
@@ -10,9 +10,10 @@ module Fog
10
10
  end
11
11
 
12
12
  def get(identity)
13
- response = service.get_http_health_check(identity)
14
- return nil if response.nil?
15
- new(response.to_h)
13
+ if identity
14
+ http_health_check = service.get_http_health_check(identity).to_h
15
+ return new(http_health_check)
16
+ end
16
17
  rescue ::Google::Apis::ClientError => e
17
18
  raise e unless e.status_code == 404
18
19
  nil
@@ -46,22 +46,33 @@ module Fog
46
46
  end
47
47
 
48
48
  def get(identity, project = nil)
49
- project.nil? ? projects = all_projects : projects = [project]
50
- data = nil
51
- projects.each do |proj|
49
+ if project
52
50
  begin
53
- data = service.get_image(identity, proj).to_h
54
- data[:project] = proj
51
+ image = service.get_image(identity, project).to_h
52
+ # TODO: Remove response modification - see #405
53
+ image[:project] = project
54
+ return new(image)
55
55
  rescue ::Google::Apis::ClientError => e
56
- next if e.status_code == 404
57
- break
58
- else
59
- break
56
+ raise e unless e.status_code == 404
57
+ nil
58
+ end
59
+ elsif identity
60
+ projects = all_projects
61
+ projects.each do |proj|
62
+ begin
63
+ response = service.get_image(identity, proj).to_h
64
+ # TODO: Remove response modification - see #405
65
+ response[:project] = proj
66
+ image = response
67
+ return new(image)
68
+ rescue ::Google::Apis::ClientError => e
69
+ next if e.status_code == 404
70
+ break
71
+ end
60
72
  end
73
+ # If nothing is found - return nil
74
+ nil
61
75
  end
62
-
63
- return nil if data.nil?
64
- new(data)
65
76
  end
66
77
 
67
78
  def get_from_family(family, project = nil)
@@ -12,10 +12,11 @@ module Fog
12
12
  :order_by => order_by,
13
13
  :page_token => page_token
14
14
  }
15
- data = []
15
+
16
16
  if zone
17
- data += service.list_instance_group_managers(zone, opts).items || []
17
+ data = service.list_instance_group_managers(zone, opts).items || []
18
18
  else
19
+ data = []
19
20
  service.list_aggregated_instance_group_managers(opts).items.each_value do |group|
20
21
  data.concat(group.instance_group_managers) if group.instance_group_managers
21
22
  end
@@ -26,11 +27,13 @@ module Fog
26
27
 
27
28
  def get(identity, zone = nil)
28
29
  if zone
29
- if instance_group_manager = service.get_instance_group_manager(identity, zone)
30
- new(instance_group_manager.to_h)
31
- end
32
- else
33
- all(:filter => "name eq .*#{identity}").first
30
+ instance_group_manager = service.get_instance_group_manager(identity, zone).to_h
31
+ return new(instance_group_manager)
32
+ elsif identity
33
+ response = all(:filter => "name eq .*#{identity}",
34
+ :max_results => 1)
35
+ instance_group_manager = response.first unless response.empty?
36
+ return instance_group_manager
34
37
  end
35
38
  rescue ::Google::Apis::ClientError => e
36
39
  raise e unless e.status_code == 404
@@ -4,13 +4,20 @@ module Fog
4
4
  class InstanceGroups < Fog::Collection
5
5
  model Fog::Compute::Google::InstanceGroup
6
6
 
7
- def all(filters = {})
8
- if filters[:zone]
9
- data = Array(service.list_instance_groups(filters[:zone]))
7
+ def all(zone: nil, filter: nil, max_results: nil, order_by: nil, page_token: nil)
8
+ opts = {
9
+ :filter => filter,
10
+ :max_results => max_results,
11
+ :order_by => order_by,
12
+ :page_token => page_token
13
+ }
14
+
15
+ if zone
16
+ data = service.list_instance_groups(zone).items || []
10
17
  else
11
18
  data = []
12
- service.list_aggregated_instance_groups.items.each_value do |group|
13
- data.concat(group.instance_groups) if group.instance_groups
19
+ service.list_aggregated_instance_groups(opts).items.each_value do |group|
20
+ data.concat(group.instance_groups) if group && group.instance_groups
14
21
  end
15
22
  end
16
23
 
@@ -18,19 +25,18 @@ module Fog
18
25
  end
19
26
 
20
27
  def get(identity, zone = nil)
21
- if zone.nil?
22
- zones = service.list_aggregated_instance_groups(:filter => "name eq .*#{identity}").items
23
- instance_groups = zones.each_value.map(&:instance_groups).compact.first
24
- if instance_groups
25
- zone = instance_groups.first.zone.split("/")[-1]
26
- end
27
- end
28
-
29
- if instance_group = service.get_instance_group(identity, zone)
30
- new(instance_group.to_h)
28
+ if zone
29
+ instance_group = service.get_instance_group(identity, zone).to_h
30
+ new(instance_group)
31
+ elsif identity
32
+ response = all(:filter => "name eq #{identity}",
33
+ :max_results => 1)
34
+ instance_group = response.first unless response.empty?
35
+ return instance_group
31
36
  end
32
37
  rescue ::Google::Apis::ClientError => e
33
38
  raise e unless e.status_code == 404
39
+
34
40
  nil
35
41
  end
36
42