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

New Resource: resource_arm_servicebus_subscription_rule #1124

Merged
merged 10 commits into from
Apr 20, 2018

Conversation

jpovey
Copy link
Contributor

@jpovey jpovey commented Apr 15, 2018

Add AzureRM Servicebus rule module, tests and documentation. Applies to feature request #145

@tombuildsstuff tombuildsstuff changed the title Add AzureRM Servicebus rule module New Resource: azurerm_servicebus_rule Apr 16, 2018
@tombuildsstuff tombuildsstuff added this to the Soon milestone Apr 16, 2018
@tombuildsstuff tombuildsstuff self-assigned this Apr 16, 2018
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @jpovey

Thanks for this PR - I've taken a look through and left some comments in-line, but this is off to a good start. If we can clean up the comments then we should be good to run the tests :)

Thanks!

}

if properties.CorrelationFilter != nil {
if err := d.Set("correlation_filter", flattenAzureRmServiceBusCorrelationFilter(properties.CorrelationFilter)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we update this to always set the correlation_filter field - but only to return items if properties.CorrelationFilter isn't nil? e.g.

if err := d.Set("correlation_filter", flattenAzureRmServiceBusCorrelationFilter(properties.CorrelationFilter)); err != nil {
  return fmt.Errorf("...")
}

func flattenAzureRmServiceBusCorrelationFilter(input *servicebus.CorrelationFilter) []interface{} {
  if input == nil {
    return []interface{}{}
  }

  output := make(map[string]interface{}, 0)
  // assignment
  return []interface{}{output}
}


"correlation_filter": {
Type: schema.TypeList,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

from what I can see from the schema below, there can only be one of these, can we add MaxItems: 1 to this?

Copy link
Contributor

Choose a reason for hiding this comment

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

we can also add ConflictsWith: []string{"sql_filter"} here which should handle only one of them being specified

}

rule := servicebus.Rule{
Ruleproperties: &ruleProperties,
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: we can actually just inline these two objects e.g.

rule := servicebus.Rule{
  Ruleproperties: &servicebus.Ruleproperties{
    FilterType:        servicebus.FilterType(filterType),
    // ..
  },
}

@@ -190,6 +190,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_servicebus_namespace": resourceArmServiceBusNamespace(),
"azurerm_servicebus_queue": resourceArmServiceBusQueue(),
"azurerm_servicebus_subscription": resourceArmServiceBusSubscription(),
"azurerm_servicebus_rule": resourceArmServiceBusRule(),
Copy link
Contributor

Choose a reason for hiding this comment

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

from what I can tell, these are known as ServiceBus Subscription Rules - as such would it make sense for this to be azurerm_servicebus_subscription_rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Tom

I did consider this but in both the Service Bus documentation and in the go SDK they are known simply as 'rules' and i wanted to keep consistency with this terraform module.

https://docs.microsoft.com/en-us/rest/api/servicebus/rules/createorupdate

https://github.com/Azure/azure-sdk-for-go/blob/56332fec5b308fbb6615fa1af6117394cdba186d/services/servicebus/mgmt/2017-04-01/servicebus/rules.go

Copy link
Contributor

Choose a reason for hiding this comment

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

so the Documentation and Go SDK are actually both generated from the same Swagger file - so the Azure Portal tends to be a more reliable source of truth. Given we've already got support for ServiceBus Topic Authorization Rules, I think this would be best as Subscription Rule (given it's scoped to that level) in-case a Namespace-wide rule is added in the future - WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, sounds good to me. Will get this sorted and updated soon

DiffSuppressFunc: ignoreCaseDiffSuppressFunc,
},

"location": deprecatedLocationSchema(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove this, since it's not being used?

topic_name = "${azurerm_servicebus_topic.test.name}"
subscription_name = "${azurerm_servicebus_subscription.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
%s
Copy link
Contributor

Choose a reason for hiding this comment

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

can we duplicate this into each test and make the spacing consistent here?

Copy link
Contributor Author

@jpovey jpovey Apr 17, 2018

Choose a reason for hiding this comment

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

Is there any reason to duplicate the topic, subscription and resource group as these will be the same for each test?

Copy link
Contributor

Choose a reason for hiding this comment

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

we tend to point people towards the test cases as examples of how to use features when people ask for end-to-end examples; the main goal here is to make them - so the aim here is to make them as readable as possible; I think it's fine to duplicate the topic, subscription and resource group - but can we add the entire resource definition for the azurerm_servicebus_subscription_rule into each test? e.g.

resource "azurerm_servicebus_subscription_rule" "test" {
  # ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok sure, i get what you mean

Create a ServiceBus Rule.
---

# azurerm\_servicebus\_rule
Copy link
Contributor

Choose a reason for hiding this comment

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

minor we can remove the backslashes here


* `sql_filter` - (Optional) Represents a filter written in SQL language-based syntax that to be evaluated against a BrokeredMessage. Must be set when `filter_type` is set to `SqlFilter`.

* `correlation_filter` - (Optional) A `correlation_filter` block as documented below to be evaluated against a BrokeredMessage. Must be set when `filter_type` is set to `CorrelationFilter`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change Must be set -> Required for consistency purposes?


* `filter_type` - (Required) Type of filter to be applied to a BrokeredMessage. Possible values are `SqlFilter` and `CorrelationFilter`.

* `sql_filter` - (Optional) Represents a filter written in SQL language-based syntax that to be evaluated against a BrokeredMessage. Must be set when `filter_type` is set to `SqlFilter`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change Must be set -> Required for consistency purposes?

correlationFilter.ContentType = &contentType
}

return &correlationFilter
Copy link
Contributor

Choose a reason for hiding this comment

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

based on this comment: https://github.com/terraform-providers/terraform-provider-azurerm/pull/1124/files#diff-5ae250cddcb7acd8b53f87d1465954bfR168 - is it worth raising an error if no properties have been set?

@jpovey
Copy link
Contributor Author

jpovey commented Apr 17, 2018

Morning Tom,
Thanks for the feedback, I have made the suggested minor fixes above and will look to change the rest over the next few days
Cheers

Jon

@jpovey
Copy link
Contributor Author

jpovey commented Apr 19, 2018

Hi @tombuildsstuff

I have updated the pull request with all the changes above apart from changing the modules name to azurerm_servicebus_subscription_rule as per my comment above

Let me know what you think

Cheers
Jon

@jpovey
Copy link
Contributor Author

jpovey commented Apr 20, 2018

Hi @tombuildsstuff

All changes have been made including change the name of the module to resource_arm_servicebus_subscription_rule and pushed up to the pull request

Let me know if there is anything else which needs to be done and i will try and get on it over the weekend

cheers
Jon

@tombuildsstuff
Copy link
Contributor

Acceptance Tests pass:

screen shot 2018-04-20 at 17 50 59

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @jpovey

Thanks for pushing those updates - I've taken a look through and whilst this needs some minor refactoring to make it consistent with the other resources (which I'll open a PR for) - this otherwise LGTM 👍

Thanks!

@tombuildsstuff tombuildsstuff merged commit 014cd6c into hashicorp:master Apr 20, 2018
tombuildsstuff added a commit that referenced this pull request Apr 20, 2018
@jpovey
Copy link
Contributor Author

jpovey commented Apr 20, 2018

Awesome, that's great news.

Thanks for the quick review process.

@tombuildsstuff tombuildsstuff changed the title New Resource: azurerm_servicebus_rule New Resource: resource_arm_servicebus_subscription_rule Apr 25, 2018
@tombuildsstuff tombuildsstuff changed the title New Resource: resource_arm_servicebus_subscription_rule New Resource: resource_arm_servicebus_subscription_rule Apr 25, 2018
@katbyte katbyte modified the milestones: Soon, 1.4.0 May 9, 2018
@vantheshark
Copy link

I could not find this in the terraform doc for azure. Could you please update the doc too?

@katbyte
Copy link
Collaborator

katbyte commented Feb 21, 2019

Are these the docs you're looking for @vanthoainguyen ?

@vantheshark
Copy link

These are, thanks 🤦‍♂️

@ghost
Copy link

ghost commented Mar 5, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants