Skip to content

Commit

Permalink
remove wo validation (#28898)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephybun authored Feb 27, 2025
1 parent 3a567a0 commit 44cca6a
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 30 deletions.
2 changes: 2 additions & 0 deletions contributing/topics/guide-new-write-only-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ func (SomeDatabase) Update() sdk.ResourceFunc {

The `terraform-plugin-sdk@v2` provides a helpful validation for WO attributes that surfaces a warning to users if they are on a version of Terraform that supports WO attributes but are using the non-WO attribute version of a sensitive property.

> **Note:** We currently recommend not adding this validation to the resource since the only way to remove the warning diagnostic is to use to WO attribute.
```go
// update the interface that the resource should implement
var _ sdk.ResourceWithConfigValidation = SomeDatabase{}
Expand Down
6 changes: 0 additions & 6 deletions internal/services/mssql/mssql_job_credential_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/jobcredentials"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/parse"
Expand Down Expand Up @@ -41,10 +39,6 @@ func resourceMsSqlJobCredential() *pluginsdk.Resource {
Delete: pluginsdk.DefaultTimeout(60 * time.Minute),
},

ValidateRawResourceConfigFuncs: []schema.ValidateRawResourceConfigFunc{
validation.PreferWriteOnlyAttribute(cty.GetAttrPath("password"), cty.GetAttrPath("password_wo")),
},

Schema: map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Expand Down
6 changes: 0 additions & 6 deletions internal/services/mssql/mssql_server_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/sql/2023-08-01-preview/servers"
"github.com/hashicorp/go-azure-sdk/sdk/client/pollers"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
schemaValidation "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand All @@ -51,10 +49,6 @@ func resourceMsSqlServer() *pluginsdk.Resource {
return err
}),

ValidateRawResourceConfigFuncs: []schema.ValidateRawResourceConfigFunc{
schemaValidation.PreferWriteOnlyAttribute(cty.GetAttrPath("administrator_login_password"), cty.GetAttrPath("administrator_login_password_wo")),
},

Timeouts: &pluginsdk.ResourceTimeout{
Create: pluginsdk.DefaultTimeout(60 * time.Minute),
Read: pluginsdk.DefaultTimeout(5 * time.Minute),
Expand Down
6 changes: 0 additions & 6 deletions internal/services/mysql/mysql_flexible_server_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2023-12-30/servers"
"github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2024-06-01/privatezones"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
pluginSdkValidation "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
keyVaultValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/keyvault/validate"
Expand Down Expand Up @@ -59,10 +57,6 @@ func resourceMysqlFlexibleServer() *pluginsdk.Resource {
return err
}),

ValidateRawResourceConfigFuncs: []schema.ValidateRawResourceConfigFunc{
pluginSdkValidation.PreferWriteOnlyAttribute(cty.GetAttrPath("administrator_password"), cty.GetAttrPath("administrator_password_wo")),
},

Schema: map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2023-06-01-preview/servers"
"github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2024-06-01/privatezones"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
pluginSdkValidation "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -62,10 +60,6 @@ func resourcePostgresqlFlexibleServer() *pluginsdk.Resource {
return err
}),

ValidateRawResourceConfigFuncs: []schema.ValidateRawResourceConfigFunc{
pluginSdkValidation.PreferWriteOnlyAttribute(cty.GetAttrPath("administrator_password"), cty.GetAttrPath("administrator_password_wo")),
},

Schema: map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Expand Down
6 changes: 0 additions & 6 deletions internal/services/postgres/postgresql_server_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2017-12-01/servers"
"github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2017-12-01/serversecurityalertpolicies"
"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
pluginSdkValidation "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
Expand Down Expand Up @@ -117,10 +115,6 @@ func resourcePostgreSQLServer() *pluginsdk.Resource {
0: migration.PostgresqlServerV0ToV1{},
}),

ValidateRawResourceConfigFuncs: []schema.ValidateRawResourceConfigFunc{
pluginSdkValidation.PreferWriteOnlyAttribute(cty.GetAttrPath("administrator_login_password"), cty.GetAttrPath("administrator_login_password_wo")),
},

Schema: map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Expand Down

0 comments on commit 44cca6a

Please sign in to comment.