Skip to content

Commit 9dc807c

Browse files
HUBS-1692 | Additional params support for provision
1 parent f8789af commit 9dc807c

File tree

2 files changed

+306
-2
lines changed

2 files changed

+306
-2
lines changed

internal/provider/resource_vdb.go

Lines changed: 291 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,100 @@ func resourceVdb() *schema.Resource {
575575
"appdata_config_params": {
576576
Type: schema.TypeString,
577577
Optional: true,
578+
Computed: true,
579+
},
580+
"make_current_account_owner": {
581+
Type: schema.TypeBool,
582+
Optional: true,
583+
},
584+
"config_params": {
585+
Type: schema.TypeString,
586+
Optional: true,
587+
Computed: true,
588+
},
589+
"additional_mount_points": {
590+
Type: schema.TypeList,
591+
Optional: true,
592+
Elem: &schema.Resource{
593+
Schema: map[string]*schema.Schema{
594+
"shared_path": {
595+
Type: schema.TypeString,
596+
Required: true,
597+
},
598+
"mount_path": {
599+
Type: schema.TypeString,
600+
Optional: true,
601+
},
602+
"environment_id": {
603+
Type: schema.TypeString,
604+
Optional: true,
605+
},
606+
},
607+
},
608+
},
609+
"vcdb_tde_key_identifier": {
610+
Type: schema.TypeString,
611+
Optional: true,
612+
},
613+
"cdb_tde_keystore_password": {
614+
Type: schema.TypeString,
615+
Optional: true,
616+
},
617+
"target_vcdb_tde_keystore_path": {
618+
Type: schema.TypeString,
619+
Optional: true,
620+
},
621+
"tde_key_identifier": {
622+
Type: schema.TypeString,
623+
Optional: true,
624+
},
625+
"tde_exported_key_file_secret": {
626+
Type: schema.TypeString,
627+
Optional: true,
628+
},
629+
"parent_tde_keystore_password": {
630+
Type: schema.TypeString,
631+
Optional: true,
632+
},
633+
"parent_tde_keystore_path": {
634+
Type: schema.TypeString,
635+
Optional: true,
636+
},
637+
"oracle_rac_custom_env_vars": {
638+
Type: schema.TypeList,
639+
Optional: true,
640+
Elem: &schema.Resource{
641+
Schema: map[string]*schema.Schema{
642+
"node_id": {
643+
Type: schema.TypeString,
644+
Required: true,
645+
},
646+
"name": {
647+
Type: schema.TypeString,
648+
Optional: true,
649+
},
650+
"value": {
651+
Type: schema.TypeString,
652+
Optional: true,
653+
},
654+
},
655+
},
656+
},
657+
"oracle_rac_custom_env_files": {
658+
Type: schema.TypeList,
659+
Optional: true,
660+
Elem: &schema.Resource{
661+
Schema: map[string]*schema.Schema{
662+
"node_id": {
663+
Type: schema.TypeString,
664+
Required: true,
665+
},
666+
"path_parameters": {
667+
Type: schema.TypeString,
668+
Optional: true,
669+
},
670+
},
671+
},
578672
},
579673
},
580674
}
@@ -609,6 +703,47 @@ func toTagArray(array interface{}) []dctapi.Tag {
609703
return items
610704
}
611705

706+
func toAdditionalMountPointsArray(array interface{}) []dctapi.AdditionalMountPoint {
707+
items := []dctapi.AdditionalMountPoint{}
708+
for _, item := range array.([]interface{}) {
709+
item_map := item.(map[string]interface{})
710+
addMntPts := dctapi.NewAdditionalMountPoint()
711+
addMntPts.SetEnvironmentId(item_map["environment_id"].(string))
712+
addMntPts.SetMountPath(item_map["mount_path"].(string))
713+
addMntPts.SetSharedPath(item_map["shared_path"].(string))
714+
715+
items = append(items, *addMntPts)
716+
}
717+
return items
718+
}
719+
720+
func toOracleRacCustomEnvVars(array interface{}) []dctapi.OracleRacCustomEnvVar {
721+
items := []dctapi.OracleRacCustomEnvVar{}
722+
for _, item := range array.([]interface{}) {
723+
item_map := item.(map[string]interface{})
724+
oracleRacCustomEnvVars := dctapi.NewOracleRacCustomEnvVar()
725+
oracleRacCustomEnvVars.SetName(item_map["name"].(string))
726+
oracleRacCustomEnvVars.SetNodeId(item_map["node_id"].(string))
727+
oracleRacCustomEnvVars.SetValue(item_map["value"].(string))
728+
729+
items = append(items, *oracleRacCustomEnvVars)
730+
}
731+
return items
732+
}
733+
734+
func toOracleRacCustomEnvFiles(array interface{}) []dctapi.OracleRacCustomEnvFile {
735+
items := []dctapi.OracleRacCustomEnvFile{}
736+
for _, item := range array.([]interface{}) {
737+
item_map := item.(map[string]interface{})
738+
oracleRacCustomEnvFiles := dctapi.NewOracleRacCustomEnvFile()
739+
oracleRacCustomEnvFiles.SetNodeId(item_map["node_id"].(string))
740+
oracleRacCustomEnvFiles.SetPathParameters(item_map["path_parameters"].(string))
741+
742+
items = append(items, *oracleRacCustomEnvFiles)
743+
}
744+
return items
745+
}
746+
612747
func helper_provision_by_snapshot(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
613748
var diags diag.Diagnostics
614749
client := meta.(*apiClient).client
@@ -785,6 +920,44 @@ func helper_provision_by_snapshot(ctx context.Context, d *schema.ResourceData, m
785920
json.Unmarshal([]byte(v.(string)), &appdata_config_params)
786921
provisionVDBBySnapshotParameters.SetAppdataConfigParams(appdata_config_params)
787922
}
923+
if v, has_v := d.GetOk("config_params"); has_v {
924+
config_params := make(map[string]interface{})
925+
json.Unmarshal([]byte(v.(string)), &config_params)
926+
provisionVDBBySnapshotParameters.SetConfigParams(config_params)
927+
}
928+
if v, has_v := d.GetOk("make_current_account_owner"); has_v {
929+
provisionVDBBySnapshotParameters.SetMakeCurrentAccountOwner(v.(bool))
930+
}
931+
if v, has_v := d.GetOk("vcdb_tde_key_identifier"); has_v {
932+
provisionVDBBySnapshotParameters.SetVcdbTdeKeyIdentifier(v.(string))
933+
}
934+
if v, has_v := d.GetOk("cdb_tde_keystore_password"); has_v {
935+
provisionVDBBySnapshotParameters.SetCdbTdeKeystorePassword(v.(string))
936+
}
937+
if v, has_v := d.GetOk("target_vcdb_tde_keystore_path"); has_v {
938+
provisionVDBBySnapshotParameters.SetTargetVcdbTdeKeystorePath(v.(string))
939+
}
940+
if v, has_v := d.GetOk("tde_key_identifier"); has_v {
941+
provisionVDBBySnapshotParameters.SetTdeKeyIdentifier(v.(string))
942+
}
943+
if v, has_v := d.GetOk("tde_exported_key_file_secret"); has_v {
944+
provisionVDBBySnapshotParameters.SetTdeExportedKeyFileSecret(v.(string))
945+
}
946+
if v, has_v := d.GetOk("parent_tde_keystore_password"); has_v {
947+
provisionVDBBySnapshotParameters.SetParentTdeKeystorePassword(v.(string))
948+
}
949+
if v, has_v := d.GetOk("parent_tde_keystore_path"); has_v {
950+
provisionVDBBySnapshotParameters.SetParentTdeKeystorePath(v.(string))
951+
}
952+
if v, has_v := d.GetOk("additional_mount_points"); has_v {
953+
provisionVDBBySnapshotParameters.SetAdditionalMountPoints(toAdditionalMountPointsArray(v))
954+
}
955+
if v, has_v := d.GetOk("oracle_rac_custom_env_files"); has_v {
956+
provisionVDBBySnapshotParameters.SetOracleRacCustomEnvFiles(toOracleRacCustomEnvFiles(v))
957+
}
958+
if v, has_v := d.GetOk("oracle_rac_custom_env_vars"); has_v {
959+
provisionVDBBySnapshotParameters.SetOracleRacCustomEnvVars(toOracleRacCustomEnvVars(v))
960+
}
788961

789962
req := client.VDBsApi.ProvisionVdbBySnapshot(ctx)
790963

@@ -992,6 +1165,44 @@ func helper_provision_by_timestamp(ctx context.Context, d *schema.ResourceData,
9921165
json.Unmarshal([]byte(v.(string)), &appdata_config_params)
9931166
provisionVDBByTimestampParameters.SetAppdataConfigParams(appdata_config_params)
9941167
}
1168+
if v, has_v := d.GetOk("config_params"); has_v {
1169+
config_params := make(map[string]interface{})
1170+
json.Unmarshal([]byte(v.(string)), &config_params)
1171+
provisionVDBByTimestampParameters.SetConfigParams(config_params)
1172+
}
1173+
if v, has_v := d.GetOk("make_current_account_owner"); has_v {
1174+
provisionVDBByTimestampParameters.SetMakeCurrentAccountOwner(v.(bool))
1175+
}
1176+
if v, has_v := d.GetOk("vcdb_tde_key_identifier"); has_v {
1177+
provisionVDBByTimestampParameters.SetVcdbTdeKeyIdentifier(v.(string))
1178+
}
1179+
if v, has_v := d.GetOk("cdb_tde_keystore_password"); has_v {
1180+
provisionVDBByTimestampParameters.SetCdbTdeKeystorePassword(v.(string))
1181+
}
1182+
if v, has_v := d.GetOk("target_vcdb_tde_keystore_path"); has_v {
1183+
provisionVDBByTimestampParameters.SetTargetVcdbTdeKeystorePath(v.(string))
1184+
}
1185+
if v, has_v := d.GetOk("tde_key_identifier"); has_v {
1186+
provisionVDBByTimestampParameters.SetTdeKeyIdentifier(v.(string))
1187+
}
1188+
if v, has_v := d.GetOk("tde_exported_key_file_secret"); has_v {
1189+
provisionVDBByTimestampParameters.SetTdeExportedKeyFileSecret(v.(string))
1190+
}
1191+
if v, has_v := d.GetOk("parent_tde_keystore_password"); has_v {
1192+
provisionVDBByTimestampParameters.SetParentTdeKeystorePassword(v.(string))
1193+
}
1194+
if v, has_v := d.GetOk("parent_tde_keystore_path"); has_v {
1195+
provisionVDBByTimestampParameters.SetParentTdeKeystorePath(v.(string))
1196+
}
1197+
if v, has_v := d.GetOk("additional_mount_points"); has_v {
1198+
provisionVDBByTimestampParameters.SetAdditionalMountPoints(toAdditionalMountPointsArray(v))
1199+
}
1200+
if v, has_v := d.GetOk("oracle_rac_custom_env_files"); has_v {
1201+
provisionVDBByTimestampParameters.SetOracleRacCustomEnvFiles(toOracleRacCustomEnvFiles(v))
1202+
}
1203+
if v, has_v := d.GetOk("oracle_rac_custom_env_vars"); has_v {
1204+
provisionVDBByTimestampParameters.SetOracleRacCustomEnvVars(toOracleRacCustomEnvVars(v))
1205+
}
9951206

9961207
req := client.VDBsApi.ProvisionVdbByTimestamp(ctx)
9971208

@@ -1184,6 +1395,44 @@ func helper_provision_by_bookmark(ctx context.Context, d *schema.ResourceData, m
11841395
json.Unmarshal([]byte(v.(string)), &appdata_config_params)
11851396
provisionVDBFromBookmarkParameters.SetAppdataConfigParams(appdata_config_params)
11861397
}
1398+
if v, has_v := d.GetOk("config_params"); has_v {
1399+
config_params := make(map[string]interface{})
1400+
json.Unmarshal([]byte(v.(string)), &config_params)
1401+
provisionVDBFromBookmarkParameters.SetConfigParams(config_params)
1402+
}
1403+
if v, has_v := d.GetOk("make_current_account_owner"); has_v {
1404+
provisionVDBFromBookmarkParameters.SetMakeCurrentAccountOwner(v.(bool))
1405+
}
1406+
if v, has_v := d.GetOk("vcdb_tde_key_identifier"); has_v {
1407+
provisionVDBFromBookmarkParameters.SetVcdbTdeKeyIdentifier(v.(string))
1408+
}
1409+
if v, has_v := d.GetOk("cdb_tde_keystore_password"); has_v {
1410+
provisionVDBFromBookmarkParameters.SetCdbTdeKeystorePassword(v.(string))
1411+
}
1412+
if v, has_v := d.GetOk("target_vcdb_tde_keystore_path"); has_v {
1413+
provisionVDBFromBookmarkParameters.SetTargetVcdbTdeKeystorePath(v.(string))
1414+
}
1415+
if v, has_v := d.GetOk("tde_key_identifier"); has_v {
1416+
provisionVDBFromBookmarkParameters.SetTdeKeyIdentifier(v.(string))
1417+
}
1418+
if v, has_v := d.GetOk("tde_exported_key_file_secret"); has_v {
1419+
provisionVDBFromBookmarkParameters.SetTdeExportedKeyFileSecret(v.(string))
1420+
}
1421+
if v, has_v := d.GetOk("parent_tde_keystore_password"); has_v {
1422+
provisionVDBFromBookmarkParameters.SetParentTdeKeystorePassword(v.(string))
1423+
}
1424+
if v, has_v := d.GetOk("parent_tde_keystore_path"); has_v {
1425+
provisionVDBFromBookmarkParameters.SetParentTdeKeystorePath(v.(string))
1426+
}
1427+
if v, has_v := d.GetOk("additional_mount_points"); has_v {
1428+
provisionVDBFromBookmarkParameters.SetAdditionalMountPoints(toAdditionalMountPointsArray(v))
1429+
}
1430+
if v, has_v := d.GetOk("oracle_rac_custom_env_files"); has_v {
1431+
provisionVDBFromBookmarkParameters.SetOracleRacCustomEnvFiles(toOracleRacCustomEnvFiles(v))
1432+
}
1433+
if v, has_v := d.GetOk("oracle_rac_custom_env_vars"); has_v {
1434+
provisionVDBFromBookmarkParameters.SetOracleRacCustomEnvVars(toOracleRacCustomEnvVars(v))
1435+
}
11871436

11881437
req := client.VDBsApi.ProvisionVdbFromBookmark(ctx)
11891438

@@ -1287,8 +1536,15 @@ func resourceVdbRead(ctx context.Context, d *schema.ResourceData, meta interface
12871536
d.Set("parent_id", result.GetParentId())
12881537
d.Set("group_name", result.GetGroupName())
12891538
d.Set("creation_date", result.GetCreationDate().String())
1290-
d.Set("appdata_source_params", result.GetAppdataSourceParams())
1291-
d.Set("appdata_config_params", result.GetAppdataConfigParams())
1539+
1540+
appdata_source_params, _ := json.Marshal(result.GetAppdataSourceParams())
1541+
d.Set("appdata_source_params", string(appdata_source_params))
1542+
appdata_config_params, _ := json.Marshal(result.GetAppdataConfigParams())
1543+
d.Set("appdata_config_params", string(appdata_config_params))
1544+
config_params, _ := json.Marshal(result.GetConfigParams())
1545+
d.Set("config_params", string(config_params))
1546+
d.Set("additional_mount_points", flattenAdditionalMountPoints(result.GetAdditionalMountPoints()))
1547+
12921548
d.Set("id", vdbId)
12931549

12941550
return diags
@@ -1396,6 +1652,39 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
13961652
if d.HasChange("cdc_on_provision") {
13971653
updateVDBParam.SetCdcOnProvision(d.Get("cdc_on_provision").(bool))
13981654
}
1655+
if d.HasChange("additional_mount_points") {
1656+
updateVDBParam.SetAdditionalMountPoints(toAdditionalMountPointsArray(d.Get("additional_mount_points")))
1657+
}
1658+
if d.HasChange("parent_tde_keystore_path") {
1659+
updateVDBParam.SetParentTdeKeystorePath(d.Get("parent_tde_keystore_path").(string))
1660+
}
1661+
if d.HasChange("parent_tde_keystore_password") {
1662+
updateVDBParam.SetParentTdeKeystorePassword(d.Get("parent_tde_keystore_password").(string))
1663+
}
1664+
if d.HasChange("tde_key_identifier") {
1665+
updateVDBParam.SetTdeKeyIdentifier(d.Get("tde_key_identifier").(string))
1666+
}
1667+
if d.HasChange("target_vcdb_tde_keystore_path") {
1668+
updateVDBParam.SetTargetVcdbTdeKeystorePath(d.Get("target_vcdb_tde_keystore_path").(string))
1669+
}
1670+
if d.HasChange("cdb_tde_keystore_password") {
1671+
updateVDBParam.SetCdbTdeKeystorePassword(d.Get("cdb_tde_keystore_password").(string))
1672+
}
1673+
if d.HasChange("appdata_source_params") {
1674+
appdata_source_params := make(map[string]interface{})
1675+
json.Unmarshal([]byte(d.Get("appdata_source_params").(string)), &appdata_source_params)
1676+
updateVDBParam.SetAppdataSourceParams(appdata_source_params)
1677+
}
1678+
if d.HasChange("appdata_config_params") {
1679+
appdata_config_params := make(map[string]interface{})
1680+
json.Unmarshal([]byte(d.Get("appdata_config_params").(string)), &appdata_config_params)
1681+
updateVDBParam.SetAppdataConfigParams(appdata_config_params)
1682+
}
1683+
if d.HasChange("config_params") {
1684+
config_params := make(map[string]interface{})
1685+
json.Unmarshal([]byte(d.Get("config_params").(string)), &config_params)
1686+
updateVDBParam.SetConfigParams(config_params)
1687+
}
13991688

14001689
res, httpRes, err := client.VDBsApi.UpdateVdbById(ctx, d.Get("id").(string)).UpdateVDBParameters(*updateVDBParam).Execute()
14011690

internal/provider/utility.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ func flattenHosts(hosts []dctapi.Host) []interface{} {
114114
return make([]interface{}, 0)
115115
}
116116

117+
func flattenAdditionalMountPoints(additional_mount_points []dctapi.AdditionalMountPoint) []interface{} {
118+
if additional_mount_points != nil {
119+
returned_additional_mount_points := make([]interface{}, len(additional_mount_points))
120+
for i, additional_mount_point := range additional_mount_points {
121+
returned_additional_mount_point := make(map[string]interface{})
122+
returned_additional_mount_point["shared_path"] = additional_mount_point.GetSharedPath()
123+
returned_additional_mount_point["mount_path"] = additional_mount_point.GetMountPath()
124+
returned_additional_mount_point["environment_id"] = additional_mount_point.GetEnvironmentId()
125+
returned_additional_mount_points[i] = returned_additional_mount_point
126+
}
127+
return returned_additional_mount_points
128+
}
129+
return make([]interface{}, 0)
130+
}
131+
117132
func apiErrorResponseHelper(res interface{}, httpRes *http.Response, err error) diag.Diagnostics {
118133
// Helper function to return Diagnostics object if there is
119134
// a failure during API call.

0 commit comments

Comments
 (0)