Skip to content

Commit 8ba9eef

Browse files
author
Uddipaan Hazarika
committed
update hook change
1 parent 2ab2c65 commit 8ba9eef

File tree

4 files changed

+52
-35
lines changed

4 files changed

+52
-35
lines changed

docs/resources/vdb.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ resource "delphix_vdb" "vdb_name_provion_by_timestamp_with_hook" {
8181
* `command` - (Required) Command to be executed.
8282
* `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`.
8383

84-
* `pre_rollback` - The commands to execute on the Target environment before rewinding the VDB. This is a map of three parameters:
84+
* `pre_self_refresh` - The commands to execute on the Target environment before rewinding the VDB. This is a map of three parameters:
8585
* `name` - Name of the hook.
8686
* `command` - (Required) Command to be executed.
8787
* `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`.
8888

89-
* `post_rollback` - The commands to execute on the Target environment after rewinding the VDB. This is a map of three parameters:
89+
* `post_self_refresh` - The commands to execute on the Target environment after rewinding the VDB. This is a map of three parameters:
9090
* `name` - Name of the hook.
9191
* `command` - (Required) Command to be executed.
9292
* `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]`.

examples/vdb/oracle/snapshot/main.tf

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,54 +76,54 @@ resource "delphix_vdb" "example" {
7676
processes = 150
7777
})
7878
pre_start {
79-
name = "string",
80-
command = "string",
81-
shell = "bash",
79+
name = "string"
80+
command = "string"
81+
shell = "bash"
8282
}
8383
pre_rollback {
84-
name = "string",
85-
command = "string",
86-
shell = "bash",
84+
name = "string"
85+
command = "string"
86+
shell = "bash"
8787
}
8888
post_start {
89-
name = "string",
90-
command = "string",
91-
shell = "bash",
89+
name = "string"
90+
command = "string"
91+
shell = "bash"
9292
}
9393
post_rollback {
94-
name = "string",
95-
command = "string",
96-
shell = "bash",
94+
name = "string"
95+
command = "string"
96+
shell = "bash"
9797
}
9898
pre_stop {
99-
name = "string",
100-
command = "string",
101-
shell = "bash",
99+
name = "string"
100+
command = "string"
101+
shell = "bash"
102102
}
103103
configure_clone {
104-
name = "string",
105-
command = "string",
106-
shell = "bash",
104+
name = "string"
105+
command = "string"
106+
shell = "bash"
107107
}
108108
post_snapshot {
109-
name = "string",
110-
command = "string",
111-
shell = "bash",
109+
name = "string"
110+
command = "string"
111+
shell = "bash"
112112
}
113113
pre_refresh {
114-
name = "string",
115-
command = "string",
116-
shell = "bash",
114+
name = "string"
115+
command = "string"
116+
shell = "bash"
117117
}
118118
post_refresh {
119119
name = "string"
120120
command = "string"
121121
shell = "bash"
122122
}
123123
post_stop {
124-
name = "string",
125-
command = "string",
126-
shell = "bash",
124+
name = "string"
125+
command = "string"
126+
shell = "bash"
127127
}
128128
pre_snapshot {
129129
name = "string"

internal/provider/commons.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var updatableVdbKeys = map[string]bool{
2525
"configure_clone": true,
2626
"pre_snapshot": true,
2727
"post_snapshot": true,
28+
"pre_rollback": true,
29+
"post_rollback": true,
2830
"pre_start": true,
2931
"post_start": true,
3032
"pre_stop": true,
@@ -35,7 +37,6 @@ var updatableVdbKeys = map[string]bool{
3537
"custom_env_vars": true,
3638
"custom_env_files": true,
3739
"appdata_source_params": true,
38-
"appdata_config_params": true,
3940
"config_params": true,
4041
"cdb_tde_keystore_password": true,
4142
"target_vcdb_tde_keystore_path": true,
@@ -61,6 +62,10 @@ var isDestructiveVdbUpdate = map[string]bool{
6162
"configure_clone": false,
6263
"pre_snapshot": false,
6364
"post_snapshot": false,
65+
"pre_rollback": false,
66+
"post_rollback": false,
67+
"pre_self_refresh": false,
68+
"post_self_refresh": false,
6469
"pre_start": false,
6570
"post_start": false,
6671
"pre_stop": false,
@@ -71,7 +76,6 @@ var isDestructiveVdbUpdate = map[string]bool{
7176
"custom_env_vars": false,
7277
"custom_env_files": false,
7378
"appdata_source_params": true,
74-
"appdata_config_params": true,
7579
"config_params": true,
7680
"cdb_tde_keystore_password": true,
7781
"target_vcdb_tde_keystore_path": true,

internal/provider/resource_vdb.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func resourceVdb() *schema.Resource {
9393
"database_name": {
9494
Type: schema.TypeString,
9595
Optional: true,
96+
Computed: true,
9697
},
9798
"cdb_id": {
9899
Type: schema.TypeString,
@@ -464,6 +465,7 @@ func resourceVdb() *schema.Resource {
464465
"instance_name": {
465466
Type: schema.TypeString,
466467
Optional: true,
468+
Computed: true,
467469
},
468470
"unique_name": {
469471
Type: schema.TypeString,
@@ -480,6 +482,7 @@ func resourceVdb() *schema.Resource {
480482
"mount_point": {
481483
Type: schema.TypeString,
482484
Optional: true,
485+
Computed: true,
483486
},
484487
"open_reset_logs": {
485488
Type: schema.TypeBool,
@@ -1643,6 +1646,12 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
16431646
if strings.Contains(k, "post_snapshot") {
16441647
k = "post_snapshot"
16451648
}
1649+
if strings.Contains(k, "pre_rollback") {
1650+
k = "pre_rollback"
1651+
}
1652+
if strings.Contains(k, "post_rollback") {
1653+
k = "post_rollback"
1654+
}
16461655
if strings.Contains(k, "pre_start") {
16471656
k = "pre_start"
16481657
}
@@ -1667,6 +1676,10 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
16671676
}
16681677
}
16691678

1679+
for _, key := range changedKeys {
1680+
tflog.Debug(ctx, "ChangedKeys>>>>>>>> "+key)
1681+
}
1682+
16701683
var updateFailure, destructiveUpdate bool = false, false
16711684
var nonUpdatableField []string
16721685

@@ -1778,17 +1791,17 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
17781791

17791792
if d.HasChange("pre_stop") {
17801793
if v, has_v := d.GetOk("pre_stop"); has_v {
1781-
nvdh.SetPostStart(toHookArray(v))
1794+
nvdh.SetPreStop(toHookArray(v))
17821795
} else {
1783-
nvdh.SetPostStart([]dctapi.Hook{})
1796+
nvdh.SetPreStop([]dctapi.Hook{})
17841797
}
17851798
}
17861799

17871800
if d.HasChange("post_stop") {
17881801
if v, has_v := d.GetOk("post_stop"); has_v {
1789-
nvdh.SetPostStart(toHookArray(v))
1802+
nvdh.SetPostStop(toHookArray(v))
17901803
} else {
1791-
nvdh.SetPostStart([]dctapi.Hook{})
1804+
nvdh.SetPostStop([]dctapi.Hook{})
17921805
}
17931806
}
17941807

0 commit comments

Comments
 (0)