Skip to content
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

Event hub namespace with KafkaEnabled property #2395

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions azurerm/data_source_eventhub_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func dataSourceEventHubNamespace() *schema.Resource {
Computed: true,
},

"kafka_enabled": {
Type: schema.TypeBool,
Computed: true,
},

"maximum_throughput_units": {
Type: schema.TypeInt,
Computed: true,
Expand Down Expand Up @@ -110,6 +115,7 @@ func dataSourceEventHubNamespaceRead(d *schema.ResourceData, meta interface{}) e

if props := resp.EHNamespaceProperties; props != nil {
d.Set("auto_inflate_enabled", props.IsAutoInflateEnabled)
d.Set("kafka_enabled", props.KafkaEnabled)
d.Set("maximum_throughput_units", int(*props.MaximumThroughputUnits))
}

Expand Down
4 changes: 3 additions & 1 deletion azurerm/data_source_eventhub_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestAccDataSourceAzureRMEventHubNamespace_complete(t *testing.T) {
resource.TestCheckResourceAttr(dataSourceName, "sku", "Standard"),
resource.TestCheckResourceAttr(dataSourceName, "capacity", "2"),
resource.TestCheckResourceAttr(dataSourceName, "auto_inflate_enabled", "true"),
resource.TestCheckResourceAttr(dataSourceName, "kafka_enabled", "true"),
resource.TestCheckResourceAttr(dataSourceName, "maximum_throughput_units", "20"),
),
},
Expand Down Expand Up @@ -83,7 +84,8 @@ resource "azurerm_eventhub_namespace" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Standard"
capacity = "2"
auto_inflate_enabled = true
auto_inflate_enabled = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like line 86 and 87 are duplicates.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A change like this usually means the line break when from \n <--> \n\r

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand. Are you saying lines 87 and 88 are not duplicates, but appear so due to github formatting? It looks to me like they are two green + lines with the same content.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my apologies, you are definitely correct. Line 88 didn't appear in the conversation view.

kafka_enabled = true
fedeoliv marked this conversation as resolved.
Show resolved Hide resolved
maximum_throughput_units = 20
}

Expand Down
9 changes: 9 additions & 0 deletions azurerm/resource_arm_eventhub_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ func resourceArmEventHubNamespace() *schema.Resource {
Default: false,
},

"kafka_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},

"maximum_throughput_units": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -115,6 +121,7 @@ func resourceArmEventHubNamespaceCreate(d *schema.ResourceData, meta interface{}
tags := d.Get("tags").(map[string]interface{})

autoInflateEnabled := d.Get("auto_inflate_enabled").(bool)
kafkaEnabled := d.Get("kafka_enabled").(bool)

parameters := eventhub.EHNamespace{
Location: &location,
Expand All @@ -125,6 +132,7 @@ func resourceArmEventHubNamespaceCreate(d *schema.ResourceData, meta interface{}
},
EHNamespaceProperties: &eventhub.EHNamespaceProperties{
IsAutoInflateEnabled: utils.Bool(autoInflateEnabled),
KafkaEnabled: utils.Bool(kafkaEnabled),
},
Tags: expandTags(tags),
}
Expand Down Expand Up @@ -197,6 +205,7 @@ func resourceArmEventHubNamespaceRead(d *schema.ResourceData, meta interface{})

if props := resp.EHNamespaceProperties; props != nil {
d.Set("auto_inflate_enabled", props.IsAutoInflateEnabled)
d.Set("kafka_enabled", props.KafkaEnabled)
d.Set("maximum_throughput_units", int(*props.MaximumThroughputUnits))
}

Expand Down
42 changes: 42 additions & 0 deletions azurerm/resource_arm_eventhub_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ func TestAccAzureRMEventHubNamespace_basic(t *testing.T) {
})
}

func TestAccAzureRMEventHubNamespace_KafkaEnabled(t *testing.T) {
resourceName := "azurerm_eventhub_namespace.test"
ri := acctest.RandInt()

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMEventHubNamespaceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMEventHubNamespace_KafkaEnabled(ri, testLocation()),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMEventHubNamespaceExists(resourceName),
),
fedeoliv marked this conversation as resolved.
Show resolved Hide resolved
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMEventHubNamespace_standard(t *testing.T) {
resourceName := "azurerm_eventhub_namespace.test"
ri := acctest.RandInt()
Expand Down Expand Up @@ -361,6 +385,24 @@ resource "azurerm_eventhub_namespace" "test" {
`, rInt, location, rInt)
}


func testAccAzureRMEventHubNamespace_KafkaEnabled(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}

resource "azurerm_eventhub_namespace" "test" {
name = "acctesteventhubnamespace-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku = "Basic"
kafka_enabled = true
fedeoliv marked this conversation as resolved.
Show resolved Hide resolved
}
`, rInt, location, rInt)
}

func testAccAzureRMEventHubNamespace_standard(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Expand Down