Skip to content

Commit 10ff5e4

Browse files
mishridaganiharika-98
authored andcommitted
Fix bug in Pub/Sub Subscription avroConfig which was not sending empty configurations. (GoogleCloudPlatform#12108)
1 parent e3266b5 commit 10ff5e4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

mmv1/products/pubsub/Subscription.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,19 @@ properties:
235235
- 'NOT_FOUND'
236236
- name: 'avroConfig'
237237
type: NestedObject
238+
send_empty_value: true
239+
allow_empty_object: true
238240
description: |
239241
If set, message data will be written to Cloud Storage in Avro format.
240242
properties:
241243
- name: 'writeMetadata'
242244
type: Boolean
245+
send_empty_value: true
243246
description: |
244247
When true, write the subscription name, messageId, publishTime, attributes, and orderingKey as additional fields in the output.
245248
- name: 'useTopicSchema'
246249
type: Boolean
250+
send_empty_value: true
247251
description: |
248252
When true, the output Cloud Storage file will be serialized using the topic schema, if it exists.
249253
- name: 'serviceAccountEmail'

mmv1/third_party/terraform/services/pubsub/resource_pubsub_subscription_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,31 @@ func TestAccPubsubSubscriptionCloudStorage_updateAvro(t *testing.T) {
352352
})
353353
}
354354

355+
func TestAccPubsubSubscriptionCloudStorage_emptyAvroConfig(t *testing.T) {
356+
t.Parallel()
357+
358+
bucket := fmt.Sprintf("tf-test-bucket-%s", acctest.RandString(t, 10))
359+
topic := fmt.Sprintf("tf-test-topic-%s", acctest.RandString(t, 10))
360+
subscriptionShort := fmt.Sprintf("tf-test-sub-%s", acctest.RandString(t, 10))
361+
362+
acctest.VcrTest(t, resource.TestCase{
363+
PreCheck: func() { acctest.AccTestPreCheck(t) },
364+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
365+
CheckDestroy: testAccCheckPubsubSubscriptionDestroyProducer(t),
366+
Steps: []resource.TestStep{
367+
{
368+
Config: testAccPubsubSubscriptionCloudStorage_basic(bucket, topic, subscriptionShort, "pre-", "-suffix", "YYYY-MM-DD/hh_mm_ssZ", 1000, "300s", 1000, "", "empty-avro"),
369+
},
370+
{
371+
ResourceName: "google_pubsub_subscription.foo",
372+
ImportStateId: subscriptionShort,
373+
ImportState: true,
374+
ImportStateVerify: true,
375+
},
376+
},
377+
})
378+
}
379+
355380
func TestAccPubsubSubscriptionCloudStorage_serviceAccount(t *testing.T) {
356381
t.Parallel()
357382

@@ -823,6 +848,8 @@ resource "google_storage_bucket_iam_member" "admin" {
823848
use_topic_schema = true
824849
}
825850
`
851+
} else if outputFormat == "empty-avro" {
852+
outputFormatString = `avro_config {}`
826853
}
827854
return fmt.Sprintf(`
828855
data "google_project" "project" { }

0 commit comments

Comments
 (0)