logstash-input-google_pubsub 1.3.0 → 1.4.0

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
  SHA256:
3
- metadata.gz: 939bc59bb6733b670afef19f24a3c651ed5fd984d180dbf89ceb206ee2c633ff
4
- data.tar.gz: f982db5ce84342d6c633131f7cba49e54102ece37d9ec829e7075a3830b39e91
3
+ metadata.gz: 9b4696d6b9d4edf149cfe2e20e95f1e60fe325abfef7b270d75ffc5abfb35b6c
4
+ data.tar.gz: 2aea3006b94752de7e74d2e514ec47d4ce26849f950f80d359c59bbdaef6ad4b
5
5
  SHA512:
6
- metadata.gz: 6c79cc1cadb234005cce5b9ed09782c18a030919c42ea8c3bf097e3d2b178f7395362548034f0092d477e8eb9c84ad9c3c54e02aa2e855ff731e1b3f298a589f
7
- data.tar.gz: 5f7b2241d2ab581d56311129b9e7947e589d99264ee3769e07eb5ac53f040cd063bb47f831830fdfc794dcaf2c2bf94a31d8a2f3c27178fec08b4eb590479084
6
+ metadata.gz: 26183a428dc24b48bec30ab50181422b38805ebe9723527a9a9543a587f75b99318ac25f97d885d52f1528e148d492e868e7a79798941817ce6bb26ce4ca6368
7
+ data.tar.gz: a05ce16d125d82202bdd1fb10e4ff452ce519aebace71390dd5d534db343b62f6e06b2bb313e83d81b300f622efb6a9650e171fa2e48de9d658532913db4a0e5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.4.0
2
+ - Added optional field json_key_file_content to get Service Account JSON key as an String input. [#68](https://github.com/logstash-plugins/logstash-input-google_pubsub/pull/68)
3
+
1
4
  ## 1.3.0
2
5
  - Updated plugins dependencies [#62](https://github.com/logstash-plugins/logstash-input-google_pubsub/pull/62)
3
6
 
data/README.md CHANGED
@@ -49,7 +49,9 @@ You have two options for authentication depending on where you run Logstash.
49
49
 
50
50
  1. If you are running Logstash outside of Google Cloud Platform, then you will
51
51
  need to create a Google Cloud Platform Service Account and specify the full
52
- path to the JSON private key file in your config. You must assign sufficient
52
+ path to the JSON private key file in your config in `json_key_file` setting.
53
+ If you don't want to upload the file and use its content as a string, then add the content
54
+ of JSON private key in `json_key_file_content` setting. You must assign sufficient
53
55
  roles to the Service Account to create a subscription and to pull messages
54
56
  from the subscription. Learn more about GCP Service Accounts and IAM roles
55
57
  here:
@@ -58,7 +60,7 @@ here:
58
60
  - Creating Service Accounts [overview](https://cloud.google.com/iam/docs/creating-managing-service-accounts)
59
61
  - Granting Roles [overview](https://cloud.google.com/iam/docs/granting-roles-to-service-accounts)
60
62
 
61
- 1. If you are running Logstash on a Google Compute Engine instance, you may opt
63
+ 2. If you are running Logstash on a Google Compute Engine instance, you may opt
62
64
  to use Application Default Credentials. In this case, you will not need to
63
65
  specify a JSON private key file in your config.
64
66
 
data/docs/index.asciidoc CHANGED
@@ -79,8 +79,9 @@ plugin will return the raw text in as `raw_message` in the logstash `event`.
79
79
  You have two options for authentication depending on where you run Logstash.
80
80
 
81
81
  1. If you are running Logstash outside of Google Cloud Platform, then you will
82
- need to create a Google Cloud Platform Service Account and specify the full
83
- path to the JSON private key file in your config. You must assign sufficient
82
+ path to the JSON private key file in your config in `json_key_file` setting.
83
+ If you don't want to upload the file and use its content as a string, then add the content
84
+ of JSON private key in `json_key_file_content` setting. You must assign sufficient
84
85
  roles to the Service Account to create a subscription and to pull messages
85
86
  from the subscription. Learn more about GCP Service Accounts and IAM roles
86
87
  here:
@@ -200,10 +200,18 @@ class LogStash::Inputs::GooglePubSub < LogStash::Inputs::Base
200
200
  config :subscription, :validate => :string, :required => true
201
201
  config :max_messages, :validate => :number, :required => true, :default => 5
202
202
 
203
- # If logstash is running within Google Compute Engine, the plugin will use
204
- # GCE's Application Default Credentials. Outside of GCE, you will need to
205
- # specify a Service Account JSON key file.
203
+ # If Logstash is running within Google Compute Engine (GCE), the plugin will use
204
+ # GCE's Application Default Credentials. When running outside of GCE, you must
205
+ # provide a Service Account JSON key. This can be done in one of two ways:
206
+ #
207
+ # 1. Specify the file path to the JSON key file using the `json_key_file` option.
208
+ # 2. Provide the JSON key as a base64-encoded string using the `json_key_file_content` option.
209
+ #
210
+ # Both `json_key_file` and `json_key_file_content` are optional, but you must
211
+ # specify one of them if Logstash is running outside of GCE. It is invalid to
212
+ # provide both options simultaneously.
206
213
  config :json_key_file, :validate => :path, :required => false
214
+ config :json_key_file_content, :validate => :string, :required => false
207
215
 
208
216
  # If set true, will include the full message data in the `[@metadata][pubsub_message]` field.
209
217
  config :include_metadata, :validate => :boolean, :required => false, :default => false
@@ -221,11 +229,20 @@ class LogStash::Inputs::GooglePubSub < LogStash::Inputs::Base
221
229
  @logger.debug("Registering Google PubSub Input: project_id=#{@project_id}, topic=#{@topic}, subscription=#{@subscription}")
222
230
  @subscription_id = "projects/#{@project_id}/subscriptions/#{@subscription}"
223
231
 
232
+ if json_key_file && json_key_file_content
233
+ raise LogStash::ConfigurationError, "Specify either 'json_key_file' or 'json_key_file_content', defining both simultanously is not permitted."
234
+ end
235
+
224
236
  if @json_key_file
225
237
  @credentialsProvider = FixedCredentialsProvider.create(
226
238
  ServiceAccountCredentials.fromStream(java.io.FileInputStream.new(@json_key_file))
227
239
  )
240
+ elsif @json_key_file_content
241
+ @credentialsProvider = FixedCredentialsProvider.create(
242
+ ServiceAccountCredentials.fromStream(java.io.ByteArrayInputStream.new((@json_key_file_content).to_java_bytes))
243
+ )
228
244
  end
245
+
229
246
  @topic_name = ProjectTopicName.of(@project_id, @topic)
230
247
  @subscription_name = ProjectSubscriptionName.of(@project_id, @subscription)
231
248
  end
@@ -51,4 +51,4 @@ require_jar('org.checkerframework', 'checker-qual', '3.33.0')
51
51
  require_jar('org.codehaus.mojo', 'animal-sniffer-annotations', '1.23')
52
52
  require_jar('org.conscrypt', 'conscrypt-openjdk-uber', '2.5.2')
53
53
  require_jar('org.threeten', 'threetenbp', '1.6.8')
54
- require_jar('org.logstash.inputs', 'plugin', '1.3.0')
54
+ require_jar('org.logstash.inputs', 'plugin', '1.4.0')
@@ -34,4 +34,12 @@ describe LogStash::Inputs::GooglePubSub do
34
34
  plugin = LogStash::Inputs::GooglePubSub.new(bad3)
35
35
  }.to raise_error(LogStash::ConfigurationError)
36
36
  end
37
+
38
+ let(:file_and_content_config_settings) { { 'project_id' => 'myproj', 'subscription' => 'foo', 'topic' => 'bar', 'json_key_file' => 'spec/inputs/test.json', 'json_key_file_content' => '{}' } }
39
+ it "raise a configuration error if both 'json_key_file' and 'json_key_file_content' are present" do
40
+ expect {
41
+ plugin = LogStash::Inputs::GooglePubSub.new(file_and_content_config_settings)
42
+ plugin.register()
43
+ }.to raise_error(LogStash::ConfigurationError)
44
+ end
37
45
  end
@@ -0,0 +1,14 @@
1
+ {
2
+ "type": "service_account",
3
+ "project_id": "test-project-id",
4
+ "private_key_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
5
+ "private_key": "-----BEGIN PRIVATE KEY-----\nxxxxxxxxxxx\n-----END PRIVATE KEY-----\n",
6
+ "client_email": "test-username@test-project-id.iam.gserviceaccount.com",
7
+ "client_id": "111111111111111111111",
8
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
9
+ "token_uri": "https://oauth2.googleapis.com/token",
10
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/apachesolrgcp-pubsub%40charged-mind-281913.iam.gserviceaccount.com",
12
+ "universe_domain": "googleapis.com"
13
+ }
14
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-google_pubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Johnson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-22 00:00:00.000000000 Z
11
+ date: 2024-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -17,8 +17,8 @@ dependencies:
17
17
  - !ruby/object:Gem::Version
18
18
  version: 8.2.0
19
19
  name: logstash-core
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
@@ -34,8 +34,8 @@ dependencies:
34
34
  - !ruby/object:Gem::Version
35
35
  version: '2.99'
36
36
  name: logstash-core-plugin-api
37
- prerelease: false
38
37
  type: :runtime
38
+ prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
@@ -51,8 +51,8 @@ dependencies:
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  name: logstash-codec-plain
54
- prerelease: false
55
54
  type: :runtime
55
+ prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - ">="
@@ -65,8 +65,8 @@ dependencies:
65
65
  - !ruby/object:Gem::Version
66
66
  version: 0.0.22
67
67
  name: stud
68
- prerelease: false
69
68
  type: :runtime
69
+ prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
@@ -79,8 +79,8 @@ dependencies:
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  name: logstash-devutils
82
- prerelease: false
83
82
  type: :development
83
+ prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
@@ -93,8 +93,8 @@ dependencies:
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0.4'
95
95
  name: jar-dependencies
96
- prerelease: false
97
96
  type: :development
97
+ prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
@@ -120,6 +120,7 @@ files:
120
120
  - lib/logstash/inputs/google_pubsub.rb
121
121
  - logstash-input-google_pubsub.gemspec
122
122
  - spec/inputs/google_pubsub_spec.rb
123
+ - spec/inputs/test.json
123
124
  - vendor/jar-dependencies/com/google/android/annotations/4.1.1.4/annotations-4.1.1.4.jar
124
125
  - vendor/jar-dependencies/com/google/api/api-common/2.15.0/api-common-2.15.0.jar
125
126
  - vendor/jar-dependencies/com/google/api/gax-grpc/2.32.0/gax-grpc-2.32.0.jar
@@ -169,7 +170,7 @@ files:
169
170
  - vendor/jar-dependencies/org/checkerframework/checker-qual/3.33.0/checker-qual-3.33.0.jar
170
171
  - vendor/jar-dependencies/org/codehaus/mojo/animal-sniffer-annotations/1.23/animal-sniffer-annotations-1.23.jar
171
172
  - vendor/jar-dependencies/org/conscrypt/conscrypt-openjdk-uber/2.5.2/conscrypt-openjdk-uber-2.5.2.jar
172
- - vendor/jar-dependencies/org/logstash/inputs/plugin/1.3.0/plugin-1.3.0.jar
173
+ - vendor/jar-dependencies/org/logstash/inputs/plugin/1.4.0/plugin-1.4.0.jar
173
174
  - vendor/jar-dependencies/org/threeten/threetenbp/1.6.8/threetenbp-1.6.8.jar
174
175
  homepage: https://cloud.google.com/pubsub/overview
175
176
  licenses:
@@ -199,9 +200,10 @@ requirements:
199
200
  - jar 'com.google.guava:guava', '20.0'
200
201
  - jar 'com.google.api:api-common', '1.2.0'
201
202
  - jar 'com.google.auth:google-auth-library-oauth2-http', '0.9.0'
202
- rubygems_version: 3.2.33
203
+ rubygems_version: 3.3.26
203
204
  signing_key:
204
205
  specification_version: 4
205
206
  summary: Consume events from a Google Cloud PubSub service
206
207
  test_files:
207
208
  - spec/inputs/google_pubsub_spec.rb
209
+ - spec/inputs/test.json