Skip to content

Commit

Permalink
Adding deployment_type to GA (#12634) (#20785)
Browse files Browse the repository at this point in the history
[upstream:a8d9f29193635e7a78bece5533f471ea6fa35c05]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Dec 26, 2024
1 parent 6241595 commit 7afaf21
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/12634.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
parallelstore: added `deployment_type` to `google_parallelstore_instance` (GA promotion)
```
36 changes: 36 additions & 0 deletions google/services/parallelstore/resource_parallelstore_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ func ResourceParallelstoreInstance() *schema.Resource {
ForceNew: true,
Description: `Part of 'parent'. See documentation of 'projectsId'.`,
},
"deployment_type": {
Type: schema.TypeString,
Optional: true,
Description: `Parallelstore Instance deployment type.
Possible values:
DEPLOYMENT_TYPE_UNSPECIFIED
SCRATCH
PERSISTENT`,
},
"description": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -271,6 +280,12 @@ func resourceParallelstoreInstanceCreate(d *schema.ResourceData, meta interface{
} else if v, ok := d.GetOkExists("directory_stripe_level"); !tpgresource.IsEmptyValue(reflect.ValueOf(directoryStripeLevelProp)) && (ok || !reflect.DeepEqual(v, directoryStripeLevelProp)) {
obj["directoryStripeLevel"] = directoryStripeLevelProp
}
deploymentTypeProp, err := expandParallelstoreInstanceDeploymentType(d.Get("deployment_type"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("deployment_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(deploymentTypeProp)) && (ok || !reflect.DeepEqual(v, deploymentTypeProp)) {
obj["deploymentType"] = deploymentTypeProp
}
labelsProp, err := expandParallelstoreInstanceEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -432,6 +447,9 @@ func resourceParallelstoreInstanceRead(d *schema.ResourceData, meta interface{})
if err := d.Set("directory_stripe_level", flattenParallelstoreInstanceDirectoryStripeLevel(res["directoryStripeLevel"], d, config)); err != nil {
return fmt.Errorf("Error reading Instance: %s", err)
}
if err := d.Set("deployment_type", flattenParallelstoreInstanceDeploymentType(res["deploymentType"], d, config)); err != nil {
return fmt.Errorf("Error reading Instance: %s", err)
}
if err := d.Set("terraform_labels", flattenParallelstoreInstanceTerraformLabels(res["labels"], d, config)); err != nil {
return fmt.Errorf("Error reading Instance: %s", err)
}
Expand Down Expand Up @@ -476,6 +494,12 @@ func resourceParallelstoreInstanceUpdate(d *schema.ResourceData, meta interface{
} else if v, ok := d.GetOkExists("directory_stripe_level"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, directoryStripeLevelProp)) {
obj["directoryStripeLevel"] = directoryStripeLevelProp
}
deploymentTypeProp, err := expandParallelstoreInstanceDeploymentType(d.Get("deployment_type"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("deployment_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, deploymentTypeProp)) {
obj["deploymentType"] = deploymentTypeProp
}
labelsProp, err := expandParallelstoreInstanceEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -504,6 +528,10 @@ func resourceParallelstoreInstanceUpdate(d *schema.ResourceData, meta interface{
updateMask = append(updateMask, "directoryStripeLevel")
}

if d.HasChange("deployment_type") {
updateMask = append(updateMask, "deploymentType")
}

if d.HasChange("effective_labels") {
updateMask = append(updateMask, "labels")
}
Expand Down Expand Up @@ -693,6 +721,10 @@ func flattenParallelstoreInstanceDirectoryStripeLevel(v interface{}, d *schema.R
return v
}

func flattenParallelstoreInstanceDeploymentType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenParallelstoreInstanceTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
if v == nil {
return v
Expand Down Expand Up @@ -736,6 +768,10 @@ func expandParallelstoreInstanceDirectoryStripeLevel(v interface{}, d tpgresourc
return v, nil
}

func expandParallelstoreInstanceDeploymentType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandParallelstoreInstanceEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ resource "google_parallelstore_instance" "instance" {
network = google_compute_network.network.name
file_stripe_level = "FILE_STRIPE_LEVEL_MIN"
directory_stripe_level = "DIRECTORY_STRIPE_LEVEL_MIN"
deployment_type = "SCRATCH"
labels = {
test = "value"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ resource "google_parallelstore_instance" "instance" {
capacity_gib = 12000
network = google_compute_network.network.name
reserved_ip_range = google_compute_global_address.private_ip_alloc.name
deployment_type = "SCRATCH"
file_stripe_level = "FILE_STRIPE_LEVEL_MIN"
directory_stripe_level = "DIRECTORY_STRIPE_LEVEL_MIN"
labels = {
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/parallelstore_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ resource "google_parallelstore_instance" "instance" {
network = google_compute_network.network.name
file_stripe_level = "FILE_STRIPE_LEVEL_MIN"
directory_stripe_level = "DIRECTORY_STRIPE_LEVEL_MIN"
deployment_type = "SCRATCH"
labels = {
test = "value"
}
Expand Down Expand Up @@ -208,7 +209,7 @@ The following arguments are supported:
DIRECTORY_STRIPE_LEVEL_MAX

* `deployment_type` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
(Optional)
Parallelstore Instance deployment type.
Possible values:
DEPLOYMENT_TYPE_UNSPECIFIED
Expand Down

0 comments on commit 7afaf21

Please sign in to comment.