fluent-plugin-google-cloud 0.4.11 → 0.4.12

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: d5af03ce7a0e466c5bf132e69b7720f11edc41c7
4
- data.tar.gz: c6726cb7a73c3cdae27e24ec78b444d82123790f
3
+ metadata.gz: 1b7271a0228faf66d2353c964baa5c62a5ea4c07
4
+ data.tar.gz: 80bbb3c3317d2700a746a3dc26d341fc24157af8
5
5
  SHA512:
6
- metadata.gz: cbf1f33d49a88fcba407d75e564120c32bed24353fb88c4c383314e3f17d0437995c5abf05bc55feff9f18fff4ffa6bcfd97018a88c45b552a251b0a0c1720bf
7
- data.tar.gz: c9b2d17c4dba28ee407a7beef3d3a1081379da96a4e108e495bc5db0390bee4bde7bbed45321c8e614841c5664cf2cbc4f7d52f5733c9a0ab545a5527bc30824
6
+ metadata.gz: 7f952cb04e042f81d68c3fb6496b5baabf9c2f64ec9adfe4b1ad874c0c829e8c8126133907762066d0867636311fc47b1d011c485089096cc99f8171eb29c2b5
7
+ data.tar.gz: f10c6a9a326f7756cca26ca377ac002cdf45b712979f537d8e4873bf0b419d00fd2c464e15f9d73b294684af69db02ba78a80078204791fd97eca146f4f2d18f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-google-cloud (0.4.11)
4
+ fluent-plugin-google-cloud (0.4.12)
5
5
  fluentd (~> 0.10)
6
6
  google-api-client (>= 0.8.6, <= 0.9)
7
7
  googleauth (~> 0.4)
@@ -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.4.11'
13
+ gem.version = '0.4.12'
14
14
  gem.authors = ['Todd Derr', 'Alex Robinson']
15
15
  gem.email = ['salty@google.com']
16
16
 
@@ -54,6 +54,10 @@ module Fluent
54
54
  # can be obtained from the metadata service or set explicitly.
55
55
  # Otherwise, the plugin will fail to initialize.
56
56
  #
57
+ # Note that while 'project id' properly refers to the alphanumeric name
58
+ # of the project, the logging service will also accept the project number,
59
+ # so either one is acceptable in this context.
60
+ #
57
61
  # Whether to attempt to obtain metadata from the local metadata service.
58
62
  # It is safe to specify 'true' even on platforms with no metadata service.
59
63
  config_param :use_metadata_service, :bool, :default => true
@@ -596,15 +600,20 @@ module Fluent
596
600
  nil
597
601
  end
598
602
 
599
- # Extracts the project id from str. Assumes the project ID is at the
600
- # front of str, and consists of a string of digits terminated by a
601
- # dash (-) which is not part of the project ID. Example:
603
+ # Extracts the project id (either name or number) from str and returns
604
+ # it (as a string) on success, or nil on failure.
605
+ #
606
+ # Recognizes IAM format (account@project-name.iam.gserviceaccount.com)
607
+ # as well as the legacy format with a project number at the front of the
608
+ # string, terminated by a dash (-) which is not part of the ID, i.e.:
602
609
  # 270694816269-1l1r2hb813leuppurdeik0apglbs80sv.apps.googleusercontent.com
603
- # Returns the project ID (as a string) on success, or nil on failure.
604
610
  def self.extract_project_id(str)
605
- @project_regexp = /^(?<project_id>\d+)-/
606
- match_data = @project_regexp.match(str)
607
- match_data ? match_data['project_id'] : nil
611
+ [/^.*@(?<project_id>.+)\.iam\.gserviceaccount\.com/,
612
+ /^(?<project_id>\d+)-/].each do |exp|
613
+ match_data = exp.match(str)
614
+ return match_data['project_id'] unless match_data.nil?
615
+ end
616
+ nil
608
617
  end
609
618
  end
610
619
 
@@ -771,7 +780,7 @@ module Fluent
771
780
  def init_api_client
772
781
  @client = Google::APIClient.new(
773
782
  application_name: 'Fluentd Google Cloud Logging plugin',
774
- application_version: '0.4.11',
783
+ application_version: '0.4.12',
775
784
  retries: 1)
776
785
 
777
786
  if @auth_method == 'private_key'
@@ -5,4 +5,3 @@
5
5
  "client_id": "847859579879-q8ancssppuvtv8dac0i742pslde81jgl.apps.googleusercontent.com",
6
6
  "type": "service_account"
7
7
  }
8
-
@@ -0,0 +1,11 @@
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.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
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/account-name%40fluent-test-project.iam.gserviceaccount.com"
11
+ }
@@ -82,13 +82,21 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
82
82
  AUTH_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:jwt-bearer'
83
83
  FAKE_AUTH_TOKEN = 'abc123'
84
84
 
85
- # Paths to test credentials files
86
- CREDENTIALS_FILE = 'test/plugin/data/credentials.json'
87
- INVALID_CREDENTIALS_FILE = 'test/plugin/data/invalid_credentials.json'
88
-
89
- # Project ID for the test credentials.
90
- # This must match the prefix of 'client_id' in CREDENTIALS_FILE.
91
- CREDENTIALS_PROJECT_ID = '847859579879'
85
+ # Information about test credentials files.
86
+ # path: Path to the credentials file.
87
+ # project_id: ID of the project, which must correspond to the file contents.
88
+ IAM_CREDENTIALS = {
89
+ 'path' => 'test/plugin/data/iam-credentials.json',
90
+ 'project_id' => 'fluent-test-project'
91
+ }
92
+ LEGACY_CREDENTIALS = {
93
+ 'path' => 'test/plugin/data/credentials.json',
94
+ 'project_id' => '847859579879'
95
+ }
96
+ INVALID_CREDENTIALS = {
97
+ 'path' => 'test/plugin/data/invalid_credentials.json',
98
+ 'project_id' => ''
99
+ }
92
100
 
93
101
  # Configuration files for various test scenarios
94
102
  APPLICATION_DEFAULT_CONFIG = %(
@@ -501,10 +509,12 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
501
509
 
502
510
  def test_ec2_metadata_project_id_from_credentials
503
511
  setup_ec2_metadata_stubs
504
- ENV['GOOGLE_APPLICATION_CREDENTIALS'] = CREDENTIALS_FILE
505
- d = create_driver
506
- d.run
507
- assert_equal CREDENTIALS_PROJECT_ID, d.instance.project_id
512
+ [IAM_CREDENTIALS, LEGACY_CREDENTIALS].each do |creds|
513
+ ENV['GOOGLE_APPLICATION_CREDENTIALS'] = creds['path']
514
+ d = create_driver
515
+ d.run
516
+ assert_equal creds['project_id'], d.instance.project_id
517
+ end
508
518
  end
509
519
 
510
520
  def test_one_log
@@ -519,7 +529,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
519
529
  def test_one_log_with_json_credentials
520
530
  setup_gce_metadata_stubs
521
531
  setup_logging_stubs
522
- ENV['GOOGLE_APPLICATION_CREDENTIALS'] = CREDENTIALS_FILE
532
+ ENV['GOOGLE_APPLICATION_CREDENTIALS'] = IAM_CREDENTIALS['path']
523
533
  d = create_driver
524
534
  d.emit('message' => log_entry(0))
525
535
  d.run
@@ -529,7 +539,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
529
539
  def test_one_log_with_invalid_json_credentials
530
540
  setup_gce_metadata_stubs
531
541
  setup_logging_stubs
532
- ENV['GOOGLE_APPLICATION_CREDENTIALS'] = INVALID_CREDENTIALS_FILE
542
+ ENV['GOOGLE_APPLICATION_CREDENTIALS'] = INVALID_CREDENTIALS['path']
533
543
  d = create_driver
534
544
  d.emit('message' => log_entry(0))
535
545
  exception_count = 0
@@ -555,7 +565,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
555
565
  # don't set up any metadata stubs, so the test will fail if we try to
556
566
  # fetch metadata (and explicitly check this as well).
557
567
  Fluent::GoogleCloudOutput.any_instance.expects(:fetch_metadata).never
558
- ENV['GOOGLE_APPLICATION_CREDENTIALS'] = CREDENTIALS_FILE
568
+ ENV['GOOGLE_APPLICATION_CREDENTIALS'] = IAM_CREDENTIALS['path']
559
569
  setup_logging_stubs
560
570
  d = create_driver(NO_METADATA_SERVICE_CONFIG + CUSTOM_METADATA_CONFIG)
561
571
  d.emit('message' => log_entry(0))
@@ -564,7 +574,7 @@ class GoogleCloudOutputTest < Test::Unit::TestCase
564
574
  end
565
575
 
566
576
  def test_one_log_ec2
567
- ENV['GOOGLE_APPLICATION_CREDENTIALS'] = CREDENTIALS_FILE
577
+ ENV['GOOGLE_APPLICATION_CREDENTIALS'] = IAM_CREDENTIALS['path']
568
578
  setup_ec2_metadata_stubs
569
579
  setup_logging_stubs
570
580
  d = create_driver(CONFIG_EC2_PROJECT_ID)
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.4.11
4
+ version: 0.4.12
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: 2015-11-09 00:00:00.000000000 Z
12
+ date: 2015-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -165,6 +165,7 @@ files:
165
165
  - test/helper.rb
166
166
  - test/plugin/data/c31e573fd7f62ed495c9ca3821a5a85cb036dee1-privatekey.p12
167
167
  - test/plugin/data/credentials.json
168
+ - test/plugin/data/iam-credentials.json
168
169
  - test/plugin/data/invalid_credentials.json
169
170
  - test/plugin/test_out_google_cloud.rb
170
171
  homepage: https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud
@@ -195,5 +196,6 @@ test_files:
195
196
  - test/helper.rb
196
197
  - test/plugin/data/c31e573fd7f62ed495c9ca3821a5a85cb036dee1-privatekey.p12
197
198
  - test/plugin/data/credentials.json
199
+ - test/plugin/data/iam-credentials.json
198
200
  - test/plugin/data/invalid_credentials.json
199
201
  - test/plugin/test_out_google_cloud.rb