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

Add memcached-1.6.15 to the list of allowed memcache versions #6642

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/9375.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
memcache: added `MEMCACHE_1_6_15` as a possible value for `memcache_version` in `google_memcache_instance`
```
60 changes: 48 additions & 12 deletions google-beta/services/memcache/resource_memcache_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ resolution and up to nine fractional digits.`,
"memcache_version": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: verify.ValidateEnum([]string{"MEMCACHE_1_5", ""}),
ValidateFunc: verify.ValidateEnum([]string{"MEMCACHE_1_5", "MEMCACHE_1_6_15", ""}),
Description: `The major version of Memcached software. If not provided, latest supported version will be used.
Currently the latest supported major version is MEMCACHE_1_5. The minor version will be automatically
determined by our system based on the latest supported minor version. Default value: "MEMCACHE_1_5" Possible values: ["MEMCACHE_1_5"]`,
determined by our system based on the latest supported minor version. Default value: "MEMCACHE_1_5" Possible values: ["MEMCACHE_1_5", "MEMCACHE_1_6_15"]`,
Default: "MEMCACHE_1_5",
},
"region": {
Expand Down Expand Up @@ -613,12 +613,6 @@ func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) er
} else if v, ok := d.GetOkExists("node_count"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, nodeCountProp)) {
obj["nodeCount"] = nodeCountProp
}
memcacheVersionProp, err := expandMemcacheInstanceMemcacheVersion(d.Get("memcache_version"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("memcache_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, memcacheVersionProp)) {
obj["memcacheVersion"] = memcacheVersionProp
}
maintenancePolicyProp, err := expandMemcacheInstanceMaintenancePolicy(d.Get("maintenance_policy"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -648,10 +642,6 @@ func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) er
updateMask = append(updateMask, "nodeCount")
}

if d.HasChange("memcache_version") {
updateMask = append(updateMask, "memcacheVersion")
}

if d.HasChange("maintenance_policy") {
updateMask = append(updateMask, "maintenancePolicy")
}
Expand Down Expand Up @@ -697,6 +687,52 @@ func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) er
return err
}
}
d.Partial(true)

if d.HasChange("memcache_version") {
obj := make(map[string]interface{})

memcacheVersionProp, err := expandMemcacheInstanceMemcacheVersion(d.Get("memcache_version"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("memcache_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, memcacheVersionProp)) {
obj["memcacheVersion"] = memcacheVersionProp
}

url, err := tpgresource.ReplaceVars(d, config, "{{MemcacheBasePath}}projects/{{project}}/locations/{{region}}/instances/{{name}}:upgrade")
if err != nil {
return err
}

// err == nil indicates that the billing_project value was found
if bp, err := tpgresource.GetBillingProject(d, config); err == nil {
billingProject = bp
}

res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "POST",
Project: billingProject,
RawURL: url,
UserAgent: userAgent,
Body: obj,
Timeout: d.Timeout(schema.TimeoutUpdate),
})
if err != nil {
return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err)
} else {
log.Printf("[DEBUG] Finished updating Instance %q: %#v", d.Id(), res)
}

err = MemcacheOperationWaitTime(
config, res, project, "Updating Instance", userAgent,
d.Timeout(schema.TimeoutUpdate))
if err != nil {
return err
}
}

d.Partial(false)

return resourceMemcacheInstanceRead(d, meta)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ resource "google_memcache_instance" "test" {
"max-item-size" = "8388608"
}
}

memcache_version = "MEMCACHE_1_6_15"
}

data "google_compute_network" "memcache_network" {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/memcache_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ The following arguments are supported:
Currently the latest supported major version is MEMCACHE_1_5. The minor version will be automatically
determined by our system based on the latest supported minor version.
Default value is `MEMCACHE_1_5`.
Possible values are: `MEMCACHE_1_5`.
Possible values are: `MEMCACHE_1_5`, `MEMCACHE_1_6_15`.

* `memcache_parameters` -
(Optional)
Expand Down
Loading