Skip to content

Commit

Permalink
Eventhub property skip empty archives (#3074)
Browse files Browse the repository at this point in the history
Resolves #3057
  • Loading branch information
Lucretius authored and katbyte committed Mar 21, 2019
1 parent 2ad3404 commit b5af16d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions azurerm/resource_arm_eventhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func resourceArmEventHub() *schema.Resource {
Type: schema.TypeBool,
Required: true,
},
"skip_empty_archives": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"encoding": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -310,12 +315,14 @@ func expandEventHubCaptureDescription(d *schema.ResourceData) (*eventhub.Capture
encoding := input["encoding"].(string)
intervalInSeconds := input["interval_in_seconds"].(int)
sizeLimitInBytes := input["size_limit_in_bytes"].(int)
skipEmptyArchives := input["skip_empty_archives"].(bool)

captureDescription := eventhub.CaptureDescription{
Enabled: utils.Bool(enabled),
Encoding: eventhub.EncodingCaptureDescription(encoding),
IntervalInSeconds: utils.Int32(int32(intervalInSeconds)),
SizeLimitInBytes: utils.Int32(int32(sizeLimitInBytes)),
SkipEmptyArchives: utils.Bool(skipEmptyArchives),
}

if v, ok := input["destination"]; ok {
Expand Down Expand Up @@ -352,6 +359,10 @@ func flattenEventHubCaptureDescription(description *eventhub.CaptureDescription)
output["enabled"] = *enabled
}

if skipEmptyArchives := description.SkipEmptyArchives; skipEmptyArchives != nil {
output["skip_empty_archives"] = *skipEmptyArchives
}

output["encoding"] = string(description.Encoding)

if interval := description.IntervalInSeconds; interval != nil {
Expand Down
2 changes: 2 additions & 0 deletions azurerm/resource_arm_eventhub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ func TestAccAzureRMEventHub_captureDescription(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMEventHubExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "capture_description.0.enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "capture_description.0.skip_empty_archives", "true"),
),
},
{
Expand Down Expand Up @@ -546,6 +547,7 @@ resource "azurerm_eventhub" "test" {
encoding = "Avro"
interval_in_seconds = 60
size_limit_in_bytes = 10485760
skip_empty_archives = true
destination {
name = "EventHubArchive.AzureBlockBlob"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/eventhub.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ A `capture_description` block supports the following:

* `size_limit_in_bytes` - (Optional) Specifies the amount of data built up in your EventHub before a Capture Operation occurs. Value should be between `10485760` and `524288000` bytes. Defaults to `314572800` bytes.

* `skip_empty_archives` - (Optional) Specifies if empty files should not be emitted if no events occur during the Capture time window. Defaults to `false`.

* `destination` - (Required) A `destination` block as defined below.

A `destination` block supports the following:
Expand Down

0 comments on commit b5af16d

Please sign in to comment.