Skip to content

Commit

Permalink
Linting, update website docs
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed May 9, 2020
1 parent b643254 commit f5db644
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 49 deletions.
37 changes: 18 additions & 19 deletions azurerm/internal/services/mysql/mysql_server_resource.go
Expand Up @@ -75,22 +75,22 @@ func resourceArmMySqlServer() *schema.Resource {
},

"auto_grow_enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true, // TODO: remove in 3.0 and default to true
ConflictsWith: []string{"storage_profile", "storage_profile.0.auto_grow"},
Type: schema.TypeBool,
Optional: true,
Computed: true, // TODO: remove in 3.0 and default to true
ConflictsWith: []string{"storage_profile", "storage_profile.0.auto_grow"},
},

"backup_retention_days": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ConflictsWith: []string{"storage_profile", "storage_profile.0.backup_retention_days"},
ValidateFunc: validation.IntBetween(7, 35),
ValidateFunc: validation.IntBetween(7, 35),
},

"create_mode": {
Type: schema.TypeString,
Type: schema.TypeString,
Optional: true,
Default: string(mysql.CreateModeDefault),
ValidateFunc: validation.StringInSlice([]string{
Expand All @@ -113,10 +113,10 @@ func resourceArmMySqlServer() *schema.Resource {
},

"geo_redundant_backup_enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
ConflictsWith: []string{"storage_profile", "storage_profile.0.geo_redundant_backup"},
Type: schema.TypeBool,
Optional: true,
Computed: true,
ConflictsWith: []string{"storage_profile", "storage_profile.0.geo_redundant_backup"},
},

"infrastructure_encryption_enabled": {
Expand Down Expand Up @@ -201,9 +201,9 @@ func resourceArmMySqlServer() *schema.Resource {
},

"storage_mb": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
Type: schema.TypeInt,
Optional: true,
Computed: true,
ConflictsWith: []string{"storage_profile", "storage_profile.0.storage_mb"},
ValidateFunc: validation.All(
validation.IntBetween(5120, 4194304),
Expand Down Expand Up @@ -237,7 +237,7 @@ func resourceArmMySqlServer() *schema.Resource {
Computed: true,
ConflictsWith: []string{"backup_retention_days"},
Deprecated: "this has been moved to the top level and will be removed in version 3.0 of the provider.",
ValidateFunc: validation.IntBetween(7, 35),
ValidateFunc: validation.IntBetween(7, 35),
},
"geo_redundant_backup": {
Type: schema.TypeString,
Expand All @@ -246,7 +246,7 @@ func resourceArmMySqlServer() *schema.Resource {
ConflictsWith: []string{"geo_redundant_backup_enabled"},
Deprecated: "this has been moved to the top level boolean attribute `geo_redundant_backup_enabled` and will be removed in version 3.0 of the provider.",
DiffSuppressFunc: suppress.CaseDifference,
ValidateFunc: validation.StringInSlice([]string{
ValidateFunc: validation.StringInSlice([]string{
"Enabled",
"Disabled",
}, true),
Expand Down Expand Up @@ -426,10 +426,10 @@ func resourceArmMySqlServerCreate(d *schema.ResourceData, meta interface{}) erro
}

server := mysql.ServerForCreate{
Location: &location,
Location: &location,
Properties: props,
Sku: sku,
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
Sku: sku,
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
}

future, err := client.Create(ctx, resourceGroup, name, server)
Expand Down Expand Up @@ -651,7 +651,6 @@ func expandMySQLStorageProfile(d *schema.ResourceData) *mysql.StorageProfile {
storage.StorageMB = utils.Int32(int32(storageprofile["storage_mb"].(int)))
}


// now override whatever we may have from the block with the top level properties
if v, ok := d.GetOk("auto_grow_enabled"); ok {
storage.StorageAutogrow = mysql.StorageAutogrowDisabled
Expand Down
7 changes: 3 additions & 4 deletions azurerm/internal/services/mysql/parse/mysql_test.go
Expand Up @@ -36,10 +36,10 @@ func TestValidateMysqlServerServerID(t *testing.T) {
Expected: nil,
},
{
Name: "Valid",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DBforMySQL/servers/test-mysql",
Name: "Valid",
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DBforMySQL/servers/test-mysql",
Expected: &MysqlServerServerId{
Name: "test-mysql",
Name: "test-mysql",
ResourceGroup: "test-rg",
},
},
Expand All @@ -66,4 +66,3 @@ func TestValidateMysqlServerServerID(t *testing.T) {
}
}
}

26 changes: 13 additions & 13 deletions azurerm/internal/services/mysql/tests/mysql_server_resource_test.go
Expand Up @@ -430,7 +430,7 @@ resource "azurerm_mysql_server" "test" {
sku_name = "GP_Gen5_2"
storage_profile {
storage_mb = 51200
storage_mb = 51200
}
administrator_login = "acctestun"
Expand Down Expand Up @@ -565,18 +565,18 @@ resource "azurerm_resource_group" "test" {
}
resource "azurerm_mysql_server" "test" {
name = "acctestmysqlsvr-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku_name = "GP_Gen5_2"
administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
auto_grow_enabled = true
backup_retention_days = 7
geo_redundant_backup_enabled = false
ssl_enforcement_enabled = true
storage_mb = 51200
version = "%s"
name = "acctestmysqlsvr-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
sku_name = "GP_Gen5_2"
administrator_login = "acctestun"
administrator_login_password = "H@Sh1CoR3!"
auto_grow_enabled = true
backup_retention_days = 7
geo_redundant_backup_enabled = false
ssl_enforcement_enabled = true
storage_mb = 51200
version = "%s"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, version)
}
Expand Down
30 changes: 17 additions & 13 deletions website/docs/r/mysql_server.html.markdown
Expand Up @@ -51,31 +51,35 @@ The following arguments are supported:

* `sku_name` - (Required) Specifies the SKU Name for this MySQL Server. The name of the SKU, follows the `tier` + `family` + `cores` pattern (e.g. `B_Gen4_1`, `GP_Gen5_8`). For more information see the [product documentation](https://docs.microsoft.com/en-us/rest/api/mysql/servers/create#sku).

* `storage_profile` - (Required) A `storage_profile` block as defined below.
* `version` - (Required) Specifies the version of MySQL to use. Valid values are `5.6`, `5.7`, and `8.0`. Changing this forces a new resource to be created.

* `administrator_login` - (Required) The Administrator Login for the MySQL Server. Changing this forces a new resource to be created.
* `administrator_login` - (Optional) The Administrator Login for the MySQL Server. Required when `create_mode` is `Default`. Changing this forces a new resource to be created.

* `administrator_login_password` - (Required) The Password associated with the `administrator_login` for the MySQL Server.
* `administrator_login_password` - (Optional) The Password associated with the `administrator_login` for the MySQL Server. Required when `create_mode` is `Default`.

* `version` - (Required) Specifies the version of MySQL to use. Valid values are `5.6`, `5.7`, and `8.0`. Changing this forces a new resource to be created.
* `auto_grow_enabled` - (Optional) Enable/Disable auto-growing of the storage. Storage auto-grow prevents your server from running out of storage and becoming read-only. If storage auto grow is enabled, the storage automatically grows without impacting the workload. The default value if not explicitly specified is `true`.

* `ssl_enforcement` - (Required) Specifies if SSL should be enforced on connections. Possible values are `Enabled` and `Disabled`.
* `backup_retention_days` - (Optional) Backup retention days for the server, supported values are between `7` and `35` days.

* `public_network_access_enabled` - (Optional) Should public network access be allowed for this server? Defaults to `true`.
* `create_mode` - (Optional) The creation mode. Can be used to restore or replicate existing servers. Possible values are `Default`, `Replica`, `GeoRestore`, and `PointInTimeRestore`. Defaults to `Default`.

* `tags` - (Optional) A mapping of tags to assign to the resource.
* `creation_source_server_id` - (Optional) For creation modes other than `Default`, the source server ID to use.

---
* `geo_redundant_backup_enabled` - (Optional) Turn Geo-redundant server backups on/off. This allows you to choose between locally redundant or geo-redundant backup storage in the General Purpose and Memory Optimized tiers. When the backups are stored in geo-redundant backup storage, they are not only stored within the region in which your server is hosted, but are also replicated to a paired data center. This provides better protection and ability to restore your server in a different region in the event of a disaster. This is not supported for the Basic tier.

`storage_profile` supports the following:
* `infrastructure_encryption_enabled` - (Optional) Whether or not infrastructure is encrypted for this server. Defaults to `false`. Changing this forces a new resource to be created.

* `storage_mb` - (Required) Max storage allowed for a server. Possible values are between `5120` MB(5GB) and `1048576` MB(1TB) for the Basic SKU and between `5120` MB(5GB) and `4194304` MB(4TB) for General Purpose/Memory Optimized SKUs. For more information see the [product documentation](https://docs.microsoft.com/en-us/rest/api/mysql/servers/create#StorageProfile).
* `public_network_access_enabled` - (Optional) Whether or not public network access is allowed for this server. Defaults to `true`.

* `backup_retention_days` - (Optional) Backup retention days for the server, supported values are between `7` and `35` days.
* `restore_point_in_time` - (Optional) When `create_mode` is `PointInTimeRestore`, specifies the point in time to restore from `creation_source_server_id`.

* `ssl_enforcement_enabled` - (Required) Specifies if SSL should be enforced on connections. Possible values are `true` and `false`.

* `geo_redundant_backup` - (Optional) Enable Geo-redundant or not for server backup. Valid values for this property are `Enabled` or `Disabled`, not supported for the `basic` tier.
* `ssl_minimal_tls_version_enforced` - (Optional) The minimum TLS version to support on the sever. Possible values are `TLSEnforcementDisabled`, `TLS1_0`, `TLS1_1`, and `TLS1_2`. Defaults to `TLSEnforcementDisabled`.

* `auto_grow` - (Optional) Defines whether autogrow is enabled or disabled for the storage. Valid values are `Enabled` or `Disabled`.
* `storage_mb` - (Required) Max storage allowed for a server. Possible values are between `5120` MB(5GB) and `1048576` MB(1TB) for the Basic SKU and between `5120` MB(5GB) and `4194304` MB(4TB) for General Purpose/Memory Optimized SKUs. For more information see the [product documentation](https://docs.microsoft.com/en-us/rest/api/mysql/servers/create#StorageProfile).

* `tags` - (Optional) A mapping of tags to assign to the resource.

## Attributes Reference

Expand Down

0 comments on commit f5db644

Please sign in to comment.