Skip to content

Commit

Permalink
azurerm_nginx_deployment: Deprecate managed_resource_group field
Browse files Browse the repository at this point in the history
This field was deprecated by the service provider
a long time back. This commit just deprectes the
same field in terrform in the next provider
version.
  • Loading branch information
puneetsarna committed Nov 20, 2024
1 parent a16745f commit c8b71af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
18 changes: 11 additions & 7 deletions internal/services/nginx/nginx_deployment_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/identity"
"github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxdeployment"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -56,7 +57,7 @@ func (m DeploymentDataSource) Arguments() map[string]*pluginsdk.Schema {
}

func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema {
return map[string]*pluginsdk.Schema{
dataSource := map[string]*pluginsdk.Schema{
"nginx_version": {
Type: pluginsdk.TypeString,
Computed: true,
Expand All @@ -69,11 +70,6 @@ func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
},

"managed_resource_group": {
Type: pluginsdk.TypeString,
Computed: true,
},

"location": commonschema.LocationComputed(),

"capacity": {
Expand Down Expand Up @@ -196,6 +192,15 @@ func (m DeploymentDataSource) Attributes() map[string]*pluginsdk.Schema {

"tags": commonschema.TagsDataSource(),
}

if !features.FivePointOhBeta() {
dataSource["managed_resource_group"] = &pluginsdk.Schema{
Deprecated: "The `managed_resource_group` field has been deprecated and will be removed in v5.0 of the AzureRM Provider.",
Type: pluginsdk.TypeString,
Computed: true,
}
}
return dataSource
}

func (m DeploymentDataSource) ModelObject() interface{} {
Expand Down Expand Up @@ -245,7 +250,6 @@ func (m DeploymentDataSource) Read() sdk.ResourceFunc {
output.Identity = *flattenedIdentity
if props := model.Properties; props != nil {
output.IpAddress = pointer.ToString(props.IPAddress)
output.ManagedResourceGroup = pointer.ToString(props.ManagedResourceGroup)
output.NginxVersion = pointer.ToString(props.NginxVersion)
output.DiagnoseSupportEnabled = pointer.ToBool(props.EnableDiagnosticsSupport)

Expand Down
22 changes: 12 additions & 10 deletions internal/services/nginx/nginx_deployment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/identity"
"github.com/hashicorp/go-azure-sdk/resource-manager/nginx/2024-09-01-preview/nginxdeployment"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -107,14 +108,6 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema {

"identity": commonschema.SystemAssignedUserAssignedIdentityOptional(),

"managed_resource_group": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringIsNotEmpty,
},

"location": commonschema.Location(),

"capacity": {
Expand Down Expand Up @@ -260,6 +253,17 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema {
"tags": commonschema.Tags(),
}

if !features.FivePointOhBeta() {
resource["managed_resource_group"] = &pluginsdk.Schema{
Deprecated: "The `managed_resource_group` field has been deprecated and will be removed in v5.0 of the AzureRM Provider.",
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringIsNotEmpty,
}
}

return resource
}

Expand Down Expand Up @@ -318,7 +322,6 @@ func (m DeploymentResource) Create() sdk.ResourceFunc {
}

prop := &nginxdeployment.NginxDeploymentProperties{}
prop.ManagedResourceGroup = pointer.To(model.ManagedResourceGroup)

if len(model.LoggingStorageAccount) > 0 {
prop.Logging = &nginxdeployment.NginxLogging{
Expand Down Expand Up @@ -457,7 +460,6 @@ func (m DeploymentResource) Read() sdk.ResourceFunc {

if props := model.Properties; props != nil {
output.IpAddress = pointer.ToString(props.IPAddress)
output.ManagedResourceGroup = pointer.ToString(props.ManagedResourceGroup)
output.NginxVersion = pointer.ToString(props.NginxVersion)
output.DiagnoseSupportEnabled = pointer.ToBool(props.EnableDiagnosticsSupport)

Expand Down

0 comments on commit c8b71af

Please sign in to comment.