functions_framework 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/docs/deploying-functions.md +7 -1
- data/lib/functions_framework/cloud_events/content_type.rb +7 -1
- data/lib/functions_framework/legacy_event_converter.rb +19 -19
- data/lib/functions_framework/server.rb +6 -2
- data/lib/functions_framework/version.rb +1 -1
- metadata +7 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 817129c1773079fed039152996a18e91a054241940b8d6e3437cb66e10046304
|
4
|
+
data.tar.gz: ff3f61597726b60241e8b528ef520641fa3f08ddb7adcdfb32f9413fcb125f45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7396117d6e94bec87c70c697c7364b9256c7575f61c7259eb25df65694e9627b6c33a93e0caaea5d9d7955707e731eaddc27b90d4595f0029d181fc6cc18bfdf
|
7
|
+
data.tar.gz: 8eb929ace2a49ae764f5de0fef6dd7e0d668c80864368ad2379d0e52a89a44c7a3514e92dc02802d940374808a271a89f3076f1c8f3d0a532204118615e0c1af
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### v0.4.1 / 2020-07-08
|
4
|
+
|
5
|
+
* Fixed unsupported signal error on Windows.
|
6
|
+
* Fixed several edge case errors in legacy event conversion.
|
7
|
+
* Generated Content-Type headers now properly quote param values if needed.
|
8
|
+
* Minor documentation updates.
|
9
|
+
|
3
10
|
### v0.4.0 / 2020-06-29
|
4
11
|
|
5
12
|
* Dropped the legacy and largely unsupported `:event` function type. All event functions should be of type `:cloud_event`.
|
data/docs/deploying-functions.md
CHANGED
@@ -105,6 +105,12 @@ to adapt it if you have an Anthos installation.
|
|
105
105
|
|
106
106
|
### Building an image for your function
|
107
107
|
|
108
|
+
Before you can deploy to Cloud Run, make sure your bundle, and in
|
109
|
+
particular your `Gemfile.lock` file, is up to date. The easiest way to do this
|
110
|
+
is to `bundle install` or `bundle update` and run your local tests prior to
|
111
|
+
deploying. The configuration used in the Dockerfile below will not accept your
|
112
|
+
function unless an up-to-date `Gemfile.lock` is present.
|
113
|
+
|
108
114
|
First, build a Docker image containing your function. Following is a simple
|
109
115
|
Dockerfile that you can use as a starting point. Feel free to adjust it to the
|
110
116
|
needs of your project:
|
@@ -165,7 +171,7 @@ deployed function.
|
|
165
171
|
|
166
172
|
Note that our Dockerfile's entrypoint did not pass any source file or target
|
167
173
|
name to the Functions Framework. If these are not specified, the Framework will
|
168
|
-
use the source
|
174
|
+
use the source `./app.rb` and the target `function` by default. To use different
|
169
175
|
values, you need to set the appropriate environment variables when deploying, as
|
170
176
|
illustrated above with the `FUNCTION_SOURCE` and `FUNCTION_TARGET` variables.
|
171
177
|
|
@@ -43,7 +43,7 @@ module FunctionsFramework
|
|
43
43
|
@error_message = nil
|
44
44
|
parse consume_comments string.strip
|
45
45
|
@canonical_string = "#{@media_type}/#{@subtype}" +
|
46
|
-
@params.map { |k, v| "; #{k}=#{v}" }.join
|
46
|
+
@params.map { |k, v| "; #{k}=#{maybe_quote v}" }.join
|
47
47
|
end
|
48
48
|
|
49
49
|
##
|
@@ -211,6 +211,12 @@ module FunctionsFramework
|
|
211
211
|
index += 1
|
212
212
|
consume_comments str[index..-1].strip
|
213
213
|
end
|
214
|
+
|
215
|
+
def maybe_quote str
|
216
|
+
return str if /^[\w!#\$%&'\*\+\.\^`\{\|\}-]+$/ =~ str
|
217
|
+
str = str.gsub("\\", "\\\\\\\\").gsub("\"", "\\\\\"")
|
218
|
+
"\"#{str}\""
|
219
|
+
end
|
214
220
|
end
|
215
221
|
end
|
216
222
|
end
|
@@ -32,10 +32,9 @@ module FunctionsFramework
|
|
32
32
|
return nil unless content_type.media_type == "application" && content_type.subtype_base == "json"
|
33
33
|
input = read_input_json env["rack.input"], content_type.charset
|
34
34
|
return nil unless input
|
35
|
-
|
36
|
-
context = normalized_context raw_context
|
35
|
+
context = normalized_context input
|
37
36
|
return nil unless context
|
38
|
-
construct_cloud_event context, input["data"]
|
37
|
+
construct_cloud_event context, input["data"], content_type.charset
|
39
38
|
end
|
40
39
|
|
41
40
|
private
|
@@ -50,27 +49,27 @@ module FunctionsFramework
|
|
50
49
|
nil
|
51
50
|
end
|
52
51
|
|
53
|
-
def normalized_context
|
54
|
-
|
55
|
-
|
56
|
-
timestamp = raw_context["timestamp"]
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
return nil unless service && resource
|
52
|
+
def normalized_context input
|
53
|
+
raw_context = input["context"]
|
54
|
+
id = raw_context&.[]("eventId") || input["eventId"]
|
55
|
+
timestamp = raw_context&.[]("timestamp") || input["timestamp"]
|
56
|
+
type = raw_context&.[]("eventType") || input["eventType"]
|
57
|
+
service, resource = analyze_resource raw_context&.[]("resource") || input["resource"]
|
58
|
+
service ||= service_from_type type
|
59
|
+
return nil unless id && timestamp && type && service && resource
|
62
60
|
{ id: id, timestamp: timestamp, type: type, service: service, resource: resource }
|
63
61
|
end
|
64
62
|
|
65
|
-
def analyze_resource raw_resource
|
63
|
+
def analyze_resource raw_resource
|
64
|
+
service = resource = nil
|
66
65
|
case raw_resource
|
67
66
|
when ::Hash
|
68
|
-
|
67
|
+
service = raw_resource["service"]
|
68
|
+
resource = raw_resource["name"]
|
69
69
|
when ::String
|
70
|
-
|
71
|
-
else
|
72
|
-
[nil, nil]
|
70
|
+
resource = raw_resource
|
73
71
|
end
|
72
|
+
[service, resource]
|
74
73
|
end
|
75
74
|
|
76
75
|
def service_from_type type
|
@@ -80,16 +79,17 @@ module FunctionsFramework
|
|
80
79
|
nil
|
81
80
|
end
|
82
81
|
|
83
|
-
def construct_cloud_event context, data
|
82
|
+
def construct_cloud_event context, data, charset
|
84
83
|
source, subject = convert_source context[:service], context[:resource]
|
85
84
|
type = LEGACY_TYPE_TO_CE_TYPE[context[:type]]
|
86
85
|
return nil unless type && source
|
87
86
|
ce_data = convert_data context[:service], data
|
87
|
+
content_type = "application/json; charset=#{charset}"
|
88
88
|
CloudEvents::Event.new id: context[:id],
|
89
89
|
source: source,
|
90
90
|
type: type,
|
91
91
|
spec_version: "1.0",
|
92
|
-
data_content_type:
|
92
|
+
data_content_type: content_type,
|
93
93
|
data: ce_data,
|
94
94
|
subject: subject,
|
95
95
|
time: context[:timestamp]
|
@@ -149,8 +149,12 @@ module FunctionsFramework
|
|
149
149
|
::Signal.trap "SIGINT" do
|
150
150
|
Server.signal_enqueue "SIGINT", @config.logger, @server
|
151
151
|
end
|
152
|
-
|
153
|
-
|
152
|
+
begin
|
153
|
+
::Signal.trap "SIGHUP" do
|
154
|
+
Server.signal_enqueue "SIGHUP", @config.logger, @server
|
155
|
+
end
|
156
|
+
rescue ::ArgumentError # rubocop:disable Lint/HandleExceptions
|
157
|
+
# Not available on all systems
|
154
158
|
end
|
155
159
|
@signals_installed = true
|
156
160
|
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.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puma
|
@@ -38,104 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.1'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: google-style
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.24.0
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 1.24.0
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5.13'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5.13'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest-focus
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.1'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.1'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: minitest-rg
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '5.2'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '5.2'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: redcarpet
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '3.5'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '3.5'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: toys
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.10.0
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.10.0
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: yard
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 0.9.24
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 0.9.24
|
139
41
|
description: The Functions Framework implementation for Ruby.
|
140
42
|
email:
|
141
43
|
- dazuma@google.com
|
@@ -176,7 +78,11 @@ files:
|
|
176
78
|
homepage: https://github.com/GoogleCloudPlatform/functions-framework-ruby
|
177
79
|
licenses:
|
178
80
|
- Apache-2.0
|
179
|
-
metadata:
|
81
|
+
metadata:
|
82
|
+
changelog_uri: https://github.com/GoogleCloudPlatform/functions-framework-ruby/blob/master/CHANGELOG.md
|
83
|
+
source_code_uri: https://github.com/GoogleCloudPlatform/functions-framework-ruby
|
84
|
+
bug_tracker_uri: https://github.com/GoogleCloudPlatform/functions-framework-ruby/issues
|
85
|
+
documentation_uri: https://rubydoc.info/gems/functions_framework/0.4.1
|
180
86
|
post_install_message:
|
181
87
|
rdoc_options: []
|
182
88
|
require_paths:
|