fluent-plugin-google-cloud 0.6.16 → 0.6.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc441330446e0c25bc08501530b66b7d6564dc37
4
- data.tar.gz: 55a4592b58913b49b23cab5ddfc469a97afd5c4f
3
+ metadata.gz: '03907dea1776a461bfedccdc6bc8c05fa099e557'
4
+ data.tar.gz: 81d1c2a217900442793ae78dccf58ccafc88d21e
5
5
  SHA512:
6
- metadata.gz: 55d494d4e51e821a800b06a3cf936fdbb0fa01305d4e04531f5c0f34001188be0da9b90ea8b84111a6d5f77abd9745f91cf3ec4465939c7af5d2ff11edd55b9f
7
- data.tar.gz: 55566646fd0f2656df5fc9d8373d17fc6ddb364b527b74ae6a1be24173e7d0aaec141ea8e90c2bf0a4f7c66d7f471e8a85b9ecc4ef65d1985d164fb86b51126f
6
+ metadata.gz: 269987948317e7917f8e237132a741d363baa9a273e1e936b5170e551d39a27cb7c480ca59295a5eae6136eb49156ae0e0f2ece80c3a2c5870305127a1fbc2da
7
+ data.tar.gz: e9c791824dcc361f6d958aeb6dd423ec3d8f51168cc448883f777c775e6ac6c33aebe443912883c0dd61e9079cf501ab15b93fc3e474989ff5d1ab3df40050e5
@@ -10,7 +10,7 @@ eos
10
10
  gem.homepage =
11
11
  'https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud'
12
12
  gem.license = 'Apache-2.0'
13
- gem.version = '0.6.16'
13
+ gem.version = '0.6.17'
14
14
  gem.authors = ['Todd Derr', 'Alex Robinson']
15
15
  gem.email = ['salty@google.com']
16
16
  gem.required_ruby_version = Gem::Requirement.new('>= 2.0')
@@ -38,6 +38,27 @@ module Google
38
38
  end
39
39
  end
40
40
 
41
+ module Google
42
+ module Auth
43
+ # Extract project_id in initialize.
44
+ class ServiceAccountCredentials
45
+ singleton_class.send(:alias_method, :super_make_creds, :make_creds)
46
+ def self.make_creds(options = {})
47
+ json_key_io, scope = options.values_at(:json_key_io, :scope)
48
+ if json_key_io
49
+ json_key = MultiJson.load(json_key_io.read)
50
+ project_id = json_key['project_id']
51
+ end
52
+ creds = super_make_creds(
53
+ json_key_io: StringIO.new(MultiJson.dump(json_key)), scope: scope)
54
+ creds.instance_variable_set(:@project_id, project_id) if project_id
55
+ creds
56
+ end
57
+ attr_reader :project_id
58
+ end
59
+ end
60
+ end
61
+
41
62
  module Fluent
42
63
  # fluentd output plugin for the Stackdriver Logging API
43
64
  class GoogleCloudOutput < BufferedOutput
@@ -199,7 +220,7 @@ module Fluent
199
220
  Fluent::Plugin.register_output('google_cloud', self)
200
221
 
201
222
  PLUGIN_NAME = 'Fluentd Google Cloud Logging plugin'.freeze
202
- PLUGIN_VERSION = '0.6.16'.freeze
223
+ PLUGIN_VERSION = '0.6.17'.freeze
203
224
 
204
225
  # Name of the the Google cloud logging write scope.
205
226
  LOGGING_SCOPE = 'https://www.googleapis.com/auth/logging.write'.freeze
@@ -361,7 +382,7 @@ module Fluent
361
382
 
362
383
  # Whether to split log entries with different log tags into different
363
384
  # requests when talking to Stackdriver Logging API.
364
- config_param :split_logs_by_tag, :bool, :default => true
385
+ config_param :split_logs_by_tag, :bool, :default => false
365
386
 
366
387
  # rubocop:enable Style/HashSyntax
367
388
 
@@ -611,7 +632,8 @@ module Fluent
611
632
  end
612
633
  combined_entries.concat(request[:entries])
613
634
  end
614
- @write_request.call(entries: combined_entries)
635
+ @write_request.call(entries: combined_entries) unless
636
+ combined_entries.empty?
615
637
  end
616
638
  end
617
639
 
@@ -1412,6 +1434,9 @@ module Fluent
1412
1434
  # Returns the project ID (as a string) on success, or nil on failure.
1413
1435
  def self.project_id
1414
1436
  creds = Google::Auth.get_application_default(LOGGING_SCOPE)
1437
+ if creds.respond_to?(:project_id)
1438
+ return creds.project_id if creds.project_id
1439
+ end
1415
1440
  if creds.issuer
1416
1441
  id = extract_project_id(creds.issuer)
1417
1442
  return id unless id.nil?
@@ -227,7 +227,8 @@ module BaseTest
227
227
  def test_project_id_from_credentials
228
228
  %w(gce ec2).each do |platform|
229
229
  send("setup_#{platform}_metadata_stubs")
230
- [IAM_CREDENTIALS, LEGACY_CREDENTIALS].each do |creds|
230
+ [IAM_CREDENTIALS, NEW_STYLE_CREDENTIALS, LEGACY_CREDENTIALS].each \
231
+ do |creds|
231
232
  ENV['GOOGLE_APPLICATION_CREDENTIALS'] = creds[:path]
232
233
  d = create_driver
233
234
  d.run
@@ -656,8 +657,8 @@ module BaseTest
656
657
  def test_configure_split_logs_by_tag
657
658
  setup_gce_metadata_stubs
658
659
  {
659
- APPLICATION_DEFAULT_CONFIG => true,
660
- DISABLE_SPLIT_LOGS_BY_TAG_CONFIG => false
660
+ APPLICATION_DEFAULT_CONFIG => false,
661
+ ENABLE_SPLIT_LOGS_BY_TAG_CONFIG => true
661
662
  }.each do |(config, split_logs_by_tag)|
662
663
  d = create_driver(config)
663
664
  assert_equal split_logs_by_tag,
@@ -672,14 +673,14 @@ module BaseTest
672
673
  "projects/test-project-id/logs/tag#{index}"
673
674
  end
674
675
  [
676
+ [APPLICATION_DEFAULT_CONFIG, 1, [''], dynamic_log_names],
675
677
  # [] returns nil for any index.
676
- [APPLICATION_DEFAULT_CONFIG, log_entry_count, dynamic_log_names, []],
677
- [DISABLE_SPLIT_LOGS_BY_TAG_CONFIG, 1, [''], dynamic_log_names]
678
+ [ENABLE_SPLIT_LOGS_BY_TAG_CONFIG, log_entry_count, dynamic_log_names, []]
678
679
  ].each do |(config, request_count, request_log_names, entry_log_names)|
679
680
  setup_prometheus
680
681
  setup_logging_stubs do
681
682
  @logs_sent = []
682
- d = create_driver(config + PROMETHEUS_ENABLE_CONFIG, 'test', true)
683
+ d = create_driver(config + ENABLE_PROMETHEUS_CONFIG, 'test', true)
683
684
  log_entry_count.times do |i|
684
685
  d.emit("tag#{i}", 'message' => log_entry(i))
685
686
  end
@@ -133,6 +133,10 @@ module Constants
133
133
  path: 'test/plugin/data/iam-credentials.json',
134
134
  project_id: 'fluent-test-project'
135
135
  }.freeze
136
+ NEW_STYLE_CREDENTIALS = {
137
+ path: 'test/plugin/data/new-style-credentials.json',
138
+ project_id: 'fluent-test-project'
139
+ }.freeze
136
140
  LEGACY_CREDENTIALS = {
137
141
  path: 'test/plugin/data/credentials.json',
138
142
  project_id: '847859579879'
@@ -182,11 +186,11 @@ module Constants
182
186
  detect_subservice false
183
187
  ).freeze
184
188
 
185
- DISABLE_SPLIT_LOGS_BY_TAG_CONFIG = %(
186
- split_logs_by_tag false
189
+ ENABLE_SPLIT_LOGS_BY_TAG_CONFIG = %(
190
+ split_logs_by_tag true
187
191
  ).freeze
188
192
 
189
- PROMETHEUS_ENABLE_CONFIG = %(
193
+ ENABLE_PROMETHEUS_CONFIG = %(
190
194
  enable_monitoring true
191
195
  monitoring_type prometheus
192
196
  ).freeze
@@ -0,0 +1,12 @@
1
+ {
2
+ "type": "service_account",
3
+ "private_key_id": "5985985bcdfe958895bd8d76456fe90d8484789d",
4
+ "private_key": "-----BEGIN PRIVATE KEY-----\nMIICdwIBADANBgkqhkiG9w0BAQEcAASCAmEwggJdAgEAAoGBAKizy6B+aJ0Wua0e\njZ3pkHV0a2Ce1prJGhzGL5NpkbUjk6J11Kwp1yvPikTwALyy4PtUIZ+23D/unVRM\nHlKa2MkHIGjJg+mykX5Bd7eRJOxdJ0iu+eRWh7HiH+mdDntHwaz4xXihJBog71qS\n+9N+r2hy1hicybechchMiXHhmWPbAgMBAAECgYEAnSzeI4qCZxEcLtnPcXeBWpz7\nycpTAWUpycMvsjTiRxR9YRhM65YT3cJ//VhqJ2S1ThOcPCt/KqViuX4tpiKUo7qA\nH1AI9APbTo66wiGpgy+qG0wPJkKIQC8PpITNNcHqcbbAsIr3/XQduihsqxP2W2mT\na0nk5XJghs1Wa0xt28ECQQDgMqZjVDcDQyqM+bcBKJUUc/247KusjpdK70r6sx2o\nkZJGy/w9exlM5QrB6DLpw34/p5x4MoecZ7lS3yHdmaEhAkEAwKHsV4k5SXTUp4+J\nWK6GlQVvnwc+PQdX5gzt4/gWSY0Op5EQ+YD6cC7Lkz+GzXUzvmdp35c0ahS93D1/\nZLTZewJBAIjOc3cHMNadyr5BtulPEUE0ro+EY/GlBS8lu/QlDmkJg2AOI3qEvliM\nvza58S9yKny/U5yJAPVw2cZ3ABxQHeECQDyBX8PrBURuXvE2o5RoVTtvlqziAi3X\nJaPLwdkOLqnxlX3KkgNcoM0l1amtlYDpZcRVcSs0+9TqKOyJoH8YUwsCQA4cJmv3\n119xcijXPM2HZOB5cCxTHj59MRtQlLboNZ2witDCJ20eG9AC3ZcH7csS0H9dz8Jr\nXGEoQMPD2ck4T0U\u003d\n-----END PRIVATE KEY-----\n",
5
+ "client_email": "account-name@fluent-test-project-1.iam.gserviceaccount.com",
6
+ "client_id": "275859789789367827863",
7
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
8
+ "token_uri": "https://accounts.google.com/o/oauth2/token",
9
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
10
+ "project_id": "fluent-test-project",
11
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/account-name%40fluent-test-project.iam.gserviceaccount.com"
12
+ }
@@ -61,7 +61,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
61
61
  stub_request(:post, WRITE_LOG_ENTRIES_URI)
62
62
  .to_return(status: root_error_code,
63
63
  body: PARTIAL_SUCCESS_RESPONSE_BODY.to_json)
64
- d = create_driver(PROMETHEUS_ENABLE_CONFIG)
64
+ d = create_driver(ENABLE_PROMETHEUS_CONFIG)
65
65
  4.times do |i|
66
66
  d.emit('message' => log_entry(i.to_s))
67
67
  end
@@ -123,7 +123,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
123
123
  stub_request(:post, WRITE_LOG_ENTRIES_URI)
124
124
  .to_return(status: code, body: 'Some Message')
125
125
  (1..request_count).each do
126
- d = create_driver(PROMETHEUS_ENABLE_CONFIG)
126
+ d = create_driver(ENABLE_PROMETHEUS_CONFIG)
127
127
  (1..entry_count).each do |i|
128
128
  d.emit('message' => log_entry(i.to_s))
129
129
  end
@@ -59,7 +59,7 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
59
59
  'User not authorized.', PARTIAL_SUCCESS_GRPC_METADATA) do
60
60
  # The API Client should not retry this and the plugin should consume
61
61
  # the exception.
62
- d = create_driver(PROMETHEUS_ENABLE_CONFIG)
62
+ d = create_driver(ENABLE_PROMETHEUS_CONFIG)
63
63
  4.times do |i|
64
64
  d.emit('message' => log_entry(i.to_s))
65
65
  end
@@ -131,7 +131,7 @@ class GoogleCloudOutputGRPCTest < Test::Unit::TestCase
131
131
  setup_prometheus
132
132
  (1..request_count).each do
133
133
  setup_logging_stubs(should_fail, code, 'SomeMessage') do
134
- d = create_driver(USE_GRPC_CONFIG + PROMETHEUS_ENABLE_CONFIG, 'test')
134
+ d = create_driver(USE_GRPC_CONFIG + ENABLE_PROMETHEUS_CONFIG, 'test')
135
135
  (1..entry_count).each do |i|
136
136
  d.emit('message' => log_entry(i.to_s))
137
137
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-google-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.16
4
+ version: 0.6.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Derr
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-01 00:00:00.000000000 Z
12
+ date: 2018-03-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -212,7 +212,6 @@ extra_rdoc_files: []
212
212
  files:
213
213
  - CONTRIBUTING
214
214
  - Gemfile
215
- - Gemfile.lock
216
215
  - LICENSE
217
216
  - README.rdoc
218
217
  - Rakefile
@@ -226,6 +225,7 @@ files:
226
225
  - test/plugin/data/credentials.json
227
226
  - test/plugin/data/iam-credentials.json
228
227
  - test/plugin/data/invalid_credentials.json
228
+ - test/plugin/data/new-style-credentials.json
229
229
  - test/plugin/test_driver.rb
230
230
  - test/plugin/test_out_google_cloud.rb
231
231
  - test/plugin/test_out_google_cloud_grpc.rb
@@ -261,6 +261,7 @@ test_files:
261
261
  - test/plugin/data/credentials.json
262
262
  - test/plugin/data/iam-credentials.json
263
263
  - test/plugin/data/invalid_credentials.json
264
+ - test/plugin/data/new-style-credentials.json
264
265
  - test/plugin/test_driver.rb
265
266
  - test/plugin/test_out_google_cloud.rb
266
267
  - test/plugin/test_out_google_cloud_grpc.rb
@@ -1,162 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- fluent-plugin-google-cloud (0.6.16)
5
- fluentd (~> 0.10)
6
- google-api-client (~> 0.17)
7
- google-cloud-logging (~> 1.3, >= 1.3.2)
8
- googleapis-common-protos (~> 1.3)
9
- googleauth (~> 0.6)
10
- grpc (~> 1.0)
11
- json (~> 1.8)
12
-
13
- GEM
14
- remote: https://rubygems.org/
15
- specs:
16
- addressable (2.5.2)
17
- public_suffix (>= 2.0.2, < 4.0)
18
- ast (2.4.0)
19
- cool.io (1.5.3)
20
- crack (0.4.3)
21
- safe_yaml (~> 1.0.0)
22
- declarative (0.0.10)
23
- declarative-option (0.1.0)
24
- faraday (0.14.0)
25
- multipart-post (>= 1.2, < 3)
26
- fluentd (0.14.25)
27
- cool.io (>= 1.4.5, < 2.0.0)
28
- http_parser.rb (>= 0.5.1, < 0.7.0)
29
- msgpack (>= 0.7.0, < 2.0.0)
30
- ruby_dig (~> 0.0.2)
31
- serverengine (>= 2.0.4, < 3.0.0)
32
- sigdump (~> 0.2.2)
33
- strptime (~> 0.1.7)
34
- tzinfo (~> 1.0)
35
- tzinfo-data (~> 1.0)
36
- yajl-ruby (~> 1.0)
37
- google-api-client (0.19.8)
38
- addressable (~> 2.5, >= 2.5.1)
39
- googleauth (>= 0.5, < 0.7.0)
40
- httpclient (>= 2.8.1, < 3.0)
41
- mime-types (~> 3.0)
42
- representable (~> 3.0)
43
- retriable (>= 2.0, < 4.0)
44
- google-cloud-core (1.2.0)
45
- google-cloud-env (~> 1.0)
46
- google-cloud-env (1.0.1)
47
- faraday (~> 0.11)
48
- google-cloud-logging (1.5.0)
49
- google-cloud-core (~> 1.2)
50
- google-gax (~> 1.0)
51
- stackdriver-core (~> 1.3)
52
- google-gax (1.0.1)
53
- google-protobuf (~> 3.2)
54
- googleapis-common-protos (>= 1.3.5, < 2.0)
55
- googleauth (~> 0.6.2)
56
- grpc (>= 1.7.2, < 2.0)
57
- rly (~> 0.2.3)
58
- google-protobuf (3.5.1.2)
59
- googleapis-common-protos (1.3.7)
60
- google-protobuf (~> 3.0)
61
- googleapis-common-protos-types (~> 1.0)
62
- grpc (~> 1.0)
63
- googleapis-common-protos-types (1.0.1)
64
- google-protobuf (~> 3.0)
65
- googleauth (0.6.2)
66
- faraday (~> 0.12)
67
- jwt (>= 1.4, < 3.0)
68
- logging (~> 2.0)
69
- memoist (~> 0.12)
70
- multi_json (~> 1.11)
71
- os (~> 0.9)
72
- signet (~> 0.7)
73
- grpc (1.9.1)
74
- google-protobuf (~> 3.1)
75
- googleapis-common-protos-types (~> 1.0.0)
76
- googleauth (>= 0.5.1, < 0.7)
77
- hashdiff (0.3.7)
78
- http_parser.rb (0.6.0)
79
- httpclient (2.8.3)
80
- json (1.8.6)
81
- jwt (2.1.0)
82
- little-plugger (1.1.4)
83
- logging (2.2.2)
84
- little-plugger (~> 1.1)
85
- multi_json (~> 1.10)
86
- memoist (0.16.0)
87
- metaclass (0.0.4)
88
- mime-types (3.1)
89
- mime-types-data (~> 3.2015)
90
- mime-types-data (3.2016.0521)
91
- mocha (1.3.0)
92
- metaclass (~> 0.0.1)
93
- msgpack (1.2.2)
94
- multi_json (1.13.1)
95
- multipart-post (2.0.0)
96
- os (0.9.6)
97
- parser (2.5.0.2)
98
- ast (~> 2.4.0)
99
- power_assert (1.1.1)
100
- powerpack (0.1.1)
101
- prometheus-client (0.7.1)
102
- quantile (~> 0.2.0)
103
- public_suffix (3.0.2)
104
- quantile (0.2.0)
105
- rainbow (2.2.2)
106
- rake
107
- rake (10.5.0)
108
- representable (3.0.4)
109
- declarative (< 0.1.0)
110
- declarative-option (< 0.2.0)
111
- uber (< 0.2.0)
112
- retriable (3.1.1)
113
- rly (0.2.3)
114
- rubocop (0.39.0)
115
- parser (>= 2.3.0.7, < 3.0)
116
- powerpack (~> 0.1)
117
- rainbow (>= 1.99.1, < 3.0)
118
- ruby-progressbar (~> 1.7)
119
- unicode-display_width (~> 1.0, >= 1.0.1)
120
- ruby-progressbar (1.9.0)
121
- ruby_dig (0.0.2)
122
- safe_yaml (1.0.4)
123
- serverengine (2.0.6)
124
- sigdump (~> 0.2.2)
125
- sigdump (0.2.4)
126
- signet (0.8.1)
127
- addressable (~> 2.3)
128
- faraday (~> 0.9)
129
- jwt (>= 1.5, < 3.0)
130
- multi_json (~> 1.10)
131
- stackdriver-core (1.3.0)
132
- google-cloud-core (~> 1.2)
133
- strptime (0.1.9)
134
- test-unit (3.2.7)
135
- power_assert
136
- thread_safe (0.3.6)
137
- tzinfo (1.2.5)
138
- thread_safe (~> 0.1)
139
- tzinfo-data (1.2018.3)
140
- tzinfo (>= 1.0.0)
141
- uber (0.1.0)
142
- unicode-display_width (1.3.0)
143
- webmock (2.3.2)
144
- addressable (>= 2.3.6)
145
- crack (>= 0.3.2)
146
- hashdiff
147
- yajl-ruby (1.3.1)
148
-
149
- PLATFORMS
150
- ruby
151
-
152
- DEPENDENCIES
153
- fluent-plugin-google-cloud!
154
- mocha (~> 1.1)
155
- prometheus-client (~> 0.7.1)
156
- rake (~> 10.3)
157
- rubocop (~> 0.39.0)
158
- test-unit (~> 3.0)
159
- webmock (~> 2.3.1)
160
-
161
- BUNDLED WITH
162
- 1.16.1