Skip to content

Commit b03bd17

Browse files
Merge pull request #104 from delphix-integrations/develop
ECO-11035 | Main <- Develop | merge to main
2 parents 078a388 + eea289a commit b03bd17

File tree

9 files changed

+270
-308
lines changed

9 files changed

+270
-308
lines changed

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Visit https://goreleaser.com for documentation on how to customize this
22
# behavior.
33
env:
4-
- PROVIDER_VERSION=3.3.0
4+
- PROVIDER_VERSION=3.3.1
55
before:
66
hooks:
77
# this is just an example and not a requirement for provider building/publishing

docs/resources/database_postgresql.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ resource "delphix_database_postgresql" "source" {
6767
* `key` - Key of the tag
6868
* `value` - Value of the tag
6969

70-
## Import (Beta)
70+
## Import
7171

7272
Use the [`import` block](https://developer.hashicorp.com/terraform/language/import) to add source configs created directly in Data Control Tower into a Terraform state file.
7373

@@ -79,5 +79,3 @@ import {
7979
}
8080
```
8181

82-
*This is a beta feature. Delphix offers no guarantees of support or compatibility.*
83-

docs/resources/vdb.md

Lines changed: 242 additions & 276 deletions
Large diffs are not rendered by default.

internal/provider/commons.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ var updatableVdbKeys = map[string]bool{
5151
"new_dbid": true,
5252
"mount_point": true,
5353
"tags": true,
54+
"database_name": true,
5455
}
5556

5657
var isDestructiveVdbUpdate = map[string]bool{

internal/provider/resource_appdata_dsource_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func TestDsource_create_positive(t *testing.T) {
1717
name := os.Getenv("DSOURCE_NAME")
1818
environmentUser := os.Getenv("DSOURCE_ENV_USER")
1919
stagingEnvironment := os.Getenv("DSOURCE_STAGE_ENV")
20-
postgresPort := os.Getenv("DSOURCE_POSTGRES_PORT")
20+
parameters := os.Getenv("DSOURCE_PARAMETERS")
2121

2222
resource.Test(t, resource.TestCase{
2323
PreCheck: func() {
24-
testDsourcePreCheck(t, sourceId, groupId, name, environmentUser, stagingEnvironment, postgresPort)
24+
testDsourcePreCheck(t, sourceId, groupId, name, environmentUser, stagingEnvironment, parameters)
2525
},
2626
Providers: testAccProviders,
2727
CheckDestroy: testDsourceDestroy,
@@ -31,13 +31,13 @@ func TestDsource_create_positive(t *testing.T) {
3131
ExpectError: regexp.MustCompile(`.*`),
3232
},
3333
{
34-
Config: testDsourceBasic(sourceId, groupId, name, environmentUser, stagingEnvironment, postgresPort),
34+
Config: testDsourceBasic(sourceId, groupId, name, environmentUser, stagingEnvironment, parameters),
3535
Check: resource.ComposeTestCheckFunc(
3636
testDsourceExists("delphix_appdata_dsource.new_data_dsource", sourceId),
3737
resource.TestCheckResourceAttr("delphix_appdata_dsource.new_data_dsource", "source_id", sourceId)),
3838
},
3939
{
40-
Config: testDsourceUpdate(sourceId, groupId, "update_same_dsource", environmentUser, stagingEnvironment, postgresPort),
40+
Config: testDsourceUpdate(sourceId, groupId, "update_same_dsource", environmentUser, stagingEnvironment, parameters),
4141
Check: resource.ComposeAggregateTestCheckFunc(
4242
// irrelevant
4343
),
@@ -47,7 +47,7 @@ func TestDsource_create_positive(t *testing.T) {
4747
})
4848
}
4949

50-
func testDsourcePreCheck(t *testing.T, sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, postgresPort string) {
50+
func testDsourcePreCheck(t *testing.T, sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, parameters string) {
5151
testAccPreCheck(t)
5252
if sourceId == "" {
5353
t.Fatal("DSOURCE_SOURCE_ID must be set for env acceptance tests")
@@ -64,12 +64,12 @@ func testDsourcePreCheck(t *testing.T, sourceId string, groupId string, name str
6464
if stagingEnvironment == "" {
6565
t.Fatal("DSOURCE_STAGE_ENV must be set for env acceptance tests")
6666
}
67-
if postgresPort == "" {
68-
t.Fatal("DSOURCE_POSTGRES_PORT must be set for env acceptance tests")
67+
if parameters == "" {
68+
t.Fatal("DSOURCE_PARAMETERS must be set for env acceptance tests")
6969
}
7070
}
7171

72-
func testDsourceBasic(sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, postgresPort string) string {
72+
func testDsourceBasic(sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, parameters string) string {
7373
return fmt.Sprintf(`
7474
resource "delphix_appdata_dsource" "new_data_dsource" {
7575
source_value = "%s"
@@ -86,10 +86,10 @@ resource "delphix_appdata_dsource" "new_data_dsource" {
8686
resync = true
8787
})
8888
}
89-
`, sourceId, groupId, name, environmentUser, stagingEnvironment, postgresPort)
89+
`, sourceId, groupId, name, environmentUser, stagingEnvironment, parameters)
9090
}
9191

92-
func testDsourceUpdate(sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, postgresPort string) string {
92+
func testDsourceUpdate(sourceId string, groupId string, name string, environmentUser string, stagingEnvironment string, parameters string) string {
9393
return fmt.Sprintf(`
9494
resource "delphix_appdata_dsource" "new_data_dsource" {
9595
source_value = "%s"
@@ -106,7 +106,7 @@ resource "delphix_appdata_dsource" "new_data_dsource" {
106106
resync = true
107107
})
108108
}
109-
`, sourceId, groupId, name, environmentUser, stagingEnvironment, postgresPort)
109+
`, sourceId, groupId, name, environmentUser, stagingEnvironment, parameters)
110110
}
111111

112112
func testDsourceExists(n string, sourceId string) resource.TestCheckFunc {

internal/provider/resource_vdb.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,10 @@ func resourceVdbRead(ctx context.Context, d *schema.ResourceData, meta interface
15911591
d.Set("post_stop", flattenHooks(result.GetHooks().PostStop))
15921592
d.Set("pre_rollback", flattenHooks(result.GetHooks().PreRollback))
15931593
d.Set("post_rollback", flattenHooks(result.GetHooks().PostRollback))
1594-
d.Set("database_name", result.GetDatabaseName())
1594+
if !*result.IsAppdata {
1595+
d.Set("database_name", result.GetDatabaseName())
1596+
}
1597+
15951598
d.Set("tags", flattenTags(result.GetTags()))
15961599
d.Set("vdb_restart", result.GetVdbRestart())
15971600

@@ -1927,7 +1930,6 @@ func resourceVdbUpdate(ctx context.Context, d *schema.ResourceData, meta interfa
19271930
tflog.Debug(ctx, "tag to be deleted: "+toTagArray(oldTag)[0].GetKey()+" "+toTagArray(oldTag)[0].GetValue())
19281931
deleteTag := *dctapi.NewDeleteTag()
19291932
tagDelResp, tagDelErr := client.VDBsAPI.DeleteVdbTags(ctx, vdbId).DeleteTag(deleteTag).Execute()
1930-
tflog.Debug(ctx, "tag delete response: "+tagDelResp.Status)
19311933
if diags := apiErrorResponseHelper(ctx, nil, tagDelResp, tagDelErr); diags != nil {
19321934
revertChanges(d, changedKeys)
19331935
updateFailure = true

internal/provider/resource_vdb_group.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func resourceVdbGroup() *schema.Resource {
3030
},
3131
"vdb_ids": {
3232
Type: schema.TypeList,
33-
Required: true,
33+
Optional: true,
3434
Elem: &schema.Schema{
3535
Type: schema.TypeString,
3636
},
@@ -45,9 +45,9 @@ func resourceVdbGroupCreate(ctx context.Context, d *schema.ResourceData, meta in
4545

4646
client := meta.(*apiClient).client
4747

48-
apiRes, httpRes, err := client.VDBGroupsAPI.CreateVdbGroup(ctx).CreateVDBGroupRequest(*dctapi.NewCreateVDBGroupRequest(
49-
d.Get("name").(string),
50-
)).Execute()
48+
vdbGroupCreateReq := *dctapi.NewCreateVDBGroupRequest(d.Get("name").(string))
49+
vdbGroupCreateReq.SetVdbIds(toStringArray(d.Get("vdb_ids")))
50+
apiRes, httpRes, err := client.VDBGroupsAPI.CreateVdbGroup(ctx).CreateVDBGroupRequest(vdbGroupCreateReq).Execute()
5151

5252
if diags := apiErrorResponseHelper(ctx, apiRes, httpRes, err); diags != nil {
5353
return diags
@@ -74,6 +74,7 @@ func resourceVdbGroupRead(ctx context.Context, d *schema.ResourceData, meta inte
7474
apiRes, httpRes, err := client.VDBGroupsAPI.GetVdbGroup(ctx, vdbGroupId).Execute()
7575

7676
if diags := apiErrorResponseHelper(ctx, apiRes, httpRes, err); diags != nil {
77+
d.SetId("")
7778
return diags
7879
}
7980

internal/provider/resource_vdb_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ func testAccVdbAppDataPreCheck(t *testing.T) {
9393
if err := os.Getenv("APPDATA_SOURCE_PARAMS"); err == "" {
9494
t.Fatal("APPDATA_SOURCE_PARAMS must be set for vdb acceptance tests")
9595
}
96-
if err := os.Getenv("APPDATA_CONFIG_PARAMS"); err == "" {
97-
t.Fatal("APPDATA_CONFIG_PARAMS must be set for vdb acceptance tests")
98-
}
9996
}
10097

10198
func testAccCheckDctVDBConfigBasic() string {
@@ -111,15 +108,13 @@ func testAccCheckDctVDBConfigBasic() string {
111108
func testAccCheckDctVDBConfigAppDataBasic() string {
112109
appdata_datasource_id := os.Getenv("APPDATA_DATASOURCE_ID")
113110
appdata_source_params := os.Getenv("APPDATA_SOURCE_PARAMS")
114-
appdata_config_params := os.Getenv("APPDATA_CONFIG_PARAMS")
115111
return fmt.Sprintf(`
116112
resource "delphix_vdb" "new_appdata" {
117113
auto_select_repository = true
118114
source_data_id = "%s"
119115
appdata_source_params = jsonencode(%s)
120-
appdata_config_params = jsonencode(%s)
121116
}
122-
`, appdata_datasource_id, appdata_source_params, appdata_config_params)
117+
`, appdata_datasource_id, appdata_source_params)
123118
}
124119

125120
func testAccCheckDctVDBBookmarkConfigBasic() string {
@@ -185,8 +180,6 @@ func testAccCheckDctVDBBookmarkConfigBasic() string {
185180
}
186181
`, bookmark_id)
187182

188-
print(resource)
189-
190183
return resource
191184

192185
}
@@ -314,8 +307,6 @@ func testAccCheckVdbDestroy(s *terraform.State) error {
314307

315308
func testAccCheckVdbDestroyBookmark(s *terraform.State) error {
316309
client := testAccProvider.Meta().(*apiClient).client
317-
318-
print("Deleting parent vdb " + vdb_id)
319310
deleteVdbParams := dctapi.NewDeleteVDBParametersWithDefaults()
320311
deleteVdbParams.SetForce(false)
321312
client.VDBsAPI.DeleteVdb(context.Background(), vdb_id).DeleteVDBParameters(*deleteVdbParams).Execute()

internal/provider/utility.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"math"
77
"net/http"
8+
"reflect"
89
"strconv"
910
"time"
1011

@@ -285,7 +286,9 @@ func enableVDB(ctx context.Context, client *dctapi.APIClient, vdbId string) diag
285286
func revertChanges(d *schema.ResourceData, changedKeys []string) {
286287
for _, key := range changedKeys {
287288
old, _ := d.GetChange(key)
288-
d.Set(key, old)
289+
if !reflect.ValueOf(old).IsZero() { // so that a previously optional param is not set to blank erroraneously
290+
d.Set(key, old)
291+
}
289292
}
290293
}
291294

0 commit comments

Comments
 (0)