Skip to content

Commit

Permalink
Merge pull request #247 from gridscale/bug/issue-#246
Browse files Browse the repository at this point in the history
Bug/issue #246
ajfriesen authored Dec 12, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents bf359d6 + 928e6a7 commit 7cdf4a3
Showing 9 changed files with 728 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test MySQL rs
name: Test MySQL8_0 rs

on:
workflow_dispatch:
@@ -39,5 +39,5 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Run TestAccResourceGridscaleMySQL_Basic
run: make testacc TEST=./gridscale TESTARGS='-run=TestAccResourceGridscaleMySQL_Basic'
- name: Run TestAccResourceGridscaleMySQL8_0_Basic
run: make testacc TEST=./gridscale TESTARGS='-run=TestAccResourceGridscaleMySQL8_0_Basic'
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog


## 1.23.0 (Dec 12, 2023)

FEATURES:
- Add `griscale_mysql8_0` resource [PR #246](https://github.com/gridscale/terraform-provider-gridscale/issues/246)

IMPROVEMENTS:
- Add deprecation notice for `griscale_mysql` (MySQL 5.7)

## 1.22.0 (Sept 26, 2023)

FEATURES:
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -88,6 +88,45 @@ To run a specific acceptance test, use `TESTARGS`.
TEST=./gridscale \
TESTARGS='-run=TestAccResourceGridscaleLoadBalancerBasic'

# Override local terraform provider for development

Create `local-dev.tfrc` with this content and change YOUR_USERNAME:

```
provider_installation {
# Use /Users/YOUR_USERNAME/github/terraform-provider-gridscale as an overridden package directory
# for the hashicorp/null provider. This disables the version and checksum
# verifications for this provider and forces Terraform to look for the
# null provider plugin in the given directory.
dev_overrides {
"gridscale/gridscale" = "/Users/YOUR_USERNAME/github/terraform-provider-gridscale/"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
```

`export TF_CLI_CONFIG_FILE=./local-dev.tfrc`

Build the binary: `go build -o terraform-provider-gridscale`

Now you can run `terraform plan/apply` and terraform will tell you that you are using a local version of that provider:

```
> terraform apply
│ Warning: Provider development overrides are in effect
│ The following provider development overrides are set in the CLI configuration:
│ - gridscale/gridscale in /Users/YOUR_USERNAME/github/terraform-provider-gridscale
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published
│ releases.
```

## Releasing the Provider

A [GoReleaser](https://goreleaser.com/) configuration is provided that produces build artifacts matching the [layout required](https://www.terraform.io/docs/registry/providers/publishing.html#manually-preparing-a-release) to publish the provider in the Terraform Registry.
1 change: 1 addition & 0 deletions gridscale/provider.go
Original file line number Diff line number Diff line change
@@ -96,6 +96,7 @@ func Provider() *schema.Provider {
"gridscale_postgresql": resourceGridscalePostgreSQL(),
"gridscale_sqlserver": resourceGridscaleMSSQLServer(),
"gridscale_mysql": resourceGridscaleMySQL(),
"gridscale_mysql8_0": resourceGridscaleMySQL8_0(),
"gridscale_mariadb": resourceGridscaleMariaDB(),
"gridscale_memcached": resourceGridscaleMemcached(),
"gridscale_filesystem": resourceGridscaleFilesystem(),
519 changes: 519 additions & 0 deletions gridscale/resource_gridscale_mysql8_0.go

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions gridscale/resource_gridscale_mysql8_0_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package gridscale

import (
"fmt"

"github.com/gridscale/gsclient-go/v3"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

"testing"
)

func TestAccResourceGridscaleMySQL8_0_Basic(t *testing.T) {
var object gsclient.PaaSService
name := fmt.Sprintf("MySQL-%s", acctest.RandString(10))

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckResourceGridscalePaaSDestroyCheck,
Steps: []resource.TestStep{
{
Config: testAccCheckResourceGridscaleMySQL8_0Config_basic(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckResourceGridscalePaaSExists("gridscale_mysql8_0.test", &object),
resource.TestCheckResourceAttr(
"gridscale_mysql8_0.test", "name", name),
),
},
{
Config: testAccCheckResourceGridscaleMySQL8_0Config_basic_update(),
Check: resource.ComposeTestCheckFunc(
testAccCheckResourceGridscalePaaSExists("gridscale_mysql8_0.test", &object),
resource.TestCheckResourceAttr(
"gridscale_mysql8_0.test", "name", "newname"),
),
},
},
})
}

func testAccCheckResourceGridscaleMySQL8_0Config_basic(name string) string {
return fmt.Sprintf(`
resource "gridscale_mysql8_0" "test" {
name = "%s"
release = "8.0"
performance_class = "standard"
}
`, name)
}

func testAccCheckResourceGridscaleMySQL8_0Config_basic_update() string {
return fmt.Sprintf(`
resource "gridscale_mysql8_0" "test" {
name = "newname"
release = "8.0"
performance_class = "standard"
max_core_count = 20
mysql_max_connections = 2000
labels = ["test"]
}
`)
}
2 changes: 2 additions & 0 deletions website/docs/r/mysql.html.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ description: |-

# gridscale_mysql

*DEPRECATED* - We keep this for existing customers who still use MySQL 5.7. Please migrate to MySQL 8.0.

Provides a MySQL resource. This can be used to create, modify, and delete MySQL instances.

## Example
89 changes: 89 additions & 0 deletions website/docs/r/mysql8_0.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
layout: "gridscale"
page_title: "gridscale: gridscale_mysql8_0"
sidebar_current: "docs-gridscale-resource-mysql8_0"
description: |-
Manage a MySQL 8.0 service in gridscale.
---

# gridscale_mysql8_0


Provides a MySQL 8.0 resource. This can be used to create, modify, and delete MySQL 8.0 instances.

## Example

The following example shows how one might use this resource to add a MySQL 8.0 service to gridscale:

```terraform
resource "gridscale_mysql8_0" "terra-mysql-test" {
name = "my mysql"
release = "8.0"
performance_class = "insane"
max_core_count = 20
mysql_default_time_zone = "Europe/Berlin"
}
```

## Argument Reference

The following arguments are supported:

* `name` - (Required) The human-readable name of the object. It supports the full UTF-8 character set, with a maximum of 64 characters.

* `release` - (Required) The mysql release of this instance. For convenience, please use [gscloud](https://github.com/gridscale/gscloud) to get the list of available mysql service releases.

* `performance_class` - (Required) Performance class of mysql service. Available performance classes at the time of writing: `standard`, `high`, `insane`, `ultra`.

* `mysql_sql_mode` - (Optional) mysql parameter: SQL Mode. Default: "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION".

* `mysql_max_connections` - (Optional) mysql parameter: Max Connections. Default: 4000.

* `mysql_default_time_zone` - (Optional) mysql parameter: Server Timezone. Default: UTC.

* `mysql_max_allowed_packet` - (Optional) mysql parameter: Max Allowed Packet Size. Format: xM (where x is an integer, M stands for unit: k(kB), M(MB), G(GB)). Default: 64M.

* `labels` - (Optional) List of labels in the format [ "label1", "label2" ].

* `network_uuid` - (Optional) The UUID of the network that the service is attached to.

* `security_zone_uuid` - *DEPRECATED* (Optional, Forcenew) The UUID of the security zone that the service is attached to.

* `max_core_count` - (Optional) Maximum CPU core count. The mysql instance's CPU core count will be autoscaled based on the workload. The number of cores stays between 1 and `max_core_count`.

## Timeouts

Timeouts configuration options (in seconds):
More info: [terraform.io/docs/configuration/resources.html#operation-timeouts](https://www.terraform.io/docs/configuration/resources.html#operation-timeouts)

* `create` - (Default value is "15m" - 15 minutes) Used for creating a resource.
* `update` - (Default value is "15m" - 15 minutes) Used for updating a resource.
* `delete` - (Default value is "15m" - 15 minutes) Used for deleting a resource.

## Attributes

This resource exports the following attributes:

* `name` - See Argument Reference above.
* `release` - See Argument Reference above.
* `performance_class` - See Argument Reference above.
* `mysql_sql_mode` - See Argument Reference above.
* `mysql_max_connections` - See Argument Reference above.
* `mysql_default_time_zone` - See Argument Reference above.
* `mysql_max_allowed_packet` - See Argument Reference above.
* `username` - Username for PaaS service. It is used to connect to the mysql instance.
* `password` - Password for PaaS service. It is used to connect to the mysql instance.
* `listen_port` - The port numbers where this mysql service accepts connections.
* `name` - Name of a port.
* `host` - Host address.
* `listen_port` - Port number.
* `security_zone_uuid` - See Argument Reference above.
* `network_uuid` - The UUID of the network that the service is attached to or network UUID containing security zone.
* `service_template_uuid` - PaaS service template that mysql service uses.
* `service_template_category` - The template service's category used to create the service.
* `usage_in_minutes` - Number of minutes that PaaS service is in use.
* `change_time` - Time of the last change.
* `create_time` - Date time this service has been created.
* `status` - Current status of PaaS service.
* `max_core_count` - See Argument Reference above.
* `labels` - See Argument Reference above.
3 changes: 3 additions & 0 deletions website/gridscale.erb
Original file line number Diff line number Diff line change
@@ -118,6 +118,9 @@
</li>
<li<%= sidebar_current("docs-gridscale-resource-mysql") %>>
<a href="/docs/providers/gridscale/r/mysql.html">gridscale_mysql</a>
</li>
<li<%= sidebar_current("docs-gridscale-resource-mysql8_0") %>>
<a href="/docs/providers/gridscale/r/mysql8_0.html">gridscale_mysql8_0</a>
</li>
<li<%= sidebar_current("docs-gridscale-resource-filesystem") %>>
<a href="/docs/providers/gridscale/r/filesystem.html">gridscale_filesystem</a>

0 comments on commit 7cdf4a3

Please sign in to comment.