Skip to content

Commit e138db3

Browse files
documentation and logging changes
1 parent 1d1043b commit e138db3

File tree

3 files changed

+66
-22
lines changed

3 files changed

+66
-22
lines changed

docs/resources/appdata_dsource.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ In Delphix terminology, a dSource is a database that the Delphix Continuous Data
44
A dSource is created and managed by the Delphix Continuous Data Engine.
55

66

7-
The dSource resource allows Terraform to apply and destroy Delphix dSources.
8-
Modification of existing dSource resources is not supported. All supported parameters are listed below
7+
The appdata dSource resource allows Terraform to apply and destroy Delphix dSources.
8+
Modification of existing appdata dSource resources is not supported. All supported parameters are listed below
99

1010
## Example Usage
11-
dSource linking can be done in 3 methods , the parameters for these methods wary based on the linking mechanism to be used.
11+
Appdata dSource linking can be done in 3 methods , the parameters for these methods wary based on the linking mechanism to be used.
1212

1313
```hcl
1414
# Link dSource using external backup.
@@ -109,7 +109,7 @@ resource "delphix_appdata_dsource" "dsource_name" {
109109

110110
* `source_id` - (Required) Id of the source to link.
111111

112-
* `group_id` - (Optional) Id of the dataset group where this dSource should belong to.
112+
* `group_id` - (Required) Id of the dataset group where this dSource should belong to.
113113

114114
* `log_sync_enabled` - (Required) True if LogSync should run for this database.
115115

@@ -171,6 +171,8 @@ resource "delphix_appdata_dsource" "dsource_name" {
171171

172172
* `excludes` - (Optional) List of subdirectories in the source to exclude when syncing data.These paths are relative to the root of the source directory. [AppDataDirect only]
173173

174+
* `follow_symlinks` - (Optional) List of symlinks in the source to follow when syncing data.These paths are relative to the root of the source directory. All other symlinks are preserved. [AppDataDirect only]
175+
174176
* `parameters` - (Optional) The JSON payload conforming to the DraftV4 schema based on the type of application data being manipulated.
175177

176178
* `sync_parameters` - (Optional) The JSON payload conforming to the snapshot parameters definition in a LUA toolkit or platform plugin.

examples/dsource/main.tf

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ provider "delphix" {
5353

5454
resource "delphix_appdata_dsource" "test_app_data_dsource_second" {
5555
source_id = "1-APPDATA_STAGED_SOURCE_CONFIG-7"
56-
group_id = ""
56+
group_id = "1-GROUP-1"
5757
log_sync_enabled = false
5858
make_current_account_owner = true
5959
link_type = "AppDataStaged"
@@ -71,14 +71,33 @@ resource "delphix_appdata_dsource" "test_app_data_dsource_second" {
7171
sourceHostAddress : "HOSTNAME"
7272
}
7373
],
74-
postgresPort : XXXX,
74+
postgresPort : 5433,
7575
mountLocation : "/tmp/delphix_mnt_second"
7676
})
7777
sync_parameters = jsonencode({
7878
resync = true
7979
})
80+
ops_pre_sync {
81+
name = "key-1"
82+
command = "echo \"hello world\""
83+
shell = "shell"
84+
credentials_env_vars {
85+
base_var_name = "XXXX"
86+
password = "XXXX"
87+
}
88+
}
89+
ops_post_sync {
90+
name = "key-2"
91+
command = "echo \"hello world\""
92+
shell = "shell"
93+
credentials_env_vars {
94+
base_var_name = "XXXX"
95+
password = "XXXX"
96+
}
97+
}
8098
}
8199

100+
82101
# Below are the 3 ways to link dsource with params , use any one of them
83102
# externalBackup: [
84103
# {

internal/provider/resource_appdata_dsource.go

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func resourceAppdataDsource() *schema.Resource {
1414
return &schema.Resource{
1515
// This description is used by the documentation generator and the language server.
16-
Description: "Resource for app data dsource creation.",
16+
Description: "Resource for appdata dSource creation.",
1717

1818
CreateContext: resourceAppdataDsourceCreate,
1919
ReadContext: resourceAppdataDsourceRead,
@@ -331,7 +331,9 @@ func toSourceOperationArray(array interface{}) []dctapi.SourceOperation {
331331
for _, item := range array.([]interface{}) {
332332
item_map := item.(map[string]interface{})
333333
sourceOperation := dctapi.NewSourceOperation(item_map["name"].(string), item_map["command"].(string))
334-
sourceOperation.SetShell(item_map["shell"].(string))
334+
if item_map["shell"].(string) != "" {
335+
sourceOperation.SetShell(item_map["shell"].(string))
336+
}
335337
sourceOperation.SetCredentialsEnvVars(toCredentialsEnvVariableArray(item_map["credentials_env_vars"]))
336338
items = append(items, *sourceOperation)
337339
}
@@ -342,17 +344,38 @@ func toCredentialsEnvVariableArray(array interface{}) []dctapi.CredentialsEnvVar
342344
items := []dctapi.CredentialsEnvVariable{}
343345
for _, item := range array.([]interface{}) {
344346
item_map := item.(map[string]interface{})
347+
345348
credentialsEnvVariable_item := dctapi.NewCredentialsEnvVariable(item_map["base_var_name"].(string))
346-
credentialsEnvVariable_item.SetPassword(item_map["password"].(string))
347-
credentialsEnvVariable_item.SetVault(item_map["vault"].(string))
348-
credentialsEnvVariable_item.SetHashicorpVaultEngine(item_map["hashicorp_vault_engine"].(string))
349-
credentialsEnvVariable_item.SetHashicorpVaultEngine(item_map["hashicorp_vault_secret_path"].(string))
350-
credentialsEnvVariable_item.SetHashicorpVaultEngine(item_map["hashicorp_vault_username_key"].(string))
351-
credentialsEnvVariable_item.SetHashicorpVaultEngine(item_map["hashicorp_vault_secret_key"].(string))
352-
credentialsEnvVariable_item.SetHashicorpVaultEngine(item_map["azure_vault_name"].(string))
353-
credentialsEnvVariable_item.SetHashicorpVaultEngine(item_map["azure_vault_username_key"].(string))
354-
credentialsEnvVariable_item.SetHashicorpVaultEngine(item_map["azure_vault_secret_key"].(string))
355-
credentialsEnvVariable_item.SetHashicorpVaultEngine(item_map["cyberark_vault_query_string"].(string))
349+
if item_map["password"].(string) != "" {
350+
credentialsEnvVariable_item.SetPassword(item_map["password"].(string))
351+
}
352+
if item_map["vault"].(string) != "" {
353+
credentialsEnvVariable_item.SetVault(item_map["vault"].(string))
354+
}
355+
if item_map["hashicorp_vault_engine"].(string) != "" {
356+
credentialsEnvVariable_item.SetHashicorpVaultEngine(item_map["hashicorp_vault_engine"].(string))
357+
}
358+
if item_map["hashicorp_vault_secret_path"].(string) != "" {
359+
credentialsEnvVariable_item.SetHashicorpVaultSecretPath(item_map["hashicorp_vault_secret_path"].(string))
360+
}
361+
if item_map["hashicorp_vault_username_key"].(string) != "" {
362+
credentialsEnvVariable_item.SetHashicorpVaultUsernameKey(item_map["hashicorp_vault_username_key"].(string))
363+
}
364+
if item_map["hashicorp_vault_secret_key"].(string) != "" {
365+
credentialsEnvVariable_item.SetHashicorpVaultSecretKey(item_map["hashicorp_vault_secret_key"].(string))
366+
}
367+
if item_map["azure_vault_name"].(string) != "" {
368+
credentialsEnvVariable_item.SetAzureVaultName(item_map["azure_vault_name"].(string))
369+
}
370+
if item_map["azure_vault_username_key"].(string) != "" {
371+
credentialsEnvVariable_item.SetAzureVaultUsernameKey(item_map["azure_vault_username_key"].(string))
372+
}
373+
if item_map["azure_vault_secret_key"].(string) != "" {
374+
credentialsEnvVariable_item.SetAzureVaultSecretKey(item_map["azure_vault_secret_key"].(string))
375+
}
376+
if item_map["cyberark_vault_query_string"].(string) != "" {
377+
credentialsEnvVariable_item.SetCyberarkVaultQueryString(item_map["cyberark_vault_query_string"].(string))
378+
}
356379
items = append(items, *credentialsEnvVariable_item)
357380
}
358381
return items
@@ -470,10 +493,10 @@ func resourceAppdataDsourceRead(ctx context.Context, d *schema.ResourceData, met
470493
})
471494
// This would imply error in poll for deletion so we just log and exit.
472495
if diags != nil {
473-
ErrorLog.Printf("Error in polling of Dsource for deletion.")
496+
ErrorLog.Printf("Error in polling of appdata dSource for deletion.")
474497
} else {
475498
// diags will be nill in case of successful poll for deletion logic aka 404
476-
ErrorLog.Printf("Error reading the Dsource %s, removing from state.", dsource_id)
499+
ErrorLog.Printf("Error reading the appdata dSource %s, removing from state.", dsource_id)
477500
d.SetId("")
478501
}
479502

@@ -519,7 +542,7 @@ func resourceAppdataDsourceUpdate(ctx context.Context, d *schema.ResourceData, m
519542
d.Set(key, old)
520543
}
521544

522-
return diag.Errorf("not implemented")
545+
return diag.Errorf("Action update not implemented for resource : appdata dsource")
523546
}
524547

525548
func resourceAppdataDsourceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
@@ -542,7 +565,7 @@ func resourceAppdataDsourceDelete(ctx context.Context, d *schema.ResourceData, m
542565
}
543566
InfoLog.Printf("Job result is %s", job_status)
544567
if isJobTerminalFailure(job_status) {
545-
return diag.Errorf("[NOT OK] Dsource-Delete %s. JobId: %s / Error: %s", job_status, *res.Id, job_err)
568+
return diag.Errorf("[NOT OK] Appdata dSource-Delete %s. JobId: %s / Error: %s", job_status, *res.Id, job_err)
546569
}
547570

548571
_, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) {

0 commit comments

Comments
 (0)