Skip to content

Fix bug in Pub/Sub Subscription avroConfig which was not sending empty configurations. #12108

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
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions mmv1/products/pubsub/Subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,18 @@ properties:
- 'NOT_FOUND'
- name: 'avroConfig'
type: NestedObject
send_empty_value: true
description: |
If set, message data will be written to Cloud Storage in Avro format.
properties:
- name: 'writeMetadata'
type: Boolean
send_empty_value: true
description: |
When true, write the subscription name, messageId, publishTime, attributes, and orderingKey as additional fields in the output.
- name: 'useTopicSchema'
type: Boolean
send_empty_value: true
description: |
When true, the output Cloud Storage file will be serialized using the topic schema, if it exists.
- name: 'serviceAccountEmail'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,31 @@ func TestAccPubsubSubscriptionCloudStorage_updateAvro(t *testing.T) {
})
}

func TestAccPubsubSubscriptionCloudStorage_emptyAvroConfig(t *testing.T) {
t.Parallel()

bucket := fmt.Sprintf("tf-test-bucket-%s", acctest.RandString(t, 10))
topic := fmt.Sprintf("tf-test-topic-%s", acctest.RandString(t, 10))
subscriptionShort := fmt.Sprintf("tf-test-sub-%s", acctest.RandString(t, 10))

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckPubsubSubscriptionDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccPubsubSubscriptionCloudStorage_basic(bucket, topic, subscriptionShort, "pre-", "-suffix", "YYYY-MM-DD/hh_mm_ssZ", 1000, "300s", 1000, "", "empty-avro"),
},
{
ResourceName: "google_pubsub_subscription.foo",
ImportStateId: subscriptionShort,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccPubsubSubscriptionCloudStorage_serviceAccount(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -819,6 +844,8 @@ resource "google_storage_bucket_iam_member" "admin" {
use_topic_schema = true
}
`
} else if outputFormat == "empty-avro" {
outputFormatString = `avro_config {}`
}
return fmt.Sprintf(`
data "google_project" "project" { }
Expand Down
Loading