Skip to content

Commit

Permalink
Add memcached-1.6.15 to the list of allowed memcache versions (#9375) (
Browse files Browse the repository at this point in the history
…#16531)

[upstream:905133647a32023e4aab64b0336b3f265f563295]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Nov 14, 2023
1 parent 2413e08 commit d20571f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 13 deletions.
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/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
2 changes: 2 additions & 0 deletions google/services/memcache/resource_memcache_instance_test.go
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

0 comments on commit d20571f

Please sign in to comment.