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 6, 2024
1 parent 9eea95b commit 3870172
Show file tree
Hide file tree
Showing 2 changed files with 22 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
21 changes: 11 additions & 10 deletions internal/services/nginx/nginx_deployment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,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 @@ -336,6 +328,17 @@ func (m DeploymentResource) Arguments() map[string]*pluginsdk.Schema {
}
}

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 @@ -394,7 +397,6 @@ func (m DeploymentResource) Create() sdk.ResourceFunc {
}

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

if len(model.LoggingStorageAccount) > 0 {
prop.Logging = &nginxdeployment.NginxLogging{
Expand Down Expand Up @@ -557,7 +559,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 3870172

Please sign in to comment.