Skip to content

Commit ef61341

Browse files
NA2047Dawid212
authored andcommitted
Adding Redis cluster import sources (GoogleCloudPlatform#13550)
1 parent d41853b commit ef61341

File tree

4 files changed

+428
-8
lines changed

4 files changed

+428
-8
lines changed

mmv1/products/redis/Cluster.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,44 @@ properties:
254254
description: |
255255
System assigned, unique identifier for the cluster.
256256
output: true
257+
- name: 'gcsSource'
258+
type: NestedObject
259+
description: |
260+
Backups stored in Cloud Storage buckets. The Cloud Storage buckets need to be the same region as the clusters.
261+
custom_flatten: 'templates/terraform/custom_flatten/redis_cluster_gcs_source.go.tmpl'
262+
immutable: true
263+
conflicts:
264+
- managedBackupSource
265+
properties:
266+
- name: 'uris'
267+
type: Array
268+
description: |
269+
URIs of the GCS objects to import. Example: gs://bucket1/object1, gs://bucket2/folder2/object2
270+
required: true
271+
immutable: true
272+
item_type:
273+
type: String
274+
- name: 'managedBackupSource'
275+
type: NestedObject
276+
description: "Backups that generated and managed by memorystore."
277+
custom_flatten: 'templates/terraform/custom_flatten/redis_cluster_managed_backup_source.go.tmpl'
278+
immutable: true
279+
conflicts:
280+
- gcsSource
281+
properties:
282+
- name: 'backup'
283+
type: String
284+
description: |
285+
Example: //redis.googleapis.com/projects/{project}/locations/{location}/backupCollections/{collection}/backups/{backup} A shorter version (without the prefix) of the backup name is also supported,
286+
like projects/{project}/locations/{location}/backupCollections/{collection}/backups/{backupId}. In this case, it assumes the backup is under redis.googleapis.com.
287+
required: true
288+
immutable: true
289+
- name: 'backupCollection'
290+
type: String
291+
description: |
292+
The backup collection full resource name.
293+
Example: projects/{project}/locations/{location}/backupCollections/{collection}
294+
output: true
257295
- name: 'automatedBackupConfig'
258296
type: NestedObject
259297
description: "The automated backup config for a instance."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2+
if len(d.Get("gcs_source").([]interface{})) > 0 {
3+
transformed := make(map[string]interface{})
4+
transformed["uris"] = d.Get("gcs_source.0.uris")
5+
return []interface{}{transformed}
6+
}
7+
return nil
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2+
3+
if len(d.Get("managed_backup_source").([]interface{})) > 0 {
4+
transformed := make(map[string]interface{})
5+
transformed["backup"] = d.Get("managed_backup_source.0.backup")
6+
return []interface{}{transformed}
7+
}
8+
9+
return nil
10+
}

0 commit comments

Comments
 (0)