Skip to content

Commit

Permalink
feat(GaussDBforMySQL): gaussdb mysql instance support version info (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
houpeng80 authored Oct 18, 2024
1 parent 5662565 commit 6208294
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 491 deletions.
6 changes: 6 additions & 0 deletions docs/resources/gaussdb_mysql_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ In addition to all arguments above, the following attributes are exported:

* `private_dns_name` - Indicates the private domain name.

* `upgrade_flag` - Indicates whether the version can be upgraded.

* `current_version` - Indicates the current database version.

* `current_kernel_version` - Indicates the current database kernel version.

* `created_at` - Indicates the creation time in the **yyyy-mm-ddThh:mm:ssZ** format.

* `updated_at` - Indicates the Update time in the **yyyy-mm-ddThh:mm:ssZ** format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func TestAccGaussDBInstance_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "auto_scaling.0.min_flavor"),
resource.TestCheckResourceAttrSet(resourceName, "auto_scaling.0.silence_start_at"),
resource.TestCheckResourceAttrSet(resourceName, "auto_scaling.0.min_read_only_count"),
resource.TestCheckResourceAttrSet(resourceName, "upgrade_flag"),
resource.TestCheckResourceAttrSet(resourceName, "current_version"),
resource.TestCheckResourceAttrSet(resourceName, "current_kernel_version"),
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type ctxType string
// @API GaussDBforMySQL GET /v3/{project_id}/instances/{instance_id}/configurations
// @API GaussDBforMySQL GET /v3/{project_id}/instances/{instance_id}/auto-scaling/policy
// @API GaussDBforMySQL GET /v3/{project_id}/instances/{instance_id}/backups/encryption
// @API GaussDBforMySQL GET /v3/{project_id}/instances/{instance_id}/database-version
// @API GaussDBforMySQL DELETE /v3/{project_id}/instances/{instance_id}
// @API EPS POST /v1.0/enterprise-projects/{enterprise_project_id}/resources-migrat
// @API BSS GET /v2/orders/customer-orders/details/{order_id}
Expand Down Expand Up @@ -454,6 +455,18 @@ func ResourceGaussDBInstance() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"upgrade_flag": {
Type: schema.TypeBool,
Computed: true,
},
"current_version": {
Type: schema.TypeString,
Computed: true,
},
"current_kernel_version": {
Type: schema.TypeString,
Computed: true,
},
"nodes": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -965,6 +978,8 @@ func resourceGaussDBInstanceRead(ctx context.Context, d *schema.ResourceData, me
mErr = multierror.Append(mErr, setAutoScaling(d, client, instanceID))
// set backup encryption
mErr = multierror.Append(mErr, setEncryption(d, client, instanceID))
// set version
mErr = multierror.Append(mErr, setVersion(d, client, instanceID)...)

// save tags
if resourceTags, err := tags.Get(client, "instances", d.Id()).Extract(); err == nil {
Expand Down Expand Up @@ -1169,6 +1184,19 @@ func setEncryption(d *schema.ResourceData, client *golangsdk.ServiceClient, inst
return d.Set("encryption_status", strings.ToUpper(resp.EncryptionStatus))
}

func setVersion(d *schema.ResourceData, client *golangsdk.ServiceClient, instanceId string) []error {
resp, err := instances.GetVersion(client, instanceId).Extract()
if err != nil {
log.Printf("[WARN] query instance %s version failed: %s", instanceId, err)
return nil
}
var errs []error
errs = append(errs, d.Set("upgrade_flag", resp.UpgradeFlag))
errs = append(errs, d.Set("current_version", resp.Datastore.CurrentVersion))
errs = append(errs, d.Set("current_kernel_version", resp.Datastore.CurrentKernelVersion))
return errs
}

func setGaussDBMySQLParameters(ctx context.Context, d *schema.ResourceData, client *golangsdk.ServiceClient) diag.Diagnostics {
parametersList, err := parameters.List(client, d.Id())
if err != nil {
Expand Down
215 changes: 0 additions & 215 deletions vendor/github.com/chnsz/golangsdk/openstack/cdn/v1/domains/requests.go

This file was deleted.

Loading

0 comments on commit 6208294

Please sign in to comment.