Skip to content

Commit

Permalink
fix: Match all whitespace and non-whitespace for Pub/Sub subscription…
Browse files Browse the repository at this point in the history
… filter validation (GoogleCloudPlatform#11676)
  • Loading branch information
michaelpri10 authored and niharika-98 committed Oct 7, 2024
1 parent 58ad7d1 commit 65d5725
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
8 changes: 7 additions & 1 deletion mmv1/products/pubsub/Subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ examples:
vars:
topic_name: 'example-topic'
subscription_name: 'example-subscription'
- !ruby/object:Provider::Terraform::Examples
name: 'pubsub_subscription_pull_filter'
primary_resource_id: 'example'
vars:
topic_name: 'example-topic'
subscription_name: 'example-subscription'
- !ruby/object:Provider::Terraform::Examples
name: 'pubsub_subscription_dead_letter'
primary_resource_id: 'example'
Expand Down Expand Up @@ -396,7 +402,7 @@ properties:
name: 'filter'
required: false
validation: !ruby/object:Provider::Terraform::Validation
regex: '^.{0,256}$'
regex: '^[\s\S]{0,256}$'
description: |
The subscription only delivers the messages that match the filter.
Pub/Sub automatically acknowledges the messages that don't match the filter. You can filter messages
Expand Down
7 changes: 6 additions & 1 deletion mmv1/products/pubsub/go_Subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ examples:
vars:
topic_name: 'example-topic'
subscription_name: 'example-subscription'
- name: 'pubsub_subscription_pull_filter'
primary_resource_id: 'example'
vars:
topic_name: 'example-topic'
subscription_name: 'example-subscription'
- name: 'pubsub_subscription_dead_letter'
primary_resource_id: 'example'
vars:
Expand Down Expand Up @@ -402,7 +407,7 @@ properties:
required: false
immutable: true
validation:
regex: '^.{0,256}$'
regex: '^[\s\S]{0,256}$'
- name: 'deadLetterPolicy'
type: NestedObject
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "google_pubsub_topic" "{{$.PrimaryResourceId}}" {
name = "{{index $.Vars "topic_name"}}"
}

resource "google_pubsub_subscription" "{{$.PrimaryResourceId}}" {
name = "{{index $.Vars "subscription_name"}}"
topic = google_pubsub_topic.{{$.PrimaryResourceId}}.id

labels = {
foo = "bar"
}

filter = <<EOF
attributes.foo = "foo"
AND attributes.bar = "bar"
EOF

ack_deadline_seconds = 20
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['topic_name'] %>"
}

resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['subscription_name'] %>"
topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id

labels = {
foo = "bar"
}

filter = <<EOF
attributes.foo = "foo"
AND attributes.bar = "bar"
EOF

ack_deadline_seconds = 20
}

0 comments on commit 65d5725

Please sign in to comment.