Skip to content

Add support for specifying event filters #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ jobs:
runtime: 'nodejs22'
entry_point: 'helloWorld'
source_dir: './tests/test-node-func/'
event_trigger_type: 'google.cloud.pubsub.topic.v1.messagePublished'
event_trigger_pubsub_topic: '${{ vars.PUBSUB_TOPIC_NAME }}'
event_trigger_type: 'google.cloud.audit.log.v1.written'
event_trigger_filters: |-
serviceName=storage.googleapis.com
methodName=storage.objects.create
event_trigger_retry: true
event_trigger_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
environment_variables: |-
Expand Down
69 changes: 52 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ jobs:
variable `GHA_ENDPOINT_OVERRIDE_<endpoint>` where `<endpoint>` is the API
endpoint to override. For example:

env:
GHA_ENDPOINT_OVERRIDE_oauth2: 'https://oauth2.myapi.endpoint/v1'
```yaml
env:
GHA_ENDPOINT_OVERRIDE_oauth2: 'https://oauth2.myapi.endpoint/v1'
```

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

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

labels: |-
labela=my-label
labelb=my-other-label
```yaml
labels: |-
labela=my-label
labelb=my-other-label
```

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

build_environment_variables: |-
FRUIT=apple
SENTENCE=" this will retain leading and trailing spaces "
```yaml
build_environment_variables: |-
FRUIT=apple
SENTENCE=" this will retain leading and trailing spaces "
```

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

environment_variables: |-
FRUIT=apple
SENTENCE=" this will retain leading and trailing spaces "
```yaml
environment_variables: |-
FRUIT=apple
SENTENCE=" this will retain leading and trailing spaces "
```

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

with:
secrets: |-
# As an environment variable:
KEY1=secret-key-1:latest

# As a volume mount:
/secrets/api/key=secret-key-2:latest
```yaml
with:
secrets: |-
# As an environment variable:
KEY1=secret-key-1:latest

# As a volume mount:
/secrets/api/key=secret-key-2:latest
```

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

The available trigger types may change over time.

- <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
matches all the filteres will trigger calls to the function. These are
comma-separated or newline-separated `ATTRIBUTE=VALUE`. Attributes or
values that contain separators must be escaped with a backslash (e.g. `\,`
or `\\n`) unless quoted. To treat a value as a path pattern, prefix the
value with the literal string `PATTERN:`. Any leading or trailing
whitespace is trimmed unless values are quoted.

```yaml
event_trigger_type: 'google.cloud.audit.log.v1.written'
event_trigger_filters: |-
serviceName=compute.googleapis.com
methodName=PATTERN:compute.instances.*
```

This value will only be set if the input is a non-empty value. If a
non-empty value is given, the field values will be overwritten (not
merged). To remove all values, set the value to the literal string `{}`.

For more information, see [Eventarc
Triggers](https://cloud.google.com/functions/docs/calling/eventarc) and
[Eventarc Path
Patterns](https://cloud.google.com/eventarc/docs/path-patterns).

- <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
will trigger function execution with message contents passed as input
data of the format:
Expand Down
71 changes: 54 additions & 17 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ inputs:
variable `GHA_ENDPOINT_OVERRIDE_<endpoint>` where `<endpoint>` is the API
endpoint to override. For example:

env:
GHA_ENDPOINT_OVERRIDE_oauth2: 'https://oauth2.myapi.endpoint/v1'
```yaml
env:
GHA_ENDPOINT_OVERRIDE_oauth2: 'https://oauth2.myapi.endpoint/v1'
```

For more information about universes, see the Google Cloud documentation.
default: 'googleapis.com'
Expand Down Expand Up @@ -87,9 +89,11 @@ inputs:
unless quoted. Any leading or trailing whitespace is trimmed unless values
are quoted.

labels: |-
labela=my-label
labelb=my-other-label
```yaml
labels: |-
labela=my-label
labelb=my-other-label
```

This value will only be set if the input is a non-empty value. If a
non-empty value is given, the field values will be overwritten (not
Expand Down Expand Up @@ -133,9 +137,11 @@ inputs:
`\\n`) unless quoted. Any leading or trailing whitespace is trimmed unless
values are quoted.

build_environment_variables: |-
FRUIT=apple
SENTENCE=" this will retain leading and trailing spaces "
```yaml
build_environment_variables: |-
FRUIT=apple
SENTENCE=" this will retain leading and trailing spaces "
```

This value will only be set if the input is a non-empty value. If a
non-empty value is given, the field values will be overwritten (not
Expand Down Expand Up @@ -222,9 +228,11 @@ inputs:
(e.g. `\,` or `\\n`) unless quoted. Any leading or trailing whitespace is
trimmed unless values are quoted.

environment_variables: |-
FRUIT=apple
SENTENCE=" this will retain leading and trailing spaces "
```yaml
environment_variables: |-
FRUIT=apple
SENTENCE=" this will retain leading and trailing spaces "
```

This value will only be set if the input is a non-empty value. If a
non-empty value is given, the field values will be overwritten (not
Expand Down Expand Up @@ -273,13 +281,16 @@ inputs:
volumes. Keys starting with a forward slash '/' are mount paths. All other
keys correspond to environment variables:

with:
secrets: |-
# As an environment variable:
KEY1=secret-key-1:latest

# As a volume mount:
/secrets/api/key=secret-key-2:latest
```yaml
with:
secrets: |-
# As an environment variable:
KEY1=secret-key-1:latest

# As a volume mount:
/secrets/api/key=secret-key-2:latest
```

This value will only be set if the input is a non-empty value. If a
non-empty value is given, the field values will be overwritten (not
Expand Down Expand Up @@ -345,6 +356,32 @@ inputs:
The available trigger types may change over time.
required: false

event_trigger_filters:
description: |-
List of event filters that the trigger should monitor. An event that
matches all the filteres will trigger calls to the function. These are
comma-separated or newline-separated `ATTRIBUTE=VALUE`. Attributes or
values that contain separators must be escaped with a backslash (e.g. `\,`
or `\\n`) unless quoted. To treat a value as a path pattern, prefix the
value with the literal string `PATTERN:`. Any leading or trailing
whitespace is trimmed unless values are quoted.

```yaml
event_trigger_type: 'google.cloud.audit.log.v1.written'
event_trigger_filters: |-
serviceName=compute.googleapis.com
methodName=PATTERN:compute.instances.*
```

This value will only be set if the input is a non-empty value. If a
non-empty value is given, the field values will be overwritten (not
merged). To remove all values, set the value to the literal string `{}`.

For more information, see [Eventarc
Triggers](https://cloud.google.com/functions/docs/calling/eventarc) and
[Eventarc Path
Patterns](https://cloud.google.com/eventarc/docs/path-patterns).

event_trigger_pubsub_topic:
description: |-
Name of Google Cloud Pub/Sub topic. Every message published in this topic
Expand Down
8 changes: 4 additions & 4 deletions dist/index.js

Large diffs are not rendered by default.

Loading
Loading