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_netapp_volume - remove Computed from network_features, create_from_snapshot_resource_id and protocols_enabled #26165

Merged
merged 6 commits into from
Jun 12, 2024
29 changes: 18 additions & 11 deletions internal/services/netapp/netapp_volume_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
netAppValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand All @@ -30,7 +31,7 @@ import (
)

func resourceNetAppVolume() *pluginsdk.Resource {
return &pluginsdk.Resource{
resource := &pluginsdk.Resource{
Create: resourceNetAppVolumeCreate,
Read: resourceNetAppVolumeRead,
Update: resourceNetAppVolumeUpdate,
Expand Down Expand Up @@ -103,15 +104,14 @@ func resourceNetAppVolume() *pluginsdk.Resource {
"create_from_snapshot_resource_id": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: snapshots.ValidateSnapshotID,
},

"network_features": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
Default: string(volumes.NetworkFeaturesBasic),
ValidateFunc: validation.StringInSlice([]string{
string(volumes.NetworkFeaturesBasic),
string(volumes.NetworkFeaturesStandard),
Expand Down Expand Up @@ -194,7 +194,6 @@ func resourceNetAppVolume() *pluginsdk.Resource {
"protocols_enabled": {
Type: pluginsdk.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
MinItems: 1,
Elem: &pluginsdk.Schema{
Expand Down Expand Up @@ -357,6 +356,20 @@ func resourceNetAppVolume() *pluginsdk.Resource {
},
},
}

if !features.FourPointOhBeta() {
resource.Schema["network_features"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
string(volumes.NetworkFeaturesBasic),
string(volumes.NetworkFeaturesStandard),
}, false),
}
}

return resource
}

func resourceNetAppVolumeCreate(d *pluginsdk.ResourceData, meta interface{}) error {
Expand Down Expand Up @@ -392,13 +405,7 @@ func resourceNetAppVolumeCreate(d *pluginsdk.ResourceData, meta interface{}) err
subnetID := d.Get("subnet_id").(string)
kerberosEnabled := d.Get("kerberos_enabled").(bool)
smbContiuouslyAvailable := d.Get("smb_continuous_availability_enabled").(bool)

var networkFeatures volumes.NetworkFeatures
networkFeaturesString := d.Get("network_features").(string)
if networkFeaturesString == "" {
networkFeatures = volumes.NetworkFeaturesBasic
}
networkFeatures = volumes.NetworkFeatures(networkFeaturesString)
networkFeatures := volumes.NetworkFeatures(d.Get("network_features").(string))

smbNonBrowsable := volumes.SmbNonBrowsableDisabled
if d.Get("smb_non_browsable_enabled").(bool) {
Expand Down
Loading