Skip to content

Commit 0739e0c

Browse files
author
Uddipaan Hazarika
committed
added import support
1 parent 5265ab7 commit 0739e0c

File tree

4 files changed

+101
-19
lines changed

4 files changed

+101
-19
lines changed

GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ HOSTNAME=delphix.com
33
NAMESPACE=dct
44
NAME=delphix
55
BINARY=terraform-provider-${NAME}
6-
VERSION=3.2.3
7-
OS_ARCH=darwin_amd64
6+
VERSION=3.3.0
7+
OS_ARCH=darwin_arm64
88

99
default: install
1010

docs/resources/vdb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ resource "delphix_vdb" "vdb_name" {
170170

171171
* `file_mapping_rules` - (Optional) Target VDB file mapping rules (Oracle Only). Rules must be line separated (\n or \r) and each line must have the format "pattern:replacement". Lines are applied in order.
172172

173-
* `oracle_instance_name` - (Optional) Target VDB SID name (Oracle Only).
173+
* `instance_name` - (Optional) Target VDB SID name (Oracle Only).
174174

175175
* `unique_name` - (Optional) Target VDB db_unique_name (Oracle Only).
176176

internal/provider/resource_vdb.go

Lines changed: 70 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func resourceVdb() *schema.Resource {
157157
"has_credentials": {
158158
Type: schema.TypeBool,
159159
Optional: true,
160+
Default: false,
160161
},
161162
},
162163
},
@@ -185,6 +186,7 @@ func resourceVdb() *schema.Resource {
185186
"has_credentials": {
186187
Type: schema.TypeBool,
187188
Optional: true,
189+
Default: false,
188190
},
189191
},
190192
},
@@ -213,6 +215,7 @@ func resourceVdb() *schema.Resource {
213215
"has_credentials": {
214216
Type: schema.TypeBool,
215217
Optional: true,
218+
Default: false,
216219
},
217220
},
218221
},
@@ -241,6 +244,7 @@ func resourceVdb() *schema.Resource {
241244
"has_credentials": {
242245
Type: schema.TypeBool,
243246
Optional: true,
247+
Default: false,
244248
},
245249
},
246250
},
@@ -269,6 +273,7 @@ func resourceVdb() *schema.Resource {
269273
"has_credentials": {
270274
Type: schema.TypeBool,
271275
Optional: true,
276+
Default: false,
272277
},
273278
},
274279
},
@@ -297,6 +302,7 @@ func resourceVdb() *schema.Resource {
297302
"has_credentials": {
298303
Type: schema.TypeBool,
299304
Optional: true,
305+
Default: false,
300306
},
301307
},
302308
},
@@ -325,6 +331,7 @@ func resourceVdb() *schema.Resource {
325331
"has_credentials": {
326332
Type: schema.TypeBool,
327333
Optional: true,
334+
Default: false,
328335
},
329336
},
330337
},
@@ -353,6 +360,7 @@ func resourceVdb() *schema.Resource {
353360
"has_credentials": {
354361
Type: schema.TypeBool,
355362
Optional: true,
363+
Default: false,
356364
},
357365
},
358366
},
@@ -381,6 +389,7 @@ func resourceVdb() *schema.Resource {
381389
"has_credentials": {
382390
Type: schema.TypeBool,
383391
Optional: true,
392+
Default: false,
384393
},
385394
},
386395
},
@@ -409,6 +418,7 @@ func resourceVdb() *schema.Resource {
409418
"has_credentials": {
410419
Type: schema.TypeBool,
411420
Optional: true,
421+
Default: false,
412422
},
413423
},
414424
},
@@ -437,6 +447,7 @@ func resourceVdb() *schema.Resource {
437447
"has_credentials": {
438448
Type: schema.TypeBool,
439449
Optional: true,
450+
Default: false,
440451
},
441452
},
442453
},
@@ -449,6 +460,10 @@ func resourceVdb() *schema.Resource {
449460
Type: schema.TypeString,
450461
Optional: true,
451462
},
463+
"jdbc_connection_string": {
464+
Type: schema.TypeString,
465+
Computed: true,
466+
},
452467
"auxiliary_template_id": {
453468
Type: schema.TypeString,
454469
Optional: true,
@@ -457,7 +472,7 @@ func resourceVdb() *schema.Resource {
457472
Type: schema.TypeString,
458473
Optional: true,
459474
},
460-
"oracle_instance_name": {
475+
"instance_name": {
461476
Type: schema.TypeString,
462477
Optional: true,
463478
},
@@ -521,6 +536,10 @@ func resourceVdb() *schema.Resource {
521536
Type: schema.TypeBool,
522537
Optional: true,
523538
},
539+
"masked": {
540+
Type: schema.TypeBool,
541+
Optional: true,
542+
},
524543
"listener_ids": {
525544
Type: schema.TypeList,
526545
Optional: true,
@@ -558,6 +577,14 @@ func resourceVdb() *schema.Resource {
558577
Type: schema.TypeString,
559578
Optional: true,
560579
},
580+
"parent_dsource_id": {
581+
Type: schema.TypeString,
582+
Optional: true,
583+
},
584+
"root_parent_id": {
585+
Type: schema.TypeString,
586+
Optional: true,
587+
},
561588
"tags": {
562589
Type: schema.TypeList,
563590
Optional: true,
@@ -693,6 +720,14 @@ func toHookArray(array interface{}) []dctapi.Hook {
693720
if name != "" {
694721
hook_item.SetName(item_map["name"].(string))
695722
}
723+
element_id := item_map["element_id"].(string)
724+
if element_id != "" {
725+
hook_item.SetElementId(element_id)
726+
}
727+
has_credentials := item_map["has_credentials"].(bool)
728+
if has_credentials {
729+
hook_item.SetHasCredentials(has_credentials)
730+
}
696731

697732
// defaults to "bash" as per resource schema spec
698733
hook_item.SetShell(item_map["shell"].(string))
@@ -701,17 +736,6 @@ func toHookArray(array interface{}) []dctapi.Hook {
701736
return items
702737
}
703738

704-
func toTagArray(array interface{}) []dctapi.Tag {
705-
items := []dctapi.Tag{}
706-
for _, item := range array.([]interface{}) {
707-
item_map := item.(map[string]interface{})
708-
tag_item := dctapi.NewTag(item_map["key"].(string), item_map["value"].(string))
709-
710-
items = append(items, *tag_item)
711-
}
712-
return items
713-
}
714-
715739
func toAdditionalMountPointsArray(array interface{}) []dctapi.AdditionalMountPoint {
716740
items := []dctapi.AdditionalMountPoint{}
717741
for _, item := range array.([]interface{}) {
@@ -817,7 +841,7 @@ func helper_provision_by_snapshot(ctx context.Context, d *schema.ResourceData, m
817841
if v, has_v := d.GetOk("file_mapping_rules"); has_v {
818842
provisionVDBBySnapshotParameters.SetFileMappingRules(v.(string))
819843
}
820-
if v, has_v := d.GetOk("oracle_instance_name"); has_v {
844+
if v, has_v := d.GetOk("instance_name"); has_v {
821845
provisionVDBBySnapshotParameters.SetOracleInstanceName(v.(string))
822846
}
823847
if v, has_v := d.GetOk("unique_name"); has_v {
@@ -853,6 +877,9 @@ func helper_provision_by_snapshot(ctx context.Context, d *schema.ResourceData, m
853877
if v, has_v := d.GetOkExists("cdc_on_provision"); has_v {
854878
provisionVDBBySnapshotParameters.SetCdcOnProvision(v.(bool))
855879
}
880+
if v, has_v := d.GetOkExists("masked"); has_v {
881+
provisionVDBBySnapshotParameters.SetMasked(v.(bool))
882+
}
856883
if v, has_v := d.GetOk("online_log_size"); has_v {
857884
provisionVDBBySnapshotParameters.SetOnlineLogSize(int32(v.(int)))
858885
}
@@ -1055,7 +1082,7 @@ func helper_provision_by_timestamp(ctx context.Context, d *schema.ResourceData,
10551082
if v, has_v := d.GetOk("file_mapping_rules"); has_v {
10561083
provisionVDBByTimestampParameters.SetFileMappingRules(v.(string))
10571084
}
1058-
if v, has_v := d.GetOk("oracle_instance_name"); has_v {
1085+
if v, has_v := d.GetOk("instance_name"); has_v {
10591086
provisionVDBByTimestampParameters.SetOracleInstanceName(v.(string))
10601087
}
10611088
if v, has_v := d.GetOk("unique_name"); has_v {
@@ -1091,6 +1118,9 @@ func helper_provision_by_timestamp(ctx context.Context, d *schema.ResourceData,
10911118
if v, has_v := d.GetOkExists("cdc_on_provision"); has_v {
10921119
provisionVDBByTimestampParameters.SetCdcOnProvision(v.(bool))
10931120
}
1121+
if v, has_v := d.GetOkExists("masked"); has_v {
1122+
provisionVDBByTimestampParameters.SetMasked(v.(bool))
1123+
}
10941124
if v, has_v := d.GetOk("online_log_size"); has_v {
10951125
provisionVDBByTimestampParameters.SetOnlineLogSize(int32(v.(int)))
10961126
}
@@ -1296,7 +1326,7 @@ func helper_provision_by_bookmark(ctx context.Context, d *schema.ResourceData, m
12961326
if v, has_v := d.GetOk("file_mapping_rules"); has_v {
12971327
provisionVDBFromBookmarkParameters.SetFileMappingRules(v.(string))
12981328
}
1299-
if v, has_v := d.GetOk("oracle_instance_name"); has_v {
1329+
if v, has_v := d.GetOk("instance_name"); has_v {
13001330
provisionVDBFromBookmarkParameters.SetOracleInstanceName(v.(string))
13011331
}
13021332
if v, has_v := d.GetOk("unique_name"); has_v {
@@ -1332,6 +1362,9 @@ func helper_provision_by_bookmark(ctx context.Context, d *schema.ResourceData, m
13321362
if v, has_v := d.GetOkExists("cdc_on_provision"); has_v {
13331363
provisionVDBFromBookmarkParameters.SetCdcOnProvision(v.(bool))
13341364
}
1365+
if v, has_v := d.GetOkExists("masked"); has_v {
1366+
provisionVDBFromBookmarkParameters.SetMasked(v.(bool))
1367+
}
13351368
if v, has_v := d.GetOk("online_log_size"); has_v {
13361369
provisionVDBFromBookmarkParameters.SetOnlineLogSize(int32(v.(int)))
13371370
}
@@ -1543,8 +1576,29 @@ func resourceVdbRead(ctx context.Context, d *schema.ResourceData, meta interface
15431576
d.Set("ip_address", result.GetIpAddress())
15441577
d.Set("fqdn", result.GetFqdn())
15451578
d.Set("parent_id", result.GetParentId())
1579+
d.Set("parent_dsource_id", result.GetParentDsourceId())
1580+
d.Set("root_parent_id", result.GetRootParentId())
1581+
d.Set("source_data_id", result.GetParentId())
15461582
d.Set("group_name", result.GetGroupName())
15471583
d.Set("creation_date", result.GetCreationDate().String())
1584+
d.Set("instance_name", result.GetInstanceName())
1585+
d.Set("pre_refresh", flattenHooks(result.GetHooks().PreRefresh))
1586+
d.Set("post_refresh", flattenHooks(result.GetHooks().PostRefresh))
1587+
d.Set("configure_clone", flattenHooks(result.GetHooks().ConfigureClone))
1588+
d.Set("pre_snapshot", flattenHooks(result.GetHooks().PreSnapshot))
1589+
d.Set("post_snapshot", flattenHooks(result.GetHooks().PostSnapshot))
1590+
d.Set("pre_start", flattenHooks(result.GetHooks().PreStart))
1591+
d.Set("post_start", flattenHooks(result.GetHooks().PostStart))
1592+
d.Set("pre_stop", flattenHooks(result.GetHooks().PreStop))
1593+
d.Set("post_stop", flattenHooks(result.GetHooks().PostStop))
1594+
d.Set("pre_rollback", flattenHooks(result.GetHooks().PreRollback))
1595+
d.Set("post_rollback", flattenHooks(result.GetHooks().PostRollback))
1596+
d.Set("database_name", result.GetDatabaseName())
1597+
1598+
d.Set("jdbc_connection_string", result.GetJdbcConnectionString())
1599+
d.Set("cdb_id", result.GetCdbId())
1600+
d.Set("template_id", result.GetTemplateId())
1601+
d.Set("mount_point", result.GetMountPoint())
15481602

15491603
appdata_source_params, _ := json.Marshal(result.GetAppdataSourceParams())
15501604
d.Set("appdata_source_params", string(appdata_source_params))
@@ -1663,7 +1717,7 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
16631717
// "truncate_log_on_checkpoint",
16641718
// "repository_id",
16651719
// "file_mapping_rules",
1666-
// "oracle_instance_name",
1720+
// "instance_name",
16671721
// "unique_name",
16681722
// "open_reset_logs",
16691723
// "snapshot_policy_id",

internal/provider/utility.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,23 @@ func flattenAdditionalMountPoints(additional_mount_points []dctapi.AdditionalMou
152152
return make([]interface{}, 0)
153153
}
154154

155+
func flattenHooks(hooks []dctapi.Hook) []interface{} {
156+
if hooks != nil {
157+
returnedHooks := make([]interface{}, len(hooks))
158+
for i, hook := range hooks {
159+
returnedHook := make(map[string]interface{})
160+
returnedHook["name"] = hook.GetName()
161+
returnedHook["command"] = hook.GetCommand()
162+
returnedHook["shell"] = hook.GetShell()
163+
returnedHook["element_id"] = hook.GetElementId()
164+
returnedHook["has_credentials"] = hook.GetHasCredentials()
165+
returnedHooks[i] = returnedHook
166+
}
167+
return returnedHooks
168+
}
169+
return make([]interface{}, 0)
170+
}
171+
155172
func apiErrorResponseHelper(ctx context.Context, res interface{}, httpRes *http.Response, err error) diag.Diagnostics {
156173
// Helper function to return Diagnostics object if there is
157174
// a failure during API call.
@@ -253,3 +270,14 @@ func revertChanges(d *schema.ResourceData, changedKeys []string) {
253270
d.Set(key, old)
254271
}
255272
}
273+
274+
func toTagArray(array interface{}) []dctapi.Tag {
275+
items := []dctapi.Tag{}
276+
for _, item := range array.([]interface{}) {
277+
item_map := item.(map[string]interface{})
278+
tag_item := dctapi.NewTag(item_map["key"].(string), item_map["value"].(string))
279+
280+
items = append(items, *tag_item)
281+
}
282+
return items
283+
}

0 commit comments

Comments
 (0)