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

azurerm_servicebus_topic - added a status field to allow disabling the topic #150

Merged
merged 6 commits into from
Jul 5, 2017

Conversation

tombuildsstuff
Copy link
Contributor

Allows Service Bus Topic's to be set to a Disabled state.

Fixes #146

Tests pass:

$ TF_ACC=1 envchain azurerm go test ./azurerm -v -timeout 120m -run TestAccAzureRMServiceBusTopic
=== RUN   TestAccAzureRMServiceBusTopic_importBasic
--- PASS: TestAccAzureRMServiceBusTopic_importBasic (206.31s)
=== RUN   TestAccAzureRMServiceBusTopic_importBasicDisabled
--- PASS: TestAccAzureRMServiceBusTopic_importBasicDisabled (207.14s)
=== RUN   TestAccAzureRMServiceBusTopic_basic
--- PASS: TestAccAzureRMServiceBusTopic_basic (202.54s)
=== RUN   TestAccAzureRMServiceBusTopic_basicDisabled
--- PASS: TestAccAzureRMServiceBusTopic_basicDisabled (207.77s)
=== RUN   TestAccAzureRMServiceBusTopic_basicDisableEnable
--- PASS: TestAccAzureRMServiceBusTopic_basicDisableEnable (251.32s)
=== RUN   TestAccAzureRMServiceBusTopic_update
--- PASS: TestAccAzureRMServiceBusTopic_update (219.43s)
=== RUN   TestAccAzureRMServiceBusTopic_enablePartitioningStandard
--- PASS: TestAccAzureRMServiceBusTopic_enablePartitioningStandard (233.38s)
=== RUN   TestAccAzureRMServiceBusTopic_enablePartitioningPremium
--- PASS: TestAccAzureRMServiceBusTopic_enablePartitioningPremium (527.34s)
=== RUN   TestAccAzureRMServiceBusTopic_enableDuplicateDetection
--- PASS: TestAccAzureRMServiceBusTopic_enableDuplicateDetection (250.84s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	2306.085s

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

This looks overall good. I left you some comments there out of which 1 is probably more significant than others - pointer helper functions. Let me know what you think.

EnablePartitioning: &enablePartitioning,
MaxSizeInMegabytes: &maxSize,
RequiresDuplicateDetection: &requiresDuplicateDetection,
SupportOrdering: &supportOrdering,
Copy link
Member

Choose a reason for hiding this comment

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

I think we'd benefit from having a provider-wide helper for creating these pointers here. AWS has its own in the SDK (aws.String(), aws.Bool() etc.) and I built similar ones in K8S: https://github.com/terraform-providers/terraform-provider-kubernetes/blob/master/kubernetes/structures.go#L124-L142

It may look like a nitpick, but you can effectively reduce the number of lines to half here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 good shout - there's a ton built into Riviera - I'll switch this out

@@ -186,6 +200,7 @@ func resourceArmServiceBusTopicRead(d *schema.ResourceData, meta interface{}) er
d.Set("location", azureRMNormalizeLocation(*resp.Location))

props := resp.TopicProperties
d.Set("status", string(props.Status))
Copy link
Member

Choose a reason for hiding this comment

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

I'd think the Set will take care of the casting, but maybe I'm wrong... 🤷‍♂️

{
Config: enabledConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceBusTopicExists(resourceName),
Copy link
Member

Choose a reason for hiding this comment

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

Good thorough testing here, nice 👍

string(servicebus.Basic),
string(servicebus.Standard),
string(servicebus.Premium),
}, true),
Copy link
Member

Choose a reason for hiding this comment

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

Good job with simplification 👍

@@ -134,7 +139,7 @@ func resourceArmServiceBusNamespaceRead(d *schema.ResourceData, meta interface{}

resp, err := namespaceClient.Get(resGroup, name)
if err != nil {
return fmt.Errorf("Error making Read request on Azure ServiceBus Namespace %s: %+v", name, err)
return fmt.Errorf("Error making Read request on Azure ServiceBus Namespace '%s': %+v", name, err)
Copy link
Member

Choose a reason for hiding this comment

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

%q would add double quotes around the string for you + escaped it properly here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TIL, thanks!

@tombuildsstuff
Copy link
Contributor Author

Tests pass:

$ TF_ACC=1 envchain azurerm go test ./azurerm -v -timeout 120m -run TestAccAzureRMServiceBusTopic
=== RUN   TestAccAzureRMServiceBusTopic_importBasic
--- PASS: TestAccAzureRMServiceBusTopic_importBasic (225.37s)
=== RUN   TestAccAzureRMServiceBusTopic_importBasicDisabled
--- PASS: TestAccAzureRMServiceBusTopic_importBasicDisabled (224.31s)
=== RUN   TestAccAzureRMServiceBusTopic_basic
--- PASS: TestAccAzureRMServiceBusTopic_basic (220.86s)
=== RUN   TestAccAzureRMServiceBusTopic_basicDisabled
--- PASS: TestAccAzureRMServiceBusTopic_basicDisabled (226.15s)
=== RUN   TestAccAzureRMServiceBusTopic_basicDisableEnable
--- PASS: TestAccAzureRMServiceBusTopic_basicDisableEnable (252.59s)
=== RUN   TestAccAzureRMServiceBusTopic_update
--- PASS: TestAccAzureRMServiceBusTopic_update (239.40s)
=== RUN   TestAccAzureRMServiceBusTopic_enablePartitioningStandard
--- PASS: TestAccAzureRMServiceBusTopic_enablePartitioningStandard (219.67s)
=== RUN   TestAccAzureRMServiceBusTopic_enablePartitioningPremium
--- PASS: TestAccAzureRMServiceBusTopic_enablePartitioningPremium (524.82s)
=== RUN   TestAccAzureRMServiceBusTopic_enableDuplicateDetection
--- PASS: TestAccAzureRMServiceBusTopic_enableDuplicateDetection (241.51s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	2374.706s

@tombuildsstuff tombuildsstuff merged commit 894e0d0 into master Jul 5, 2017
@tombuildsstuff tombuildsstuff deleted the servicebus-disabled branch July 5, 2017 09:29
tombuildsstuff added a commit that referenced this pull request Jul 5, 2017
@ghost
Copy link

ghost commented Apr 1, 2020

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 Apr 1, 2020
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.

Feature Request: Allow Service Bus Topic Subscriptions to be created in a "disabled" state
2 participants