Skip to content

Commit 1f99e21

Browse files
michaelpri10abd-goog
authored andcommitted
fix: Match all whitespace and non-whitespace for Pub/Sub subscription filter validation (GoogleCloudPlatform#11676)
1 parent a979807 commit 1f99e21

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

mmv1/products/pubsub/Subscription.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ examples:
4242
vars:
4343
topic_name: 'example-topic'
4444
subscription_name: 'example-subscription'
45+
- !ruby/object:Provider::Terraform::Examples
46+
name: 'pubsub_subscription_pull_filter'
47+
primary_resource_id: 'example'
48+
vars:
49+
topic_name: 'example-topic'
50+
subscription_name: 'example-subscription'
4551
- !ruby/object:Provider::Terraform::Examples
4652
name: 'pubsub_subscription_dead_letter'
4753
primary_resource_id: 'example'
@@ -396,7 +402,7 @@ properties:
396402
name: 'filter'
397403
required: false
398404
validation: !ruby/object:Provider::Terraform::Validation
399-
regex: '^.{0,256}$'
405+
regex: '^[\s\S]{0,256}$'
400406
description: |
401407
The subscription only delivers the messages that match the filter.
402408
Pub/Sub automatically acknowledges the messages that don't match the filter. You can filter messages

mmv1/products/pubsub/go_Subscription.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ examples:
5656
vars:
5757
topic_name: 'example-topic'
5858
subscription_name: 'example-subscription'
59+
- name: 'pubsub_subscription_pull_filter'
60+
primary_resource_id: 'example'
61+
vars:
62+
topic_name: 'example-topic'
63+
subscription_name: 'example-subscription'
5964
- name: 'pubsub_subscription_dead_letter'
6065
primary_resource_id: 'example'
6166
vars:
@@ -402,7 +407,7 @@ properties:
402407
required: false
403408
immutable: true
404409
validation:
405-
regex: '^.{0,256}$'
410+
regex: '^[\s\S]{0,256}$'
406411
- name: 'deadLetterPolicy'
407412
type: NestedObject
408413
description: |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "google_pubsub_topic" "{{$.PrimaryResourceId}}" {
2+
name = "{{index $.Vars "topic_name"}}"
3+
}
4+
5+
resource "google_pubsub_subscription" "{{$.PrimaryResourceId}}" {
6+
name = "{{index $.Vars "subscription_name"}}"
7+
topic = google_pubsub_topic.{{$.PrimaryResourceId}}.id
8+
9+
labels = {
10+
foo = "bar"
11+
}
12+
13+
filter = <<EOF
14+
attributes.foo = "foo"
15+
AND attributes.bar = "bar"
16+
EOF
17+
18+
ack_deadline_seconds = 20
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" {
2+
name = "<%= ctx[:vars]['topic_name'] %>"
3+
}
4+
5+
resource "google_pubsub_subscription" "<%= ctx[:primary_resource_id] %>" {
6+
name = "<%= ctx[:vars]['subscription_name'] %>"
7+
topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id
8+
9+
labels = {
10+
foo = "bar"
11+
}
12+
13+
filter = <<EOF
14+
attributes.foo = "foo"
15+
AND attributes.bar = "bar"
16+
EOF
17+
18+
ack_deadline_seconds = 20
19+
}

0 commit comments

Comments
 (0)