From fb26a0b29e08c24e7473c3e8cd040edcc53dab7d Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Tue, 17 Oct 2023 21:04:32 +0530 Subject: [PATCH 01/11] new resource for oracle dsource creation/deletion --- internal/provider/resource_oracle_dsource.go | 615 +++++++++++++++++++ 1 file changed, 615 insertions(+) create mode 100644 internal/provider/resource_oracle_dsource.go diff --git a/internal/provider/resource_oracle_dsource.go b/internal/provider/resource_oracle_dsource.go new file mode 100644 index 0000000..054bbd9 --- /dev/null +++ b/internal/provider/resource_oracle_dsource.go @@ -0,0 +1,615 @@ +package provider + +import ( + "context" + "net/http" + + dctapi "github.com/delphix/dct-sdk-go/v10" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceOracleDsource() *schema.Resource { + return &schema.Resource{ + // This description is used by the documentation generator and the language server. + Description: "Resource for Oracle dSource creation.", + + CreateContext: resourceOracleDsourceCreate, + ReadContext: resourceOracleDsourceRead, + UpdateContext: resourceOracleDsourceUpdate, + DeleteContext: resourceOracleDsourceDelete, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + }, + "source_id": { + Type: schema.TypeString, + Required: true, + }, + "group_id": { + Type: schema.TypeString, + Required: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + }, + "log_sync_enabled": { + Type: schema.TypeBool, + Optional: true, + }, + "make_current_account_owner": { + Type: schema.TypeBool, + Optional: true, + }, + "tags": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Optional: true, + }, + "value": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + "ops_pre_sync": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + }, + "command": { + Type: schema.TypeString, + Optional: true, + }, + "shell": { + Type: schema.TypeString, + Optional: true, + }, "credentials_env_vars": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "base_var_name": { + Type: schema.TypeString, + Required: true, + }, + "password": { + Type: schema.TypeString, + Optional: true, + }, + "vault": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_engine": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_secret_path": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "azure_vault_name": { + Type: schema.TypeString, + Optional: true, + }, + "azure_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "azure_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "cyberark_vault_query_string": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + }, + "ops_post_sync": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + }, + "command": { + Type: schema.TypeString, + Optional: true, + }, + "shell": { + Type: schema.TypeString, + Optional: true, + }, "credentials_env_vars": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "base_var_name": { + Type: schema.TypeString, + Required: true, + }, + "password": { + Type: schema.TypeString, + Optional: true, + }, + "vault": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_engine": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_secret_path": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "azure_vault_name": { + Type: schema.TypeString, + Optional: true, + }, + "azure_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "azure_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "cyberark_vault_query_string": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + }, + "external_file_path": { + Type: schema.TypeString, + Required: true, + }, + "environment_user_id": { + Type: schema.TypeString, + Required: true, + }, + "backup_level_enabled": { + Type: schema.TypeBool, + Optional: true, + }, + "rman_channels": { + Type: schema.TypeInt, + Optional: true, + }, + "files_per_set": { + Type: schema.TypeInt, + Required: true, + }, + "check_logical": { + Type: schema.TypeBool, + Optional: true, + }, + ////////////////////////////TODO ADD REMAINING INPUTS///// + + // Output + "id": { + Type: schema.TypeString, + Computed: true, + }, + "database_type": { + Type: schema.TypeString, + Computed: true, + }, + "namespace_id": { + Type: schema.TypeString, + Computed: true, + }, + "namespace_name": { + Type: schema.TypeString, + Computed: true, + }, + "is_replica": { + Type: schema.TypeBool, + Computed: true, + }, + "database_version": { + Type: schema.TypeString, + Computed: true, + }, + "content_type": { + Type: schema.TypeString, + Computed: true, + }, + "data_uuid": { + Type: schema.TypeString, + Computed: true, + }, + "storage_size": { + Type: schema.TypeInt, + Computed: true, + }, + "plugin_version": { + Type: schema.TypeString, + Computed: true, + }, + "creation_date": { + Type: schema.TypeString, + Computed: true, + }, + "group_name": { + Type: schema.TypeString, + Computed: true, + }, + "enabled": { + Type: schema.TypeBool, + Computed: true, + }, + "engine_id": { + Type: schema.TypeString, + Computed: true, + }, + "status": { + Type: schema.TypeString, + Computed: true, + }, + "engine_name": { + Type: schema.TypeString, + Computed: true, + }, + "current_timeflow_id": { + Type: schema.TypeString, + Computed: true, + }, + "previous_timeflow_id": { + Type: schema.TypeString, + Computed: true, + }, + "is_appdata": { + Type: schema.TypeBool, + Computed: true, + }, + }, + } +} + +func resourceOracleDsourceCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + var diags diag.Diagnostics + client := meta.(*apiClient).client + + oracleDSourceLinkSourceParameters := dctapi.NewOracleDSourceLinkSourceParametersWithDefaults() + + if v, has_v := d.GetOk("name"); has_v { + oracleDSourceLinkSourceParameters.SetName(v.(string)) + } + if v, has_v := d.GetOk("source_id"); has_v { + oracleDSourceLinkSourceParameters.SetSourceId(v.(string)) + } + if v, has_v := d.GetOk("group_id"); has_v { + oracleDSourceLinkSourceParameters.SetGroupId(v.(string)) + } + if v, has_v := d.GetOk("description"); has_v { + oracleDSourceLinkSourceParameters.SetDescription(v.(string)) + } + if v, has_v := d.GetOkExists("log_sync_enabled"); has_v { + oracleDSourceLinkSourceParameters.SetLogSyncEnabled(v.(bool)) + } + if v, has_v := d.GetOkExists("make_current_account_owner"); has_v { + oracleDSourceLinkSourceParameters.SetMakeCurrentAccountOwner(v.(bool)) + } + if v, has_v := d.GetOk("tags"); has_v { + oracleDSourceLinkSourceParameters.SetTags(toTagArray(v)) + } + if v, has_v := d.GetOk("ops_pre_sync"); has_v { + oracleDSourceLinkSourceParameters.SetOpsPreSync(toSourceOperationArray(v)) + } + if v, has_v := d.GetOk("ops_post_sync"); has_v { + oracleDSourceLinkSourceParameters.SetOpsPostSync(toSourceOperationArray(v)) + } + if v, has_v := d.GetOk("external_file_path"); has_v { + oracleDSourceLinkSourceParameters.SetExternalFilePath(v.(string)) + } + if v, has_v := d.GetOk("environment_user_id"); has_v { + oracleDSourceLinkSourceParameters.SetEnvironmentUserId(v.(string)) + } + if v, has_v := d.GetOkExists("backup_level_enabled"); has_v { + oracleDSourceLinkSourceParameters.SetBackupLevelEnabled(v.(bool)) + } + if v, has_v := d.GetOk("rman_channels"); has_v { + oracleDSourceLinkSourceParameters.SetRmanChannels(v.(int32)) + } + if v, has_v := d.GetOk("files_per_set"); has_v { + oracleDSourceLinkSourceParameters.SetFilesPerSet(v.(int32)) + } + if v, has_v := d.GetOkExists("check_logical"); has_v { + oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) + } + if v, has_v := d.GetOkExists("encrypted_linking_enabled"); has_v { + oracleDSourceLinkSourceParameters.SetEncryptedLinkingEnabled(v.(bool)) + } + if v, has_v := d.GetOkExists("compressed_linking_enabled"); has_v { + oracleDSourceLinkSourceParameters.SetCompressedLinkingEnabled(v.(bool)) + } + if v, has_v := d.GetOk("bandwidth_limit"); has_v { + oracleDSourceLinkSourceParameters.SetBandwidthLimit(v.(int32)) + } + if v, has_v := d.GetOk("number_of_connections"); has_v { + oracleDSourceLinkSourceParameters.SetNumberOfConnections(v.(int32)) + } + if v, has_v := d.GetOkExists("diagnose_no_logging_faults"); has_v { + oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) + } + if v, has_v := d.GetOkExists("pre_provisioning_enabled"); has_v { + oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) + } + if v, has_v := d.GetOkExists("link_now"); has_v { + oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) + } + if v, has_v := d.GetOkExists("force_full_backup"); has_v { + oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) + } + if v, has_v := d.GetOkExists("double_sync"); has_v { + oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) + } + if v, has_v := d.GetOkExists("skip_space_check"); has_v { + oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) + } + if v, has_v := d.GetOkExists("do_not_resume"); has_v { + oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) + } + if v, has_v := d.GetOk("files_for_full_backup"); has_v { + oracleDSourceLinkSourceParameters.SetFilesForFullBackup(toIntArray(v)) + } + if v, has_v := d.GetOk("log_sync_mode"); has_v { + oracleDSourceLinkSourceParameters.SetLogSyncMode(v.(string)) + } + if v, has_v := d.GetOk("log_sync_interval"); has_v { + oracleDSourceLinkSourceParameters.SetLogSyncInterval(v.(int32)) + } + if v, has_v := d.GetOk("non_sys_username"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysUsername(v.(string)) + } + if v, has_v := d.GetOk("non_sys_password"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysPassword(v.(string)) + } + + if v, has_v := d.GetOk("non_sys_vault"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysVault(v.(string)) + } + if v, has_v := d.GetOk("non_sys_hashicorp_vault_engine"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysHashicorpVaultEngine(v.(string)) + } + if v, has_v := d.GetOk("non_sys_hashicorp_vault_secret_path"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysHashicorpVaultSecretPath(v.(string)) + } + if v, has_v := d.GetOk("non_sys_hashicorp_vault_username_key"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysHashicorpVaultUsernameKey(v.(string)) + } + + if v, has_v := d.GetOk("non_sys_hashicorp_vault_secret_key"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysHashicorpVaultSecretKey(v.(string)) + } + + if v, has_v := d.GetOk("non_sys_azure_vault_name"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysAzureVaultName(v.(string)) + } + + if v, has_v := d.GetOk("non_sys_azure_vault_username_key"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysAzureVaultUsernameKey(v.(string)) + } + + if v, has_v := d.GetOk("non_sys_azure_vault_secret_key"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysAzureVaultSecretKey(v.(string)) + } + + if v, has_v := d.GetOk("non_sys_cyberark_vault_query_string"); has_v { + oracleDSourceLinkSourceParameters.SetNonSysCyberarkVaultQueryString(v.(string)) + } + if v, has_v := d.GetOk("fallback_username"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackUsername(v.(string)) + } + if v, has_v := d.GetOk("fallback_password"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackPassword(v.(string)) + } + if v, has_v := d.GetOk("fallback_vault"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackVault(v.(string)) + } + if v, has_v := d.GetOk("fallback_hashicorp_vault_engine"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackHashicorpVaultEngine(v.(string)) + } + if v, has_v := d.GetOk("fallback_hashicorp_vault_secret_path"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackHashicorpVaultSecretPath(v.(string)) + } + if v, has_v := d.GetOk("fallback_hashicorp_vault_username_key"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackHashicorpVaultUsernameKey(v.(string)) + } + if v, has_v := d.GetOk("fallback_hashicorp_vault_secret_key"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackHashicorpVaultSecretKey(v.(string)) + } + if v, has_v := d.GetOk("fallback_azure_vault_name"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackAzureVaultName(v.(string)) + } + if v, has_v := d.GetOk("fallback_azure_vault_username_key"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackAzureVaultUsernameKey(v.(string)) + } + if v, has_v := d.GetOk("fallback_azure_vault_secret_key"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackAzureVaultSecretKey(v.(string)) + } + if v, has_v := d.GetOk("fallback_cyberark_vault_query_string"); has_v { + oracleDSourceLinkSourceParameters.SetFallbackCyberarkVaultQueryString(v.(string)) + } + if v, has_v := d.GetOk("ops_pre_log_sync"); has_v { + oracleDSourceLinkSourceParameters.SetOpsPreLogSync(toSourceOperationArray(v)) + } + + req := client.DSourcesApi.LinkOracleDatabase(ctx) + + apiRes, httpRes, err := req.OracleDSourceLinkSourceParameters(*oracleDSourceLinkSourceParameters).Execute() + if diags := apiErrorResponseHelper(apiRes, httpRes, err); diags != nil { + return diags + } + + d.SetId(*apiRes.DsourceId) + + job_res, job_err := PollJobStatus(*apiRes.Job.Id, ctx, client) + if job_err != "" { + ErrorLog.Printf("Job Polling failed but continuing with dSource creation. Error: %s", job_err) + } + + InfoLog.Printf("Job result is %s", job_res) + + if job_res == Failed || job_res == Canceled || job_res == Abandoned { + d.SetId("") + ErrorLog.Printf("Job %s %s!", job_res, *apiRes.Job.Id) + return diag.Errorf("[NOT OK] Job %s %s with error %s", *apiRes.Job.Id, job_res, job_err) + } + + readDiags := resourceOracleDsourceRead(ctx, d, meta) + + if readDiags.HasError() { + return readDiags + } + + return diags +} + +func toIntArray(array interface{}) []int32 { + items := []int32{} + for _, item := range array.([]interface{}) { + items = append(items, item.(int32)) + } + return items +} + +func resourceOracleDsourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + + client := meta.(*apiClient).client + + dsource_id := d.Id() + + res, diags := PollForObjectExistence(func() (interface{}, *http.Response, error) { + return client.DSourcesApi.GetDsourceById(ctx, dsource_id).Execute() + }) + + if diags != nil { + _, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) { + return client.DSourcesApi.GetDsourceById(ctx, dsource_id).Execute() + }) + // This would imply error in poll for deletion so we just log and exit. + if diags != nil { + ErrorLog.Printf("Error in polling of appdata dSource for deletion.") + } else { + // diags will be nill in case of successful poll for deletion logic aka 404 + ErrorLog.Printf("Error reading the appdata dSource %s, removing from state.", dsource_id) + d.SetId("") + } + + return nil + } + + result, ok := res.(*dctapi.DSource) + if !ok { + return diag.Errorf("Error occured in type casting.") + } + + d.Set("id", result.GetId()) + d.Set("database_type", result.GetDatabaseType()) + d.Set("name", result.GetName()) + d.Set("is_replica", result.GetIsReplica()) + d.Set("storage_size", result.GetStorageSize()) + d.Set("plugin_version", result.GetPluginVersion()) + d.Set("creation_date", result.GetCreationDate().String()) + d.Set("group_name", result.GetGroupName()) + d.Set("enabled", result.GetEnabled()) + d.Set("engine_id", result.GetEngineId()) + d.Set("source_id", result.GetSourceId()) + d.Set("status", result.GetStatus()) + d.Set("engine_name", result.GetEngineName()) + d.Set("current_timeflow_id", result.GetCurrentTimeflowId()) + d.Set("is_appdata", result.GetIsAppdata()) + + return diags +} + +func resourceOracleDsourceUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + // get the changed keys + changedKeys := make([]string, 0, len(d.State().Attributes)) + for k := range d.State().Attributes { + if d.HasChange(k) { + changedKeys = append(changedKeys, k) + } + } + // revert and set the old value to the changed keys + for _, key := range changedKeys { + old, _ := d.GetChange(key) + d.Set(key, old) + } + + return diag.Errorf("Action update not implemented for resource : appdata dsource") +} + +func resourceOracleDsourceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(*apiClient).client + + dsourceId := d.Id() + + deleteDsourceParams := dctapi.NewDeleteDSourceRequest(dsourceId) + deleteDsourceParams.SetForce(false) + + res, httpRes, err := client.DSourcesApi.DeleteDsource(ctx).DeleteDSourceRequest(*deleteDsourceParams).Execute() + + if diags := apiErrorResponseHelper(res, httpRes, err); diags != nil { + return diags + } + + job_status, job_err := PollJobStatus(*res.Id, ctx, client) + if job_err != "" { + WarnLog.Printf("Job Polling failed but continuing with deletion. Error :%v", job_err) + } + InfoLog.Printf("Job result is %s", job_status) + if isJobTerminalFailure(job_status) { + return diag.Errorf("[NOT OK] Appdata dSource-Delete %s. JobId: %s / Error: %s", job_status, *res.Id, job_err) + } + + _, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) { + return client.DSourcesApi.GetDsourceById(ctx, dsourceId).Execute() + }) + + return diags +} From 2adc35f9026d371b2622e5f2fb55d21348ff332c Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Fri, 27 Oct 2023 18:07:05 +0530 Subject: [PATCH 02/11] added support for oracle dsource creation/deletion --- examples/{dsource => appdata_dsource}/main.tf | 0 examples/oracle_dsource/main.tf | 48 +++ internal/provider/provider.go | 1 + internal/provider/resource_appdata_dsource.go | 22 +- internal/provider/resource_oracle_dsource.go | 356 ++++++++++++------ 5 files changed, 302 insertions(+), 125 deletions(-) rename examples/{dsource => appdata_dsource}/main.tf (100%) create mode 100644 examples/oracle_dsource/main.tf diff --git a/examples/dsource/main.tf b/examples/appdata_dsource/main.tf similarity index 100% rename from examples/dsource/main.tf rename to examples/appdata_dsource/main.tf diff --git a/examples/oracle_dsource/main.tf b/examples/oracle_dsource/main.tf new file mode 100644 index 0000000..e321011 --- /dev/null +++ b/examples/oracle_dsource/main.tf @@ -0,0 +1,48 @@ +/** +* Summary: This template showcases the properties available when creating an app data dsource. +*/ + +terraform { + required_providers { + delphix = { + version = "VERSION" + source = "delphix-integrations/delphix" + } + } +} + +provider "delphix" { + tls_insecure_skip = true + key = "1.XXXX" + host = "HOSTNAME" +} + + + +resource "delphix_oracle_dsource" "test_oracle_dsource_second" { + name = "test2" + source_value = "DBOMSRB331B3" + group_id = "3-GROUP-1" + log_sync_enabled = false + make_current_account_owner = true + environment_user_id = "HOST_USER-1" + rman_channels = 2 + files_per_set = 5 + check_logical = false + encrypted_linking_enabled = false + compressed_linking_enabled = true + bandwidth_limit = 0 + number_of_connections = 1 + diagnose_no_logging_faults = true + pre_provisioning_enabled = false + link_now = true + force_full_backup = false + double_sync = false + skip_space_check = false + do_not_resume = false + files_for_full_backup = [] + log_sync_mode = "UNDEFINED" + log_sync_interval = 5 +} + + diff --git a/internal/provider/provider.go b/internal/provider/provider.go index d82e4e6..84ca96b 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -63,6 +63,7 @@ func Provider(version string) func() *schema.Provider { "delphix_vdb_group": resourceVdbGroup(), "delphix_environment": resourceEnvironment(), "delphix_appdata_dsource": resourceAppdataDsource(), + "delphix_oracle_dsource": resourceOracleDsource(), }, } diff --git a/internal/provider/resource_appdata_dsource.go b/internal/provider/resource_appdata_dsource.go index 77b9249..c481645 100644 --- a/internal/provider/resource_appdata_dsource.go +++ b/internal/provider/resource_appdata_dsource.go @@ -16,9 +16,9 @@ func resourceAppdataDsource() *schema.Resource { Description: "Resource for appdata dSource creation.", CreateContext: resourceAppdataDsourceCreate, - ReadContext: resourceAppdataDsourceRead, - UpdateContext: resourceAppdataDsourceUpdate, - DeleteContext: resourceAppdataDsourceDelete, + ReadContext: resourceDsourceRead, + UpdateContext: resourceDsourceUpdate, + DeleteContext: resourceDsourceDelete, Schema: map[string]*schema.Schema{ "name": { @@ -472,7 +472,7 @@ func resourceAppdataDsourceCreate(ctx context.Context, d *schema.ResourceData, m return diag.Errorf("[NOT OK] Job %s %s with error %s", *apiRes.Job.Id, job_res, job_err) } - readDiags := resourceAppdataDsourceRead(ctx, d, meta) + readDiags := resourceDsourceRead(ctx, d, meta) if readDiags.HasError() { return readDiags @@ -481,7 +481,7 @@ func resourceAppdataDsourceCreate(ctx context.Context, d *schema.ResourceData, m return diags } -func resourceAppdataDsourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func resourceDsourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*apiClient).client @@ -497,10 +497,10 @@ func resourceAppdataDsourceRead(ctx context.Context, d *schema.ResourceData, met }) // This would imply error in poll for deletion so we just log and exit. if diags != nil { - ErrorLog.Printf("Error in polling of appdata dSource for deletion.") + ErrorLog.Printf("Error in polling of dSource for deletion.") } else { // diags will be nill in case of successful poll for deletion logic aka 404 - ErrorLog.Printf("Error reading the appdata dSource %s, removing from state.", dsource_id) + ErrorLog.Printf("Error reading the dSource %s, removing from state.", dsource_id) d.SetId("") } @@ -531,7 +531,7 @@ func resourceAppdataDsourceRead(ctx context.Context, d *schema.ResourceData, met return diags } -func resourceAppdataDsourceUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func resourceDsourceUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // get the changed keys changedKeys := make([]string, 0, len(d.State().Attributes)) for k := range d.State().Attributes { @@ -545,10 +545,10 @@ func resourceAppdataDsourceUpdate(ctx context.Context, d *schema.ResourceData, m d.Set(key, old) } - return diag.Errorf("Action update not implemented for resource : appdata dsource") + return diag.Errorf("Action update not implemented for resource : dsource") } -func resourceAppdataDsourceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func resourceDsourceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*apiClient).client dsourceId := d.Id() @@ -568,7 +568,7 @@ func resourceAppdataDsourceDelete(ctx context.Context, d *schema.ResourceData, m } InfoLog.Printf("Job result is %s", job_status) if isJobTerminalFailure(job_status) { - return diag.Errorf("[NOT OK] Appdata dSource-Delete %s. JobId: %s / Error: %s", job_status, *res.Id, job_err) + return diag.Errorf("[NOT OK] dSource-Delete %s. JobId: %s / Error: %s", job_status, *res.Id, job_err) } _, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) { diff --git a/internal/provider/resource_oracle_dsource.go b/internal/provider/resource_oracle_dsource.go index 054bbd9..14166a5 100644 --- a/internal/provider/resource_oracle_dsource.go +++ b/internal/provider/resource_oracle_dsource.go @@ -2,7 +2,6 @@ package provider import ( "context" - "net/http" dctapi "github.com/delphix/dct-sdk-go/v10" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -15,16 +14,16 @@ func resourceOracleDsource() *schema.Resource { Description: "Resource for Oracle dSource creation.", CreateContext: resourceOracleDsourceCreate, - ReadContext: resourceOracleDsourceRead, - UpdateContext: resourceOracleDsourceUpdate, - DeleteContext: resourceOracleDsourceDelete, + ReadContext: resourceDsourceRead, + UpdateContext: resourceDsourceUpdate, + DeleteContext: resourceDsourceDelete, Schema: map[string]*schema.Schema{ "name": { Type: schema.TypeString, Optional: true, }, - "source_id": { + "source_value": { Type: schema.TypeString, Required: true, }, @@ -204,11 +203,11 @@ func resourceOracleDsource() *schema.Resource { }, "external_file_path": { Type: schema.TypeString, - Required: true, + Optional: true, }, "environment_user_id": { Type: schema.TypeString, - Required: true, + Optional: true, }, "backup_level_enabled": { Type: schema.TypeBool, @@ -220,19 +219,245 @@ func resourceOracleDsource() *schema.Resource { }, "files_per_set": { Type: schema.TypeInt, - Required: true, + Optional: true, }, "check_logical": { Type: schema.TypeBool, Optional: true, }, - ////////////////////////////TODO ADD REMAINING INPUTS///// + "encrypted_linking_enabled": { + Type: schema.TypeBool, + Optional: true, + }, + "compressed_linking_enabled": { + Type: schema.TypeBool, + Optional: true, + }, + "bandwidth_limit": { + Type: schema.TypeInt, + Optional: true, + }, + "number_of_connections": { + Type: schema.TypeInt, + Optional: true, + }, + "diagnose_no_logging_faults": { + Type: schema.TypeBool, + Optional: true, + }, + "pre_provisioning_enabled": { + Type: schema.TypeBool, + Optional: true, + }, + "link_now": { + Type: schema.TypeBool, + Optional: true, + }, + "force_full_backup": { + Type: schema.TypeBool, + Optional: true, + }, + "double_sync": { + Type: schema.TypeBool, + Optional: true, + }, + "skip_space_check": { + Type: schema.TypeBool, + Optional: true, + }, + "do_not_resume": { + Type: schema.TypeBool, + Optional: true, + }, + "files_for_full_backup": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeInt, + }, + }, + "log_sync_mode": { + Type: schema.TypeString, + Optional: true, + }, + + "log_sync_interval": { + Type: schema.TypeInt, + Optional: true, + }, + "non_sys_username": { + Type: schema.TypeString, + Optional: true, + }, + + "non_sys_password": { + Type: schema.TypeString, + Optional: true, + }, + + "non_sys_vault": { + Type: schema.TypeString, + Optional: true, + }, + + "non_sys_hashicorp_vault_engine": { + Type: schema.TypeString, + Optional: true, + }, + + "non_sys_hashicorp_vault_secret_path": { + Type: schema.TypeString, + Optional: true, + }, + "non_sys_hashicorp_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "non_sys_hashicorp_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "non_sys_azure_vault_name": { + Type: schema.TypeString, + Optional: true, + }, + "non_sys_azure_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "non_sys_azure_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "non_sys_cyberark_vault_query_string": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_username": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_password": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_vault": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_hashicorp_vault_engine": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_hashicorp_vault_secret_path": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_hashicorp_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_hashicorp_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_azure_vault_name": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_azure_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_azure_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "fallback_cyberark_vault_query_string": { + Type: schema.TypeString, + Optional: true, + }, + "ops_pre_log_sync": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + }, + "command": { + Type: schema.TypeString, + Optional: true, + }, + "shell": { + Type: schema.TypeString, + Optional: true, + }, "credentials_env_vars": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "base_var_name": { + Type: schema.TypeString, + Required: true, + }, + "password": { + Type: schema.TypeString, + Optional: true, + }, + "vault": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_engine": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_secret_path": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "hashicorp_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "azure_vault_name": { + Type: schema.TypeString, + Optional: true, + }, + "azure_vault_username_key": { + Type: schema.TypeString, + Optional: true, + }, + "azure_vault_secret_key": { + Type: schema.TypeString, + Optional: true, + }, + "cyberark_vault_query_string": { + Type: schema.TypeString, + Optional: true, + }, + }, + }, + }, + }, + }, + }, // Output "id": { Type: schema.TypeString, Computed: true, }, + "source_id": { + Type: schema.TypeString, + Computed: true, + }, "database_type": { Type: schema.TypeString, Computed: true, @@ -318,7 +543,7 @@ func resourceOracleDsourceCreate(ctx context.Context, d *schema.ResourceData, me if v, has_v := d.GetOk("name"); has_v { oracleDSourceLinkSourceParameters.SetName(v.(string)) } - if v, has_v := d.GetOk("source_id"); has_v { + if v, has_v := d.GetOk("source_value"); has_v { oracleDSourceLinkSourceParameters.SetSourceId(v.(string)) } if v, has_v := d.GetOk("group_id"); has_v { @@ -352,10 +577,10 @@ func resourceOracleDsourceCreate(ctx context.Context, d *schema.ResourceData, me oracleDSourceLinkSourceParameters.SetBackupLevelEnabled(v.(bool)) } if v, has_v := d.GetOk("rman_channels"); has_v { - oracleDSourceLinkSourceParameters.SetRmanChannels(v.(int32)) + oracleDSourceLinkSourceParameters.SetRmanChannels(int32(v.(int))) } if v, has_v := d.GetOk("files_per_set"); has_v { - oracleDSourceLinkSourceParameters.SetFilesPerSet(v.(int32)) + oracleDSourceLinkSourceParameters.SetFilesPerSet(int32(v.(int))) } if v, has_v := d.GetOkExists("check_logical"); has_v { oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) @@ -367,10 +592,10 @@ func resourceOracleDsourceCreate(ctx context.Context, d *schema.ResourceData, me oracleDSourceLinkSourceParameters.SetCompressedLinkingEnabled(v.(bool)) } if v, has_v := d.GetOk("bandwidth_limit"); has_v { - oracleDSourceLinkSourceParameters.SetBandwidthLimit(v.(int32)) + oracleDSourceLinkSourceParameters.SetBandwidthLimit(int32(v.(int))) } if v, has_v := d.GetOk("number_of_connections"); has_v { - oracleDSourceLinkSourceParameters.SetNumberOfConnections(v.(int32)) + oracleDSourceLinkSourceParameters.SetNumberOfConnections(int32(v.(int))) } if v, has_v := d.GetOkExists("diagnose_no_logging_faults"); has_v { oracleDSourceLinkSourceParameters.SetCheckLogical(v.(bool)) @@ -400,7 +625,7 @@ func resourceOracleDsourceCreate(ctx context.Context, d *schema.ResourceData, me oracleDSourceLinkSourceParameters.SetLogSyncMode(v.(string)) } if v, has_v := d.GetOk("log_sync_interval"); has_v { - oracleDSourceLinkSourceParameters.SetLogSyncInterval(v.(int32)) + oracleDSourceLinkSourceParameters.SetLogSyncInterval(int32(v.(int))) } if v, has_v := d.GetOk("non_sys_username"); has_v { oracleDSourceLinkSourceParameters.SetNonSysUsername(v.(string)) @@ -500,7 +725,7 @@ func resourceOracleDsourceCreate(ctx context.Context, d *schema.ResourceData, me return diag.Errorf("[NOT OK] Job %s %s with error %s", *apiRes.Job.Id, job_res, job_err) } - readDiags := resourceOracleDsourceRead(ctx, d, meta) + readDiags := resourceDsourceRead(ctx, d, meta) if readDiags.HasError() { return readDiags @@ -512,104 +737,7 @@ func resourceOracleDsourceCreate(ctx context.Context, d *schema.ResourceData, me func toIntArray(array interface{}) []int32 { items := []int32{} for _, item := range array.([]interface{}) { - items = append(items, item.(int32)) + items = append(items, int32(item.(int))) } return items } - -func resourceOracleDsourceRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - - client := meta.(*apiClient).client - - dsource_id := d.Id() - - res, diags := PollForObjectExistence(func() (interface{}, *http.Response, error) { - return client.DSourcesApi.GetDsourceById(ctx, dsource_id).Execute() - }) - - if diags != nil { - _, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) { - return client.DSourcesApi.GetDsourceById(ctx, dsource_id).Execute() - }) - // This would imply error in poll for deletion so we just log and exit. - if diags != nil { - ErrorLog.Printf("Error in polling of appdata dSource for deletion.") - } else { - // diags will be nill in case of successful poll for deletion logic aka 404 - ErrorLog.Printf("Error reading the appdata dSource %s, removing from state.", dsource_id) - d.SetId("") - } - - return nil - } - - result, ok := res.(*dctapi.DSource) - if !ok { - return diag.Errorf("Error occured in type casting.") - } - - d.Set("id", result.GetId()) - d.Set("database_type", result.GetDatabaseType()) - d.Set("name", result.GetName()) - d.Set("is_replica", result.GetIsReplica()) - d.Set("storage_size", result.GetStorageSize()) - d.Set("plugin_version", result.GetPluginVersion()) - d.Set("creation_date", result.GetCreationDate().String()) - d.Set("group_name", result.GetGroupName()) - d.Set("enabled", result.GetEnabled()) - d.Set("engine_id", result.GetEngineId()) - d.Set("source_id", result.GetSourceId()) - d.Set("status", result.GetStatus()) - d.Set("engine_name", result.GetEngineName()) - d.Set("current_timeflow_id", result.GetCurrentTimeflowId()) - d.Set("is_appdata", result.GetIsAppdata()) - - return diags -} - -func resourceOracleDsourceUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - // get the changed keys - changedKeys := make([]string, 0, len(d.State().Attributes)) - for k := range d.State().Attributes { - if d.HasChange(k) { - changedKeys = append(changedKeys, k) - } - } - // revert and set the old value to the changed keys - for _, key := range changedKeys { - old, _ := d.GetChange(key) - d.Set(key, old) - } - - return diag.Errorf("Action update not implemented for resource : appdata dsource") -} - -func resourceOracleDsourceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - client := meta.(*apiClient).client - - dsourceId := d.Id() - - deleteDsourceParams := dctapi.NewDeleteDSourceRequest(dsourceId) - deleteDsourceParams.SetForce(false) - - res, httpRes, err := client.DSourcesApi.DeleteDsource(ctx).DeleteDSourceRequest(*deleteDsourceParams).Execute() - - if diags := apiErrorResponseHelper(res, httpRes, err); diags != nil { - return diags - } - - job_status, job_err := PollJobStatus(*res.Id, ctx, client) - if job_err != "" { - WarnLog.Printf("Job Polling failed but continuing with deletion. Error :%v", job_err) - } - InfoLog.Printf("Job result is %s", job_status) - if isJobTerminalFailure(job_status) { - return diag.Errorf("[NOT OK] Appdata dSource-Delete %s. JobId: %s / Error: %s", job_status, *res.Id, job_err) - } - - _, diags := PollForObjectDeletion(func() (interface{}, *http.Response, error) { - return client.DSourcesApi.GetDsourceById(ctx, dsourceId).Execute() - }) - - return diags -} From 304d55c489311fc33e811a7d5a53c435d618be04 Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Fri, 27 Oct 2023 18:47:01 +0530 Subject: [PATCH 03/11] Added MD file --- docs/resources/oracle_dsource.md | 197 +++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 docs/resources/oracle_dsource.md diff --git a/docs/resources/oracle_dsource.md b/docs/resources/oracle_dsource.md new file mode 100644 index 0000000..8545020 --- /dev/null +++ b/docs/resources/oracle_dsource.md @@ -0,0 +1,197 @@ +# Resource: delphix_oracle_dsource + +In Delphix terminology, a dSource is a database that the Delphix Continuous Data Engine uses to create and update virtual copies of your database. +A dSource is created and managed by the Delphix Continuous Data Engine. + +The dSource resource allows Terraform to create and delete Delphix dSources. This specifically enables the apply and destroy Terraform commands. Modification of existing dSource resources via the apply command is not supported. All supported parameters are listed below. + +## System Requirements + +* Data Control Tower v10.0.1+ is required for dSource management. Lower versions are not supported. +* The dSource Resource does not support SQL Server, or SAP ASE. The below examples are shown from the Oracle context. + +## Example Usage + +The linking of a dSource can be configured through various ingestion approaches. Each configuration is customized to the connector and its supported options. The three PostgreSQL parameter sets below show working examples. + +```hcl +# Link dSource + +resource "delphix_oracle_dsource" "test_oracle_dsource_second" { + name = "test2" + source_value = "DBOMSRB331B3" + group_id = "3-GROUP-1" + log_sync_enabled = false + make_current_account_owner = true + environment_user_id = "HOST_USER-1" + rman_channels = 2 + files_per_set = 5 + check_logical = false + encrypted_linking_enabled = false + compressed_linking_enabled = true + bandwidth_limit = 0 + number_of_connections = 1 + diagnose_no_logging_faults = true + pre_provisioning_enabled = false + link_now = true + force_full_backup = false + double_sync = false + skip_space_check = false + do_not_resume = false + files_for_full_backup = [] + log_sync_mode = "UNDEFINED" + log_sync_interval = 5 +} +``` + +## Argument Reference + +* `source_value` - (Required) Id or Name of the source to link. + +* `group_id` - (Required) Id of the dataset group where this dSource should belong to. + +* `log_sync_enabled` - (Required) True if LogSync should run for this database. + +* `make_current_account_owner` - (Required) Whether the account creating this reporting schedule must be configured as owner of the reporting schedule. + +* `description` - (Optional) The notes/description for the dSource. + +* `external_file_path` - (Optional) External file path. + +* `environment_user_id` - (Optional) Id of the environment user to use for linking. + +* `backup_level_enabled` - (Optional) Boolean value indicates whether LEVEL-based incremental backups can be used on the source database. + +* `rman_channels` - (Optional) Number of parallel channels to use. + +* `files_per_set` - (Optional) Number of data files to include in each RMAN backup set. + +* `check_logical` - (Optional) True if extended block checking should be used for this linked database. + +* `encrypted_linking_enabled` - (Optional) True if SnapSync data from the source should be retrieved through an encrypted connection. Enabling this feature can decrease the performance of SnapSync from the source but has no impact on the performance of VDBs created from the retrieved data. + +* `compressed_linking_enabled` - (Optional) True if SnapSync data from the source should be compressed over the network. Enabling this feature will reduce network bandwidth consumption and may significantly improve throughput, especially over slow network. + +* `bandwidth_limit` - (Optional) Bandwidth limit (MB/s) for SnapSync and LogSync network traffic. A value of 0 means no limit. + +* `number_of_connections` - (Optional) Total number of transport connections to use during SnapSync. + +* `diagnose_no_logging_faults` - (Optional) If true, NOLOGGING operations on this container are treated as faults and cannot be resolved manually. + +* `pre_provisioning_enabled` - (Optional) If true, pre-provisioning will be performed after every sync. + +* `link_now` - (Optional) True if initial load should be done immediately. + +* `force_full_backup` - (Optional) Whether or not to take another full backup of the source database. + +* `double_sync` - (Optional) True if two SnapSyncs should be performed in immediate succession to reduce the number of logs required to provision the snapshot. This may significantly reduce the time necessary to provision from a snapshot. + +* `skip_space_check` - (Optional) Skip check that tests if there is enough space available to store the database in the Delphix Engine. The Delphix Engine estimates how much space a database will occupy after compression and prevents SnapSync if insufficient space is available. This safeguard can be overridden using this option. This may be useful when linking highly compressible databases. + +* `do_not_resume` - (Optional) Indicates whether a fresh SnapSync must be started regardless if it was possible to resume the current SnapSync. If true, we will not resume but instead ignore previous progress and backup all datafiles even if already completed from previous failed SnapSync. This does not force a full backup, if an incremental was in progress this will start a new incremental snapshot. + +* `files_for_full_backup` - (Optional) List of datafiles to take a full backup of. This would be useful in situations where certain datafiles could not be backed up during previous SnapSync due to corruption or because they went offline. + +* `log_sync_mode` - (Optional) LogSync operation mode for this database [ ARCHIVE_ONLY_MODE, ARCHIVE_REDO_MODE, UNDEFINED ]. + +* `log_sync_interval` - (Optional) Interval between LogSync requests, in seconds. + +* `non_sys_password` - (Optional) Password for non sys user authentication (Single tenant only). + +* `non_sys_username` - (Optional) Non-SYS database user to access this database. Only required for username-password auth (Single tenant only). + +* `non_sys_vault` - (Optional) The name or reference of the vault from which to read the database credentials (Single tenant only). + +* `non_sys_hashicorp_vault_engine` - (Optional) Vault engine name where the credential is stored (Single tenant only). + +* `non_sys_hashicorp_vault_secret_path` - (Optional) Path in the vault engine where the credential is stored (Single tenant only). + +* `non_sys_hashicorp_vault_username_key` - (Optional) Hashicorp vault key for the username in the key-value store (Single tenant only). + +* `non_sys_hashicorp_vault_secret_key` - (Optional) Hashicorp vault key for the password in the key-value store (Single tenant only). + +* `non_sys_azure_vault_name` - (Optional) Azure key vault name (Single tenant only). + +* `non_sys_azure_vault_username_key` - (Optional) Azure vault key for the username in the key-value store (Single tenant only). + +* `non_sys_azure_vault_secret_key` - (Optional) Azure vault key for the password in the key-value store (Single tenant only). + +* `non_sys_cyberark_vault_query_string` - (Optional) Query to find a credential in the CyberArk vault (Single tenant only). + +* `fallback_username` - (Optional) The database fallback username. Optional if bequeath connections are enabled (to be used in case of bequeath connection failures). Only required for username-password auth.. + +* `fallback_password` - (Optional) Password for fallback username. + +* `fallback_vault` - (Optional) The name or reference of the vault from which to read the database credentials. + +* `fallback_hashicorp_vault_engine` - (Optional) Vault engine name where the credential is stored. + +* `fallback_hashicorp_vault_secret_path` - (Optional) Path in the vault engine where the credential is stored. + +* `fallback_hashicorp_vault_username_key` - (Optional) Hashicorp vault key for the username in the key-value store. + +* `fallback_hashicorp_vault_secret_key` - (Optional) Hashicorp vault key for the password in the key-value store. + +* `fallback_azure_vault_name` - (Optional) Azure key vault name. + +* `fallback_azure_vault_username_key` - (Optional) Azure vault key for the username in the key-value store. + +* `fallback_azure_vault_secret_key` - (Optional) Azure vault key for the password in the key-value store. + +* `fallback_cyberark_vault_query_string` - (Optional) Query to find a credential in the CyberArk vault. + +* `tags` - (Optional) The tags to be created for dSource. This is a map of 2 parameters: + * `key` - (Required) Key of the tag + * `value` - (Required) Value of the tag + +* `ops_pre_log_sync` - (Optional) Operations to perform after syncing a created dSource and before running the LogSync. + * `name` - Name of the hook + * `command` - Command to be executed + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `credentials_env_vars` - List of environment variables that will contain credentials for this operation + * `base_var_name` - Base name of the environment variables. Variables are named by appending '_USER', '_PASSWORD', '_PUBKEY' and '_PRIVKEY' to this base name, respectively. Variables whose values are not entered or are not present in the type of credential or vault selected, will not be set. + * `password` - Password to assign to the environment variables. + * `vault` - The name or reference of the vault to assign to the environment variables. + * `hashicorp_vault_engine` - Vault engine name where the credential is stored. + * `hashicorp_vault_secret_path` - Path in the vault engine where the credential is stored. + * `hashicorp_vault_username_key` - Hashicorp vault key for the username in the key-value store. + * `hashicorp_vault_secret_key` - Hashicorp vault key for the password in the key-value store. + * `azure_vault_name` - Azure key vault name. + * `azure_vault_username_key` - Azure vault key in the key-value store. + * `azure_vault_secret_key` - Azure vault key in the key-value store. + * `cyberark_vault_query_string` - Query to find a credential in the CyberArk vault. + +* `ops_pre_sync` - (Optional) Operations to perform before syncing the created dSource. These operations can quiesce any data prior to syncing + * `name` - Name of the hook + * `command` - Command to be executed + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `credentials_env_vars` - List of environment variables that will contain credentials for this operation + * `base_var_name` - Base name of the environment variables. Variables are named by appending '_USER', '_PASSWORD', '_PUBKEY' and '_PRIVKEY' to this base name, respectively. Variables whose values are not entered or are not present in the type of credential or vault selected, will not be set. + * `password` - Password to assign to the environment variables. + * `vault` - The name or reference of the vault to assign to the environment variables. + * `hashicorp_vault_engine` - Vault engine name where the credential is stored. + * `hashicorp_vault_secret_path` - Path in the vault engine where the credential is stored. + * `hashicorp_vault_username_key` - Hashicorp vault key for the username in the key-value store. + * `hashicorp_vault_secret_key` - Hashicorp vault key for the password in the key-value store. + * `azure_vault_name` - Azure key vault name. + * `azure_vault_username_key` - Azure vault key in the key-value store. + * `azure_vault_secret_key` - Azure vault key in the key-value store. + * `cyberark_vault_query_string` - Query to find a credential in the CyberArk vault. + +* `ops_post_sync` - (Optional) Operations to perform after syncing a created dSource. + * `name` - Name of the hook + * `command` - Command to be executed + * `shell` - Type of shell. Valid values are `[bash, shell, expect, ps, psd]` + * `credentials_env_vars` - List of environment variables that will contain credentials for this operation + * `base_var_name` - Base name of the environment variables. Variables are named by appending '_USER', '_PASSWORD', '_PUBKEY' and '_PRIVKEY' to this base name, respectively. Variables whose values are not entered or are not present in the type of credential or vault selected, will not be set. + * `password` - Password to assign to the environment variables. + * `vault` - The name or reference of the vault to assign to the environment variables. + * `hashicorp_vault_engine` - Vault engine name where the credential is stored. + * `hashicorp_vault_secret_path` - Path in the vault engine where the credential is stored. + * `hashicorp_vault_username_key` - Hashicorp vault key for the username in the key-value store. + * `hashicorp_vault_secret_key` - Hashicorp vault key for the password in the key-value store. + * `azure_vault_name` - Azure key vault name. + * `azure_vault_username_key` - Azure vault key in the key-value store. + * `azure_vault_secret_key` - Azure vault key in the key-value store. + * `cyberark_vault_query_string` - Query to find a credential in the CyberArk vault. + From 06179bcfee58951fee0c754cfe80f63d04d68e91 Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Tue, 31 Oct 2023 16:52:33 +0530 Subject: [PATCH 04/11] addressed review comments --- docs/resources/appdata_dsource.md | 4 ++-- docs/resources/oracle_dsource.md | 10 ++++------ examples/oracle_dsource/main.tf | 2 +- internal/provider/resource_appdata_dsource.go | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/resources/appdata_dsource.md b/docs/resources/appdata_dsource.md index f3cae9f..8eae530 100644 --- a/docs/resources/appdata_dsource.md +++ b/docs/resources/appdata_dsource.md @@ -3,12 +3,12 @@ In Delphix terminology, a dSource is a database that the Delphix Continuous Data Engine uses to create and update virtual copies of your database. A dSource is created and managed by the Delphix Continuous Data Engine. -The dSource resource allows Terraform to create and delete Delphix dSources. This specifically enables the apply and destroy Terraform commands. Modification of existing dSource resources via the apply command is not supported. All supported parameters are listed below. +The Appdata dSource resource allows Terraform to create and delete AppData dSources. This specifically enables the apply and destroy Terraform commands. Modification of existing dSource resources via the apply command is not supported. All supported parameters are listed below. ## System Requirements * Data Control Tower v10.0.1+ is required for dSource management. Lower versions are not supported. -* The dSource Resource does not support Oracle, SQL Server, or SAP ASE. The below examples are shown from the PostgreSQL context. The parameters values can be updated for other connectors (i.e. AppData), such as SAP HANA, IBM Db2, etc. +* This Appdata dSource Resource only supports Appdata based datasources , such as POSTGRES,SAP HANA, IBM Db2, etc.The below examples are shown from the PostgreSQL context. See the Oracle dSource Resource for the support of Oracle. The Delphix Provider does not support Oracle, SQL Server, or SAP ASE. ## Example Usage diff --git a/docs/resources/oracle_dsource.md b/docs/resources/oracle_dsource.md index 8545020..add3258 100644 --- a/docs/resources/oracle_dsource.md +++ b/docs/resources/oracle_dsource.md @@ -3,21 +3,19 @@ In Delphix terminology, a dSource is a database that the Delphix Continuous Data Engine uses to create and update virtual copies of your database. A dSource is created and managed by the Delphix Continuous Data Engine. -The dSource resource allows Terraform to create and delete Delphix dSources. This specifically enables the apply and destroy Terraform commands. Modification of existing dSource resources via the apply command is not supported. All supported parameters are listed below. +The Oracle dSource resource allows Terraform to create and delete Oracle dSources. This specifically enables the apply and destroy Terraform commands. Modification of existing dSource resources via the apply command is not supported. All supported parameters are listed below. ## System Requirements * Data Control Tower v10.0.1+ is required for dSource management. Lower versions are not supported. -* The dSource Resource does not support SQL Server, or SAP ASE. The below examples are shown from the Oracle context. +* This Oracle dSource Resource only supports Oracle. See the AppData dSource Resource for the support of other connectors (i.e. AppData), such as PostgreSQL and SAP HANA. The Delphix Provider does not support SQL Server or SAP ASE. ## Example Usage -The linking of a dSource can be configured through various ingestion approaches. Each configuration is customized to the connector and its supported options. The three PostgreSQL parameter sets below show working examples. - ```hcl -# Link dSource +# Link Oracle dSource -resource "delphix_oracle_dsource" "test_oracle_dsource_second" { +resource "delphix_oracle_dsource" "test_oracle_dsource" { name = "test2" source_value = "DBOMSRB331B3" group_id = "3-GROUP-1" diff --git a/examples/oracle_dsource/main.tf b/examples/oracle_dsource/main.tf index e321011..0d0139d 100644 --- a/examples/oracle_dsource/main.tf +++ b/examples/oracle_dsource/main.tf @@ -19,7 +19,7 @@ provider "delphix" { -resource "delphix_oracle_dsource" "test_oracle_dsource_second" { +resource "delphix_oracle_dsource" "test_oracle_dsource" { name = "test2" source_value = "DBOMSRB331B3" group_id = "3-GROUP-1" diff --git a/internal/provider/resource_appdata_dsource.go b/internal/provider/resource_appdata_dsource.go index c481645..c6f771c 100644 --- a/internal/provider/resource_appdata_dsource.go +++ b/internal/provider/resource_appdata_dsource.go @@ -545,7 +545,7 @@ func resourceDsourceUpdate(ctx context.Context, d *schema.ResourceData, meta int d.Set(key, old) } - return diag.Errorf("Action update not implemented for resource : dsource") + return diag.Errorf("Action update not implemented for resource : dSource") } func resourceDsourceDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { From 084ff5e282105aadddf2acaad0b307325b067e78 Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Tue, 31 Oct 2023 17:00:46 +0530 Subject: [PATCH 05/11] minor update --- docs/resources/oracle_dsource.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/resources/oracle_dsource.md b/docs/resources/oracle_dsource.md index add3258..026c651 100644 --- a/docs/resources/oracle_dsource.md +++ b/docs/resources/oracle_dsource.md @@ -12,6 +12,8 @@ The Oracle dSource resource allows Terraform to create and delete Oracle dSource ## Example Usage +* The linking of a dSource can be performed via direct ingestion as shown in the example below + ```hcl # Link Oracle dSource From 7da0585d430d5c8857d5c473de438dc3a5fc8e5b Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Wed, 1 Nov 2023 15:21:34 +0530 Subject: [PATCH 06/11] Added unite test cases --- examples/oracle_dsource/main.tf | 29 +++- .../provider/resource_oracle_dsource_test.go | 143 ++++++++++++++++++ 2 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 internal/provider/resource_oracle_dsource_test.go diff --git a/examples/oracle_dsource/main.tf b/examples/oracle_dsource/main.tf index 0d0139d..d1e8bd4 100644 --- a/examples/oracle_dsource/main.tf +++ b/examples/oracle_dsource/main.tf @@ -22,7 +22,7 @@ provider "delphix" { resource "delphix_oracle_dsource" "test_oracle_dsource" { name = "test2" source_value = "DBOMSRB331B3" - group_id = "3-GROUP-1" + group_id = "4-GROUP-1" log_sync_enabled = false make_current_account_owner = true environment_user_id = "HOST_USER-1" @@ -43,6 +43,33 @@ resource "delphix_oracle_dsource" "test_oracle_dsource" { files_for_full_backup = [] log_sync_mode = "UNDEFINED" log_sync_interval = 5 + ops_pre_sync { + name = "key-1" + command = "echo \"hello world\"" + shell = "shell" + credentials_env_vars { + base_var_name = "XXXX" + password = "XXXX" + } + } + ops_post_sync { + name = "key-2" + command = "echo \"hello world\"" + shell = "shell" + credentials_env_vars { + base_var_name = "XXXX" + password = "XXXX" + } + } + ops_pre_log_sync { + name = "key-2" + command = "echo \"hello world\"" + shell = "shell" + credentials_env_vars { + base_var_name = "XXXX" + password = "XXXX" + } + } } diff --git a/internal/provider/resource_oracle_dsource_test.go b/internal/provider/resource_oracle_dsource_test.go new file mode 100644 index 0000000..8ba5100 --- /dev/null +++ b/internal/provider/resource_oracle_dsource_test.go @@ -0,0 +1,143 @@ +package provider + +import ( + "context" + "fmt" + "os" + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestOracleDsource_create_positive(t *testing.T) { + sourcevalue := os.Getenv("ORACLE_DSOURCE_SOURCE_VALUE") + groupId := os.Getenv("ORACLE_DSOURCE_GROUP_ID") + name := os.Getenv("ORACLE_DSOURCE_NAME") + environmentUser := os.Getenv("ORACLE_DSOURCE_ENV_USER") + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testOracleDsourcePreCheck(t, sourcevalue, groupId, name, environmentUser) + }, + Providers: testAccProviders, + CheckDestroy: testDsourceDestroy, + Steps: []resource.TestStep{ + { + Config: testOracleDsourceBasic(name, "", groupId, environmentUser), + ExpectError: regexp.MustCompile(`.*`), + }, + { + Config: testOracleDsourceBasic(name, sourcevalue, groupId, environmentUser), + Check: resource.ComposeTestCheckFunc( + testOracleDsourceExists("delphix_oracle_dsource.test_oracle_dsource", sourcevalue), + resource.TestCheckResourceAttr("delphix_oracle_dsource.test_oracle_dsource", "source_id", sourcevalue)), + }, + { + Config: testOracleDsourceBasic("update_name", sourcevalue, groupId, environmentUser), + Check: resource.ComposeAggregateTestCheckFunc( + // irrelevant + ), + ExpectError: regexp.MustCompile(`.*`), + }, + }, + }) +} + +func testOracleDsourcePreCheck(t *testing.T, sourceId string, groupId string, name string, environmentUser string) { + testAccPreCheck(t) + if sourceId == "" { + t.Fatal("ORACLE_DSOURCE_SOURCE_VALUE must be set for env acceptance tests") + } + if groupId == "" { + t.Fatal("ORACLE_DSOURCE_GROUP_ID must be set for env acceptance tests") + } + if name == "" { + t.Fatal("ORACLE_DSOURCE_NAME must be set for env acceptance tests") + } + if environmentUser == "" { + t.Fatal("ORACLE_DSOURCE_ENV_USER must be set for env acceptance tests") + } +} + +func testOracleDsourceBasic(name string, sourceValue string, groupId string, environmentUser string) string { + return fmt.Sprintf(` +resource "delphix_oracle_dsource" "test_oracle_dsource" { + name = "%s" + source_value = "%s" + group_id = "%s" + log_sync_enabled = false + make_current_account_owner = true + environment_user_id = "%s" + rman_channels = 2 + files_per_set = 5 + check_logical = false + encrypted_linking_enabled = false + compressed_linking_enabled = true + bandwidth_limit = 0 + number_of_connections = 1 + diagnose_no_logging_faults = true + pre_provisioning_enabled = false + link_now = true + force_full_backup = false + double_sync = false + skip_space_check = false + do_not_resume = false + files_for_full_backup = [] + log_sync_mode = "UNDEFINED" + log_sync_interval = 5 +} + `, name, sourceValue, groupId, environmentUser) +} + +func testOracleDsourceExists(n string, sourceValue string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + dsourceId := rs.Primary.ID + if dsourceId == "" { + return fmt.Errorf("No dsourceId set") + } + + client := testAccProvider.Meta().(*apiClient).client + res, _, err := client.DSourcesApi.GetDsourceById(context.Background(), dsourceId).Execute() + if err != nil { + return err + } + + resSourceId := res.GetSourceId() + if resSourceId != sourceValue { + return fmt.Errorf("SourceId mismatch") + } + + return nil + } +} + +func testOracleDsourceDestroy(s *terraform.State) error { + client := testAccProvider.Meta().(*apiClient).client + + for _, rs := range s.RootModule().Resources { + if rs.Type != "delphix_oracle_dsource" { + continue + } + + dsourceId := rs.Primary.ID + + _, httpResp, _ := client.DSourcesApi.GetDsourceById(context.Background(), dsourceId).Execute() + if httpResp == nil { + return fmt.Errorf("Dsource has not been deleted") + } + + if httpResp.StatusCode != 404 { + return fmt.Errorf("Exepcted a 404 Not Found for a deleted Dsource but got %d", httpResp.StatusCode) + } + } + + return nil +} From 4a46b3f3b08655f2b00f6fe39842deb3c2dfe564 Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Wed, 15 Nov 2023 13:44:24 +0530 Subject: [PATCH 07/11] added example for vdb_group based on fedex usecase --- examples/vdb_group/main.tf | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 examples/vdb_group/main.tf diff --git a/examples/vdb_group/main.tf b/examples/vdb_group/main.tf new file mode 100644 index 0000000..69b3098 --- /dev/null +++ b/examples/vdb_group/main.tf @@ -0,0 +1,43 @@ +/** +* Summary: This template showcases the properties available when creating an app data dsource. +*/ + +terraform { + required_providers { + delphix = { + version = "VERSION" + source = "delphix-integrations/delphix" + } + } +} + +provider "delphix" { + tls_insecure_skip = true + key = "1.XXXX" + host = "HOSTNAME" +} + + +locals { + vdbs = { + "vdb4" = { snapshot_id = "6-ORACLE_DB_CONTAINER-21", name = "us4" }, + "vdb5" = { snapshot_id = "6-ORACLE_DB_CONTAINER-23", name = "us5" }, + "vdb1" = { snapshot_id = "6-ORACLE_DB_CONTAINER-7", name = "us1" }, + "vdb2" = { snapshot_id = "6-ORACLE_DB_CONTAINER-1", name = "us2" }, + "vdb3" = { snapshot_id = "6-ORACLE_DB_CONTAINER-5", name = "us3" } + } +} + +resource "delphix_vdb" "example" { + for_each = try(local.vdbs, {}) + name = each.value.name + source_data_id = each.value.snapshot_id + auto_select_repository = true + +} + +#sort helps to maintain thr order of the vdbs to avoid erroneous drift +resource "delphix_vdb_group" "this" { + name = "random" + vdb_ids = sort(flatten([for vdb in delphix_vdb.example : vdb.id])) +} From 3b37747bbd630a0071c146593303966d26943b2d Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Wed, 15 Nov 2023 13:47:13 +0530 Subject: [PATCH 08/11] updated version for oracle dsource support --- .goreleaser.yml | 2 +- GNUmakefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index ca848b7..1ec7de7 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,7 +1,7 @@ # Visit https://goreleaser.com for documentation on how to customize this # behavior. env: - - PROVIDER_VERSION=3.0.0 + - PROVIDER_VERSION=3.1.0 before: hooks: # this is just an example and not a requirement for provider building/publishing diff --git a/GNUmakefile b/GNUmakefile index 1eac906..01230fc 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,7 @@ HOSTNAME=delphix.com NAMESPACE=dct NAME=delphix BINARY=terraform-provider-${NAME} -VERSION=3.0.0 +VERSION=3.1.0 OS_ARCH=darwin_amd64 default: install From 12f19cf3fa4f283c18d506b1ea513d13b4b8bc4f Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Wed, 15 Nov 2023 20:52:36 +0530 Subject: [PATCH 09/11] dependabot changes --- go.mod | 10 +++++----- go.sum | 15 ++++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index b67d5ad..e9ce4ce 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.7.0 // indirect - github.com/google/go-cmp v0.5.8 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -48,14 +48,14 @@ require ( golang.org/x/crypto v0.1.0 // indirect golang.org/x/sys v0.5.0 // indirect golang.org/x/text v0.7.0 // indirect - google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect - google.golang.org/grpc v1.45.0 // indirect + google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect + google.golang.org/grpc v1.53.0 // indirect ) require ( github.com/golang/protobuf v1.5.2 // indirect github.com/hashicorp/terraform-plugin-sdk/v2 v2.12.0 golang.org/x/net v0.7.0 // indirect - google.golang.org/appengine v1.6.6 // indirect - google.golang.org/protobuf v1.27.1 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/protobuf v1.28.1 // indirect ) diff --git a/go.sum b/go.sum index 5913c40..b31466d 100644 --- a/go.sum +++ b/go.sum @@ -159,8 +159,9 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -589,8 +590,9 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -623,8 +625,9 @@ google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d h1:92D1fum1bJLKSdr11OJ+54YeCMCGYIygTA7R/YZxH5M= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= +google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -642,8 +645,9 @@ google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= +google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -656,8 +660,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From ddaaaa297d05f5f3999b427743e2e9b7045e1eb9 Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Wed, 15 Nov 2023 20:55:32 +0530 Subject: [PATCH 10/11] updated version in example files --- examples/simple-provision/versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/simple-provision/versions.tf b/examples/simple-provision/versions.tf index fb454d5..30df7b0 100644 --- a/examples/simple-provision/versions.tf +++ b/examples/simple-provision/versions.tf @@ -2,7 +2,7 @@ terraform { required_providers { delphix = { source = "delphix-integrations/delphix" - version = "3.0.0" + version = "3.1.0" } } } From b4e193dd782875761da73d7765a16a0a6fa5fafa Mon Sep 17 00:00:00 2001 From: "ankit.patil" Date: Wed, 15 Nov 2023 21:12:41 +0530 Subject: [PATCH 11/11] updated fix for dependabot alerts --- go.mod | 16 ++++++++-------- go.sum | 35 ++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/go.mod b/go.mod index e9ce4ce..28b2e86 100644 --- a/go.mod +++ b/go.mod @@ -45,17 +45,17 @@ require ( github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect github.com/vmihailenco/tagparser v0.1.1 // indirect github.com/zclconf/go-cty v1.10.0 // indirect - golang.org/x/crypto v0.1.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect - google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect - google.golang.org/grpc v1.53.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/grpc v1.56.3 // indirect ) require ( - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/terraform-plugin-sdk/v2 v2.12.0 - golang.org/x/net v0.7.0 // indirect + golang.org/x/net v0.17.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.30.0 // indirect ) diff --git a/go.sum b/go.sum index b31466d..73eb2e2 100644 --- a/go.sum +++ b/go.sum @@ -143,8 +143,9 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -385,8 +386,8 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -451,8 +452,8 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -505,19 +506,19 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -626,8 +627,8 @@ google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -646,8 +647,8 @@ google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= +google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -661,8 +662,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=