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

Resolve 4.0 TODOs Service Bus #28531

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import (
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/disasterrecoveryconfigs"
"github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2022-10-01-preview/namespaces"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
Expand All @@ -37,25 +35,6 @@ func dataSourceServiceBusNamespaceDisasterRecoveryConfig() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: namespaces.ValidateNamespaceID,
AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"},
},

// TODO Remove in 4.0
"namespace_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validate.NamespaceName,
AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"},
Deprecated: "`namespace_name` will be removed in favour of the property `namespace_id` in version 4.0 of the AzureRM Provider.",
},

// TODO Remove in 4.0
"resource_group_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: resourcegroups.ValidateName,
AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"},
Deprecated: "`resource_group_name` will be removed in favour of the property `namespace_id` in version 4.0 of the AzureRM Provider.",
},

"alias_authorization_rule_id": {
Expand Down
60 changes: 30 additions & 30 deletions internal/services/servicebus/servicebus_queue_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import (
"fmt"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/queues"
"github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2022-10-01-preview/namespaces"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand All @@ -19,7 +19,7 @@
)

func dataSourceServiceBusQueue() *pluginsdk.Resource {
return &pluginsdk.Resource{
resource := &pluginsdk.Resource{
Read: dataSourceServiceBusQueueRead,

Timeouts: &pluginsdk.ResourceTimeout{
Expand All @@ -37,25 +37,6 @@
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: namespaces.ValidateNamespaceID,
AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"},
},

// TODO Remove in 4.0
"namespace_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: azValidate.NamespaceName,
AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"},
Deprecated: "`namespace_name` will be removed in favour of the property `namespace_id` in version 4.0 of the AzureRM Provider.",
},

// TODO Remove in 4.0
"resource_group_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: resourcegroups.ValidateName,
AtLeastOneOf: []string{"namespace_id", "resource_group_name", "namespace_name"},
Deprecated: "`resource_group_name` will be removed in favour of the property `namespace_id` in version 4.0 of the AzureRM Provider.",
},

"auto_delete_on_idle": {
Expand All @@ -78,20 +59,17 @@
Computed: true,
},

// TODO 4.0: change this from enable_* to *_enabled
"enable_batched_operations": {
"batched_operations_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},

// TODO 4.0: change this from enable_* to *_enabled
"enable_express": {
"express_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},

// TODO 4.0: change this from enable_* to *_enabled
"enable_partitioning": {
"partitioning_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},
Expand Down Expand Up @@ -137,6 +115,22 @@
},
},
}

if !features.FivePointOh() {
for _, name := range []string{"batched_operations", "express", "partitioning"} {
oldName := fmt.Sprintf("enable_%s", name)
newName := fmt.Sprintf("%s_enabled", name)
resource.Schema[oldName] = &pluginsdk.Schema{

Check failure on line 123 in internal/services/servicebus/servicebus_queue_data_source.go

View workflow job for this annotation

GitHub Actions / tflint

S026: schema should not only enable Computed and configure ConflictsWith
Deprecated: fmt.Sprintf("this property has been deprecated in favour of `%s`", newName),
Type: pluginsdk.TypeBool,
Computed: true,
ConflictsWith: []string{newName},
}
resource.Schema[newName].ConflictsWith = []string{oldName}
}
}

return resource
}

func dataSourceServiceBusQueueRead(d *pluginsdk.ResourceData, meta interface{}) error {
Expand Down Expand Up @@ -177,9 +171,9 @@
d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration)
d.Set("default_message_ttl", props.DefaultMessageTimeToLive)
d.Set("duplicate_detection_history_time_window", props.DuplicateDetectionHistoryTimeWindow)
d.Set("enable_batched_operations", props.EnableBatchedOperations)
d.Set("enable_express", props.EnableExpress)
d.Set("enable_partitioning", props.EnablePartitioning)
d.Set("batched_operations_enabled", props.EnableBatchedOperations)
d.Set("express_enabled", props.EnableExpress)
d.Set("partitioning_enabled", props.EnablePartitioning)
d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo)
d.Set("forward_to", props.ForwardTo)
d.Set("lock_duration", props.LockDuration)
Expand All @@ -188,6 +182,12 @@
d.Set("requires_session", props.RequiresSession)
d.Set("status", string(pointer.From(props.Status)))

if !features.FivePointOhBeta() {
d.Set("enable_batched_operations", props.EnableBatchedOperations)
d.Set("enable_express", props.EnableExpress)
d.Set("enable_partitioning", props.EnablePartitioning)
}

if apiMaxSizeInMegabytes := props.MaxSizeInMegabytes; apiMaxSizeInMegabytes != nil {
maxSizeInMegabytes := int(*apiMaxSizeInMegabytes)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import (
"time"

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourcegroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/subscriptions"
"github.com/hashicorp/go-azure-sdk/resource-manager/servicebus/2021-06-01-preview/topics"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/servicebus/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/timeouts"
)
Expand All @@ -35,34 +33,6 @@ func dataSourceServiceBusSubscription() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: topics.ValidateTopicID,
AtLeastOneOf: []string{"topic_id", "resource_group_name", "namespace_name", "topic_name"},
},

// TODO Remove in 4.0
"namespace_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validate.NamespaceName,
AtLeastOneOf: []string{"topic_id", "resource_group_name", "namespace_name", "topic_name"},
Deprecated: "`namespace_name` will be removed in favour of the property `topic_id` in version 4.0 of the AzureRM Provider.",
},

// TODO Remove in 4.0
"resource_group_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: resourcegroups.ValidateName,
AtLeastOneOf: []string{"topic_id", "resource_group_name", "namespace_name", "topic_name"},
Deprecated: "`resource_group_name` will be removed in favour of the property `topic_id` in version 4.0 of the AzureRM Provider.",
},

// TODO Remove in 4.0
"topic_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validate.TopicName(),
AtLeastOneOf: []string{"topic_id", "resource_group_name", "namespace_name", "topic_name"},
Deprecated: "`topic_name` will be removed in favour of the property `topic_id` in version 4.0 of the AzureRM Provider.",
},

"auto_delete_on_idle": {
Expand Down Expand Up @@ -90,8 +60,7 @@ func dataSourceServiceBusSubscription() *pluginsdk.Resource {
Computed: true,
},

// TODO 4.0: change this from enable_* to *_enabled
"enable_batched_operations": {
"batched_operations_enabled": {
Type: pluginsdk.TypeBool,
Computed: true,
},
Expand Down Expand Up @@ -161,7 +130,7 @@ func dataSourceServiceBusSubscriptionRead(d *pluginsdk.ResourceData, meta interf
d.Set("lock_duration", props.LockDuration)
d.Set("dead_lettering_on_message_expiration", props.DeadLetteringOnMessageExpiration)
d.Set("dead_lettering_on_filter_evaluation_error", props.DeadLetteringOnFilterEvaluationExceptions)
d.Set("enable_batched_operations", props.EnableBatchedOperations)
d.Set("batched_operations_enabled", props.EnableBatchedOperations)
d.Set("requires_session", props.RequiresSession)
d.Set("forward_dead_lettered_messages_to", props.ForwardDeadLetteredMessagesTo)
d.Set("forward_to", props.ForwardTo)
Expand Down
Loading