Skip to content

Commit f650806

Browse files
committed
Add support for specifying event filters
1 parent 316d9c5 commit f650806

File tree

10 files changed

+302
-137
lines changed

10 files changed

+302
-137
lines changed

.github/workflows/integration.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ jobs:
7474
runtime: 'nodejs22'
7575
entry_point: 'helloWorld'
7676
source_dir: './tests/test-node-func/'
77-
event_trigger_type: 'google.cloud.pubsub.topic.v1.messagePublished'
77+
event_trigger_type: 'google.cloud.audit.log.v1.written'
78+
event_trigger_filters: |-
79+
serviceName=storage.googleapis.com
80+
methodName=storage.objects.create
7881
event_trigger_pubsub_topic: '${{ vars.PUBSUB_TOPIC_NAME }}'
7982
event_trigger_retry: true
8083
event_trigger_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'

README.md

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ jobs:
8181
variable `GHA_ENDPOINT_OVERRIDE_<endpoint>` where `<endpoint>` is the API
8282
endpoint to override. For example:
8383

84-
env:
85-
GHA_ENDPOINT_OVERRIDE_oauth2: 'https://oauth2.myapi.endpoint/v1'
84+
```yaml
85+
env:
86+
GHA_ENDPOINT_OVERRIDE_oauth2: 'https://oauth2.myapi.endpoint/v1'
87+
```
8688

8789
For more information about universes, see the Google Cloud documentation.
8890

@@ -104,9 +106,11 @@ jobs:
104106
unless quoted. Any leading or trailing whitespace is trimmed unless values
105107
are quoted.
106108

107-
labels: |-
108-
labela=my-label
109-
labelb=my-other-label
109+
```yaml
110+
labels: |-
111+
labela=my-label
112+
labelb=my-other-label
113+
```
110114

111115
This value will only be set if the input is a non-empty value. If a
112116
non-empty value is given, the field values will be overwritten (not
@@ -136,9 +140,11 @@ jobs:
136140
`\\n`) unless quoted. Any leading or trailing whitespace is trimmed unless
137141
values are quoted.
138142

139-
build_environment_variables: |-
140-
FRUIT=apple
141-
SENTENCE=" this will retain leading and trailing spaces "
143+
```yaml
144+
build_environment_variables: |-
145+
FRUIT=apple
146+
SENTENCE=" this will retain leading and trailing spaces "
147+
```
142148

143149
This value will only be set if the input is a non-empty value. If a
144150
non-empty value is given, the field values will be overwritten (not
@@ -197,9 +203,11 @@ jobs:
197203
(e.g. `\,` or `\\n`) unless quoted. Any leading or trailing whitespace is
198204
trimmed unless values are quoted.
199205

200-
environment_variables: |-
201-
FRUIT=apple
202-
SENTENCE=" this will retain leading and trailing spaces "
206+
```yaml
207+
environment_variables: |-
208+
FRUIT=apple
209+
SENTENCE=" this will retain leading and trailing spaces "
210+
```
203211

204212
This value will only be set if the input is a non-empty value. If a
205213
non-empty value is given, the field values will be overwritten (not
@@ -232,13 +240,16 @@ jobs:
232240
volumes. Keys starting with a forward slash '/' are mount paths. All other
233241
keys correspond to environment variables:
234242

235-
with:
236-
secrets: |-
237-
# As an environment variable:
238-
KEY1=secret-key-1:latest
239243

240-
# As a volume mount:
241-
/secrets/api/key=secret-key-2:latest
244+
```yaml
245+
with:
246+
secrets: |-
247+
# As an environment variable:
248+
KEY1=secret-key-1:latest
249+
250+
# As a volume mount:
251+
/secrets/api/key=secret-key-2:latest
252+
```
242253

243254
This value will only be set if the input is a non-empty value. If a
244255
non-empty value is given, the field values will be overwritten (not
@@ -280,6 +291,30 @@ jobs:
280291

281292
The available trigger types may change over time.
282293

294+
- <a name="event_trigger_filters"></a><a href="#user-content-event_trigger_filters"><code>event_trigger_filters</code></a>: _(Optional)_ List of event filters that the trigger should monitor. An event that
295+
matches all the filteres will trigger calls to the function. These are
296+
comma-separated or newline-separated `ATTRIBUTE=VALUE`. Attributes or
297+
values that contain separators must be escaped with a backslash (e.g. `\,`
298+
or `\\n`) unless quoted. To treat a value as a path pattern, prefix the
299+
value with the literal string `PATTERN:`. Any leading or trailing
300+
whitespace is trimmed unless values are quoted.
301+
302+
```yaml
303+
event_trigger_type: 'google.cloud.audit.log.v1.written'
304+
event_trigger_filters: |-
305+
serviceName=compute.googleapis.com
306+
methodName=PATTERN:compute.instances.*
307+
```
308+
309+
This value will only be set if the input is a non-empty value. If a
310+
non-empty value is given, the field values will be overwritten (not
311+
merged). To remove all values, set the value to the literal string `{}`.
312+
313+
For more information, see [Eventarc
314+
Triggers](https://cloud.google.com/functions/docs/calling/eventarc) and
315+
[Eventarc Path
316+
Patterns](https://cloud.google.com/eventarc/docs/path-patterns).
317+
283318
- <a name="event_trigger_pubsub_topic"></a><a href="#user-content-event_trigger_pubsub_topic"><code>event_trigger_pubsub_topic</code></a>: _(Optional)_ Name of Google Cloud Pub/Sub topic. Every message published in this topic
284319
will trigger function execution with message contents passed as input
285320
data of the format:

action.yml

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ inputs:
4343
variable `GHA_ENDPOINT_OVERRIDE_<endpoint>` where `<endpoint>` is the API
4444
endpoint to override. For example:
4545
46-
env:
47-
GHA_ENDPOINT_OVERRIDE_oauth2: 'https://oauth2.myapi.endpoint/v1'
46+
```yaml
47+
env:
48+
GHA_ENDPOINT_OVERRIDE_oauth2: 'https://oauth2.myapi.endpoint/v1'
49+
```
4850
4951
For more information about universes, see the Google Cloud documentation.
5052
default: 'googleapis.com'
@@ -87,9 +89,11 @@ inputs:
8789
unless quoted. Any leading or trailing whitespace is trimmed unless values
8890
are quoted.
8991
90-
labels: |-
91-
labela=my-label
92-
labelb=my-other-label
92+
```yaml
93+
labels: |-
94+
labela=my-label
95+
labelb=my-other-label
96+
```
9397
9498
This value will only be set if the input is a non-empty value. If a
9599
non-empty value is given, the field values will be overwritten (not
@@ -133,9 +137,11 @@ inputs:
133137
`\\n`) unless quoted. Any leading or trailing whitespace is trimmed unless
134138
values are quoted.
135139
136-
build_environment_variables: |-
137-
FRUIT=apple
138-
SENTENCE=" this will retain leading and trailing spaces "
140+
```yaml
141+
build_environment_variables: |-
142+
FRUIT=apple
143+
SENTENCE=" this will retain leading and trailing spaces "
144+
```
139145
140146
This value will only be set if the input is a non-empty value. If a
141147
non-empty value is given, the field values will be overwritten (not
@@ -222,9 +228,11 @@ inputs:
222228
(e.g. `\,` or `\\n`) unless quoted. Any leading or trailing whitespace is
223229
trimmed unless values are quoted.
224230
225-
environment_variables: |-
226-
FRUIT=apple
227-
SENTENCE=" this will retain leading and trailing spaces "
231+
```yaml
232+
environment_variables: |-
233+
FRUIT=apple
234+
SENTENCE=" this will retain leading and trailing spaces "
235+
```
228236
229237
This value will only be set if the input is a non-empty value. If a
230238
non-empty value is given, the field values will be overwritten (not
@@ -273,13 +281,16 @@ inputs:
273281
volumes. Keys starting with a forward slash '/' are mount paths. All other
274282
keys correspond to environment variables:
275283
276-
with:
277-
secrets: |-
278-
# As an environment variable:
279-
KEY1=secret-key-1:latest
280284
281-
# As a volume mount:
282-
/secrets/api/key=secret-key-2:latest
285+
```yaml
286+
with:
287+
secrets: |-
288+
# As an environment variable:
289+
KEY1=secret-key-1:latest
290+
291+
# As a volume mount:
292+
/secrets/api/key=secret-key-2:latest
293+
```
283294
284295
This value will only be set if the input is a non-empty value. If a
285296
non-empty value is given, the field values will be overwritten (not
@@ -345,6 +356,32 @@ inputs:
345356
The available trigger types may change over time.
346357
required: false
347358

359+
event_trigger_filters:
360+
description: |-
361+
List of event filters that the trigger should monitor. An event that
362+
matches all the filteres will trigger calls to the function. These are
363+
comma-separated or newline-separated `ATTRIBUTE=VALUE`. Attributes or
364+
values that contain separators must be escaped with a backslash (e.g. `\,`
365+
or `\\n`) unless quoted. To treat a value as a path pattern, prefix the
366+
value with the literal string `PATTERN:`. Any leading or trailing
367+
whitespace is trimmed unless values are quoted.
368+
369+
```yaml
370+
event_trigger_type: 'google.cloud.audit.log.v1.written'
371+
event_trigger_filters: |-
372+
serviceName=compute.googleapis.com
373+
methodName=PATTERN:compute.instances.*
374+
```
375+
376+
This value will only be set if the input is a non-empty value. If a
377+
non-empty value is given, the field values will be overwritten (not
378+
merged). To remove all values, set the value to the literal string `{}`.
379+
380+
For more information, see [Eventarc
381+
Triggers](https://cloud.google.com/functions/docs/calling/eventarc) and
382+
[Eventarc Path
383+
Patterns](https://cloud.google.com/eventarc/docs/path-patterns).
384+
348385
event_trigger_pubsub_topic:
349386
description: |-
350387
Name of Google Cloud Pub/Sub topic. Every message published in this topic

dist/index.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)