functions_framework 0.10.0 → 0.11.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/docs/overview.md +1 -1
- data/docs/writing-functions.md +2 -2
- data/lib/functions_framework/legacy_event_converter.rb +27 -7
- data/lib/functions_framework/server.rb +7 -3
- data/lib/functions_framework/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f9635b64ce67210f26441f5725d6ac6d46f470480411a93b736e470e108929a
|
4
|
+
data.tar.gz: 2c9df19eb02af7ecef29750bb0989eaaaa8ae6e6594fc5ebaf161d99fd6c477e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57c0cb8831225d0923cc31913693aa20f70fd245a7a5597ebbffe9d91aad51eeccd13a2c5697f010069afe529f143a320d29aa75c557edc6271f1361cacc9163
|
7
|
+
data.tar.gz: d8660d91dcdacbd5b35b44b3f8c9857d20bebb843d13c848651475e0f40884b564d6917e11b56394a3d7be0f711452308668ad66a6cdfbb05207b68a7ed23dc7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### v0.11.0 / 2021-06-28
|
4
|
+
|
5
|
+
* UPDATED: Update CloudEvents dependency to 0.5 to get fixes for JSON formatting cases
|
6
|
+
* FIXED: Updated Pub/Sub and Firebase event conversion logic to better align to Eventarc
|
7
|
+
|
3
8
|
### v0.10.0 / 2021-06-01
|
4
9
|
|
5
10
|
* ADDED: Support raw pubsub events sent by the pubsub emulator
|
data/README.md
CHANGED
@@ -60,7 +60,7 @@ Create a `Gemfile` listing the Functions Framework as a dependency:
|
|
60
60
|
```ruby
|
61
61
|
# Gemfile
|
62
62
|
source "https://rubygems.org"
|
63
|
-
gem "functions_framework", "~> 0.
|
63
|
+
gem "functions_framework", "~> 0.11"
|
64
64
|
```
|
65
65
|
|
66
66
|
Create a file called `app.rb` and include the following code. This defines a
|
data/docs/overview.md
CHANGED
@@ -64,7 +64,7 @@ Create a `Gemfile` listing the Functions Framework as a dependency:
|
|
64
64
|
```ruby
|
65
65
|
# Gemfile
|
66
66
|
source "https://rubygems.org"
|
67
|
-
gem "functions_framework", "~> 0.
|
67
|
+
gem "functions_framework", "~> 0.11"
|
68
68
|
```
|
69
69
|
|
70
70
|
Create a file called `app.rb` and include the following code. This defines a
|
data/docs/writing-functions.md
CHANGED
@@ -111,7 +111,7 @@ dependency on Sinatra in your `Gemfile`:
|
|
111
111
|
|
112
112
|
```ruby
|
113
113
|
source "https://rubygems.org"
|
114
|
-
gem "functions_framework", "~> 0.
|
114
|
+
gem "functions_framework", "~> 0.11"
|
115
115
|
gem "sinatra", "~> 2.0"
|
116
116
|
```
|
117
117
|
|
@@ -470,7 +470,7 @@ Following is a typical layout for a Functions Framework based project.
|
|
470
470
|
```ruby
|
471
471
|
# Gemfile
|
472
472
|
source "https://rubygems.org"
|
473
|
-
gem "functions_framework", "~> 0.
|
473
|
+
gem "functions_framework", "~> 0.11"
|
474
474
|
```
|
475
475
|
|
476
476
|
```ruby
|
@@ -84,10 +84,11 @@ module FunctionsFramework
|
|
84
84
|
id = normalized_context_field input, "eventId"
|
85
85
|
timestamp = normalized_context_field input, "timestamp"
|
86
86
|
type = normalized_context_field input, "eventType"
|
87
|
+
domain = normalized_context_field input, "domain"
|
87
88
|
service, resource = analyze_resource normalized_context_field input, "resource"
|
88
89
|
service ||= service_from_type type
|
89
90
|
return nil unless id && timestamp && type && service && resource
|
90
|
-
{ id: id, timestamp: timestamp, type: type, service: service, resource: resource }
|
91
|
+
{ id: id, timestamp: timestamp, type: type, service: service, resource: resource, domain: domain }
|
91
92
|
end
|
92
93
|
|
93
94
|
def normalized_context_field input, field
|
@@ -114,10 +115,10 @@ module FunctionsFramework
|
|
114
115
|
end
|
115
116
|
|
116
117
|
def construct_cloud_event context, data
|
117
|
-
source, subject = convert_source context[:service], context[:resource]
|
118
|
+
source, subject = convert_source context[:service], context[:resource], context[:domain]
|
118
119
|
type = LEGACY_TYPE_TO_CE_TYPE[context[:type]]
|
119
120
|
return nil unless type && source
|
120
|
-
ce_data, data_subject = convert_data context
|
121
|
+
ce_data, data_subject = convert_data context, data
|
121
122
|
content_type = "application/json"
|
122
123
|
::CloudEvents::Event.new id: context[:id],
|
123
124
|
source: source,
|
@@ -129,17 +130,36 @@ module FunctionsFramework
|
|
129
130
|
time: context[:timestamp]
|
130
131
|
end
|
131
132
|
|
132
|
-
def convert_source service, resource
|
133
|
+
def convert_source service, resource, domain
|
133
134
|
return ["//#{service}/#{resource}", nil] unless CE_SERVICE_TO_RESOURCE_RE.key? service
|
134
135
|
|
135
136
|
match = CE_SERVICE_TO_RESOURCE_RE[service].match resource
|
136
137
|
return [nil, nil] unless match
|
137
|
-
|
138
|
+
resource_fragment = match[1]
|
139
|
+
subject = match[2]
|
140
|
+
|
141
|
+
if service == "firebasedatabase.googleapis.com"
|
142
|
+
location =
|
143
|
+
case domain
|
144
|
+
when "firebaseio.com"
|
145
|
+
"us-central1"
|
146
|
+
when /^([\w-]+)\./
|
147
|
+
Regexp.last_match[1]
|
148
|
+
else
|
149
|
+
return [nil, nil]
|
150
|
+
end
|
151
|
+
["//#{service}/projects/_/locations/#{location}/#{resource_fragment}", subject]
|
152
|
+
else
|
153
|
+
["//#{service}/#{resource_fragment}", subject]
|
154
|
+
end
|
138
155
|
end
|
139
156
|
|
140
|
-
def convert_data
|
157
|
+
def convert_data context, data
|
158
|
+
service = context[:service]
|
141
159
|
case service
|
142
160
|
when "pubsub.googleapis.com"
|
161
|
+
data["messageId"] = context[:id]
|
162
|
+
data["publishTime"] = context[:timestamp]
|
143
163
|
[{ "message" => data }, nil]
|
144
164
|
when "firebaseauth.googleapis.com"
|
145
165
|
if data.key? "metadata"
|
@@ -189,7 +209,7 @@ module FunctionsFramework
|
|
189
209
|
|
190
210
|
CE_SERVICE_TO_RESOURCE_RE = {
|
191
211
|
"firebase.googleapis.com" => %r{^(projects/[^/]+)/(events/[^/]+)$},
|
192
|
-
"firebasedatabase.googleapis.com" => %r{^
|
212
|
+
"firebasedatabase.googleapis.com" => %r{^projects/_/(instances/[^/]+)/(refs/.+)$},
|
193
213
|
"firestore.googleapis.com" => %r{^(projects/[^/]+/databases/\(default\))/(documents/.+)$},
|
194
214
|
"storage.googleapis.com" => %r{^(projects/[^/]+/buckets/[^/]+)/([^#]+)(?:#.*)?$}
|
195
215
|
}.freeze
|
@@ -431,7 +431,7 @@ module FunctionsFramework
|
|
431
431
|
when ::CloudEvents::Event
|
432
432
|
handle_cloud_event event, logger
|
433
433
|
when ::Array
|
434
|
-
::CloudEvents::
|
434
|
+
::CloudEvents::CloudEventsError.new "Batched CloudEvents are not supported"
|
435
435
|
when ::CloudEvents::CloudEventsError
|
436
436
|
event
|
437
437
|
else
|
@@ -443,9 +443,13 @@ module FunctionsFramework
|
|
443
443
|
private
|
444
444
|
|
445
445
|
def decode_event env
|
446
|
-
|
446
|
+
begin
|
447
|
+
@cloud_events.decode_event env
|
448
|
+
rescue ::CloudEvents::NotCloudEventError
|
449
|
+
env["rack.input"].rewind rescue nil
|
447
450
|
@legacy_events.decode_rack_env(env) ||
|
448
|
-
|
451
|
+
raise(::CloudEvents::CloudEventsError, "Unrecognized event format")
|
452
|
+
end
|
449
453
|
rescue ::CloudEvents::CloudEventsError => e
|
450
454
|
e
|
451
455
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: functions_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.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: 2021-06-
|
11
|
+
date: 2021-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cloud_events
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.5.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 2.a
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 0.5.1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.a
|
@@ -99,10 +99,10 @@ homepage: https://github.com/GoogleCloudPlatform/functions-framework-ruby
|
|
99
99
|
licenses:
|
100
100
|
- Apache-2.0
|
101
101
|
metadata:
|
102
|
-
changelog_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v0.
|
102
|
+
changelog_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v0.11.0/file.CHANGELOG.html
|
103
103
|
source_code_uri: https://github.com/GoogleCloudPlatform/functions-framework-ruby
|
104
104
|
bug_tracker_uri: https://github.com/GoogleCloudPlatform/functions-framework-ruby/issues
|
105
|
-
documentation_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v0.
|
105
|
+
documentation_uri: https://googlecloudplatform.github.io/functions-framework-ruby/v0.11.0
|
106
106
|
post_install_message:
|
107
107
|
rdoc_options: []
|
108
108
|
require_paths:
|