Skip to content

Commit 3e408a2

Browse files
author
Uddipaan Hazarika
committed
develop cut | vdb updates
1 parent 12752ad commit 3e408a2

17 files changed

+398
-134
lines changed

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ module terraform-provider-delphix
22

33
go 1.22.0
44

5+
toolchain go1.22.6
6+
57
require (
68
github.com/delphix/dct-sdk-go/v14 v14.0.0
9+
github.com/delphix/dct-sdk-go/v21 v21.0.0
710
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
811
)
912

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
2121
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2222
github.com/delphix/dct-sdk-go/v14 v14.0.0 h1:ap+uHAN2zvQQgvyk4lImAjvIo6tkN1pG/8932qq66bY=
2323
github.com/delphix/dct-sdk-go/v14 v14.0.0/go.mod h1:OwfMNFfYxQrunIxpfmFK0cIKC6o8gf2x7fE8LhcWNfo=
24+
github.com/delphix/dct-sdk-go/v21 v21.0.0 h1:6fj52ADsaKyR41LlEvLFOWeqc6z0fgh6+VzkLRD5yMg=
25+
github.com/delphix/dct-sdk-go/v21 v21.0.0/go.mod h1:4X/VTv451NWvtNwMltqZvNgwDITkTH61yOMOKswoERg=
2426
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
2527
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
2628
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
@@ -133,8 +135,8 @@ github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2
133135
github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
134136
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
135137
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
136-
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
137-
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
138+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
139+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
138140
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
139141
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
140142
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=

internal/provider/commons.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,49 @@ const (
1515
WARN string = "[WARN] "
1616
ERROR string = "[ERROR] "
1717
)
18+
19+
var updatableVdbKeys = map[string]bool{
20+
"name": true,
21+
"db_username": true,
22+
"db_password": true,
23+
"pre_refresh": true,
24+
"post_refresh": true,
25+
"configure_clone": true,
26+
"pre_snapshot": true,
27+
"post_snapshot": true,
28+
"pre_start": true,
29+
"post_start": true,
30+
"pre_stop": true,
31+
"post_stop": true,
32+
"template_id": true,
33+
"pre_script": true,
34+
"post_script": true,
35+
"custom_env_vars": true,
36+
"custom_env_files": true,
37+
"appdata_source_params": true,
38+
"appdata_config_params": true,
39+
"config_params": true,
40+
}
41+
42+
var isDestructiveVdbUpdate = map[string]bool{
43+
"name": false,
44+
"db_username": false,
45+
"db_password": false,
46+
"pre_refresh": false,
47+
"post_refresh": false,
48+
"configure_clone": false,
49+
"pre_snapshot": false,
50+
"post_snapshot": false,
51+
"pre_start": false,
52+
"post_start": false,
53+
"pre_stop": false,
54+
"post_stop": false,
55+
"template_id": true,
56+
"pre_script": false,
57+
"post_script": false,
58+
"custom_env_vars": false,
59+
"custom_env_files": false,
60+
"appdata_source_params": true,
61+
"appdata_config_params": true,
62+
"config_params": true,
63+
}

internal/provider/provider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"crypto/tls"
66
"net/http"
77

8-
dctapi "github.com/delphix/dct-sdk-go/v14"
8+
dctapi "github.com/delphix/dct-sdk-go/v21"
99

1010
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -99,8 +99,8 @@ func configure(version string, p *schema.Provider) func(context.Context, *schema
9999
}
100100
// make a test call
101101

102-
req := client.ManagementApi.GetRegisteredEngines(ctx)
103-
_, _, err := client.ManagementApi.GetRegisteredEnginesExecute(req)
102+
req := client.ManagementAPI.GetRegisteredEngines(ctx)
103+
_, _, err := client.ManagementAPI.GetRegisteredEnginesExecute(req)
104104

105105
if err != nil {
106106
return nil, diag.FromErr(err)

internal/provider/resource_appdata_dsource.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"encoding/json"
66
"net/http"
77

8-
dctapi "github.com/delphix/dct-sdk-go/v14"
8+
dctapi "github.com/delphix/dct-sdk-go/v21"
99
"github.com/hashicorp/terraform-plugin-log/tflog"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1111
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -457,7 +457,7 @@ func resourceAppdataDsourceCreate(ctx context.Context, d *schema.ResourceData, m
457457
appDataDSourceLinkSourceParameters.SetSyncParameters(sync_params)
458458
}
459459

460-
req := client.DSourcesApi.LinkAppdataDatabase(ctx)
460+
req := client.DSourcesAPI.LinkAppdataDatabase(ctx)
461461

462462
apiRes, httpRes, err := req.AppDataDSourceLinkSourceParameters(*appDataDSourceLinkSourceParameters).Execute()
463463
if diags := apiErrorResponseHelper(ctx, apiRes, httpRes, err); diags != nil {
@@ -497,12 +497,12 @@ func resourceDsourceRead(ctx context.Context, d *schema.ResourceData, meta inter
497497
dsource_id := d.Id()
498498

499499
res, diags := PollForObjectExistence(ctx, func() (interface{}, *http.Response, error) {
500-
return client.DSourcesApi.GetDsourceById(ctx, dsource_id).Execute()
500+
return client.DSourcesAPI.GetDsourceById(ctx, dsource_id).Execute()
501501
})
502502

503503
if diags != nil {
504504
_, diags := PollForObjectDeletion(ctx, func() (interface{}, *http.Response, error) {
505-
return client.DSourcesApi.GetDsourceById(ctx, dsource_id).Execute()
505+
return client.DSourcesAPI.GetDsourceById(ctx, dsource_id).Execute()
506506
})
507507
// This would imply error in poll for deletion so we just log and exit.
508508
if diags != nil {
@@ -564,7 +564,7 @@ func resourceDsourceDelete(ctx context.Context, d *schema.ResourceData, meta int
564564
deleteDsourceParams := dctapi.NewDeleteDSourceRequest(dsourceId)
565565
deleteDsourceParams.SetForce(false)
566566

567-
res, httpRes, err := client.DSourcesApi.DeleteDsource(ctx).DeleteDSourceRequest(*deleteDsourceParams).Execute()
567+
res, httpRes, err := client.DSourcesAPI.DeleteDsource(ctx).DeleteDSourceRequest(*deleteDsourceParams).Execute()
568568

569569
if diags := apiErrorResponseHelper(ctx, res, httpRes, err); diags != nil {
570570
return diags
@@ -580,7 +580,7 @@ func resourceDsourceDelete(ctx context.Context, d *schema.ResourceData, meta int
580580
}
581581

582582
_, diags := PollForObjectDeletion(ctx, func() (interface{}, *http.Response, error) {
583-
return client.DSourcesApi.GetDsourceById(ctx, dsourceId).Execute()
583+
return client.DSourcesAPI.GetDsourceById(ctx, dsourceId).Execute()
584584
})
585585

586586
return diags

internal/provider/resource_appdata_dsource_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func testDsourceExists(n string, sourceId string) resource.TestCheckFunc {
123123
}
124124

125125
client := testAccProvider.Meta().(*apiClient).client
126-
res, _, err := client.DSourcesApi.GetDsourceById(context.Background(), dsourceId).Execute()
126+
res, _, err := client.DSourcesAPI.GetDsourceById(context.Background(), dsourceId).Execute()
127127
if err != nil {
128128
return err
129129
}
@@ -147,7 +147,7 @@ func testDsourceDestroy(s *terraform.State) error {
147147

148148
dsourceId := rs.Primary.ID
149149

150-
_, httpResp, _ := client.DSourcesApi.GetDsourceById(context.Background(), dsourceId).Execute()
150+
_, httpResp, _ := client.DSourcesAPI.GetDsourceById(context.Background(), dsourceId).Execute()
151151
if httpResp == nil {
152152
return fmt.Errorf("Dsource has not been deleted")
153153
}

internal/provider/resource_database_postgresql.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"net/http"
66

7-
dctapi "github.com/delphix/dct-sdk-go/v14"
7+
dctapi "github.com/delphix/dct-sdk-go/v21"
88
"github.com/hashicorp/terraform-plugin-log/tflog"
99
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1010
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -146,7 +146,7 @@ func resourceDatabasePostgressqlCreate(ctx context.Context, d *schema.ResourceDa
146146
sourceCreateParameters.SetEngineId(v.(string))
147147
}
148148

149-
req := client.SourcesApi.CreatePostgresSource(ctx)
149+
req := client.SourcesAPI.CreatePostgresSource(ctx)
150150

151151
apiRes, httpRes, err := req.PostgresSourceCreateParameters(*sourceCreateParameters).Execute()
152152
if diags := apiErrorResponseHelper(ctx, apiRes, httpRes, err); diags != nil {
@@ -184,12 +184,12 @@ func resourceDatabasePostgressqlRead(ctx context.Context, d *schema.ResourceData
184184
source_id := d.Id()
185185

186186
res, diags := PollForObjectExistence(ctx, func() (interface{}, *http.Response, error) {
187-
return client.SourcesApi.GetSourceById(ctx, source_id).Execute()
187+
return client.SourcesAPI.GetSourceById(ctx, source_id).Execute()
188188
})
189189

190190
if diags != nil {
191191
_, diags := PollForObjectDeletion(ctx, func() (interface{}, *http.Response, error) {
192-
return client.SourcesApi.GetSourceById(ctx, source_id).Execute()
192+
return client.SourcesAPI.GetSourceById(ctx, source_id).Execute()
193193
})
194194
// This would imply error in poll for deletion so we just log and exit.
195195
if diags != nil {
@@ -262,7 +262,7 @@ func resourceDatabasePostgressqlUpdate(ctx context.Context, d *schema.ResourceDa
262262
updateSourceParam.SetName(d.Get("name").(string))
263263
}
264264

265-
res, httpRes, err := client.SourcesApi.UpdatePostgresSourceById(ctx, d.Get("id").(string)).PostgresSourceUpdateParameters(*updateSourceParam).Execute()
265+
res, httpRes, err := client.SourcesAPI.UpdatePostgresSourceById(ctx, d.Get("id").(string)).PostgresSourceUpdateParameters(*updateSourceParam).Execute()
266266

267267
if diags := apiErrorResponseHelper(ctx, nil, httpRes, err); diags != nil {
268268
// revert and set the old value to the changed keys
@@ -290,7 +290,7 @@ func resourceDatabasePostgressqlDelete(ctx context.Context, d *schema.ResourceDa
290290

291291
source_id := d.Id()
292292

293-
res, httpRes, err := client.SourcesApi.DeleteSource(ctx, source_id).Execute()
293+
res, httpRes, err := client.SourcesAPI.DeleteSource(ctx, source_id).Execute()
294294

295295
if diags := apiErrorResponseHelper(ctx, res, httpRes, err); diags != nil {
296296
return diags
@@ -306,7 +306,7 @@ func resourceDatabasePostgressqlDelete(ctx context.Context, d *schema.ResourceDa
306306
}
307307

308308
_, diags := PollForObjectDeletion(ctx, func() (interface{}, *http.Response, error) {
309-
return client.SourcesApi.GetSourceById(ctx, source_id).Execute()
309+
return client.SourcesAPI.GetSourceById(ctx, source_id).Execute()
310310
})
311311

312312
return diags

internal/provider/resource_database_postgresql_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func testSourceDestroy(s *terraform.State) error {
7171

7272
sourceId := rs.Primary.ID
7373

74-
_, httpResp, _ := client.SourcesApi.GetSourceById(context.Background(), sourceId).Execute()
74+
_, httpResp, _ := client.SourcesAPI.GetSourceById(context.Background(), sourceId).Execute()
7575
if httpResp == nil {
7676
return fmt.Errorf("Source has not been deleted")
7777
}
@@ -107,7 +107,7 @@ func testSourceExists(n string, name string) resource.TestCheckFunc {
107107
}
108108

109109
client := testAccProvider.Meta().(*apiClient).client
110-
res, _, err := client.SourcesApi.GetSourceById(context.Background(), sourceId).Execute()
110+
res, _, err := client.SourcesAPI.GetSourceById(context.Background(), sourceId).Execute()
111111
if err != nil {
112112
return err
113113
}

internal/provider/resource_environment.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package provider
22

33
import (
44
"context"
5-
"github.com/hashicorp/terraform-plugin-log/tflog"
65
"net/http"
76

8-
dctapi "github.com/delphix/dct-sdk-go/v14"
7+
"github.com/hashicorp/terraform-plugin-log/tflog"
8+
9+
dctapi "github.com/delphix/dct-sdk-go/v21"
910
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1011
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1112
)
@@ -384,7 +385,7 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, meta
384385
createEnvParams.SetTags(toTagArray(v))
385386
}
386387

387-
apiReq := client.EnvironmentsApi.CreateEnvironment(ctx)
388+
apiReq := client.EnvironmentsAPI.CreateEnvironment(ctx)
388389
apiRes, httpRes, err := apiReq.EnvironmentCreateParameters(*createEnvParams).Execute()
389390

390391
if diags := apiErrorResponseHelper(ctx, apiRes, httpRes, err); diags != nil {
@@ -415,12 +416,12 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta i
415416
envId := d.Id()
416417

417418
apiRes, diags := PollForObjectExistence(ctx, func() (interface{}, *http.Response, error) {
418-
return client.EnvironmentsApi.GetEnvironmentById(ctx, envId).Execute()
419+
return client.EnvironmentsAPI.GetEnvironmentById(ctx, envId).Execute()
419420
})
420421

421422
if diags != nil {
422423
_, diags := PollForObjectDeletion(ctx, func() (interface{}, *http.Response, error) {
423-
return client.EnvironmentsApi.GetEnvironmentById(ctx, envId).Execute()
424+
return client.EnvironmentsAPI.GetEnvironmentById(ctx, envId).Execute()
424425
})
425426
if diags != nil {
426427
tflog.Error(ctx, DLPX+ERROR+"Error in polling of environment for deletion.")
@@ -450,7 +451,7 @@ func resourceEnvironmentDelete(ctx context.Context, d *schema.ResourceData, meta
450451
client := meta.(*apiClient).client
451452
envId := d.Id()
452453

453-
apiRes, httpRes, err := client.EnvironmentsApi.DeleteEnvironment(ctx, envId).Execute()
454+
apiRes, httpRes, err := client.EnvironmentsAPI.DeleteEnvironment(ctx, envId).Execute()
454455

455456
if diags := apiErrorResponseHelper(ctx, apiRes, httpRes, err); diags != nil {
456457
return diags
@@ -464,7 +465,7 @@ func resourceEnvironmentDelete(ctx context.Context, d *schema.ResourceData, meta
464465
return diag.Errorf("[NOT OK] Env-Delete %s. JobId: %s / Error: %s", job_status, *apiRes.Job.Id, job_err)
465466
}
466467
_, diags := PollForObjectDeletion(ctx, func() (interface{}, *http.Response, error) {
467-
return client.EnvironmentsApi.GetEnvironmentById(ctx, envId).Execute()
468+
return client.EnvironmentsAPI.GetEnvironmentById(ctx, envId).Execute()
468469
})
469470

470471
return diags

internal/provider/resource_environment_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func testAccCheckDctEnvResourceExists(n string, hostname string) resource.TestCh
8686
}
8787

8888
client := testAccProvider.Meta().(*apiClient).client
89-
res, _, err := client.EnvironmentsApi.GetEnvironmentById(context.Background(), EnvId).Execute()
89+
res, _, err := client.EnvironmentsAPI.GetEnvironmentById(context.Background(), EnvId).Execute()
9090
if err != nil {
9191
return err
9292
}
@@ -110,7 +110,7 @@ func testAccCheckEnvDestroy(s *terraform.State) error {
110110

111111
EnvId := rs.Primary.ID
112112

113-
_, httpResp, _ := client.EnvironmentsApi.GetEnvironmentById(context.Background(), EnvId).Execute()
113+
_, httpResp, _ := client.EnvironmentsAPI.GetEnvironmentById(context.Background(), EnvId).Execute()
114114
if httpResp == nil {
115115
return fmt.Errorf("Environment has not been deleted")
116116
}

0 commit comments

Comments
 (0)