From 679ad7dbd7725a2bf6ac7d8439e719557930599a Mon Sep 17 00:00:00 2001 From: Rafael Ribeiro Date: Fri, 14 Jun 2024 14:30:14 +0100 Subject: [PATCH 1/2] feat: add masked flag to VDB provisioning --- GNUmakefile | 1 + internal/provider/resource_vdb.go | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index ba5690f..ad3686e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -13,6 +13,7 @@ build: release: GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 + GOOS=darwin GOARCH=arm64 go build -o ./bin/${BINARY}_${VERSION}_darwin_arm64 GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm diff --git a/internal/provider/resource_vdb.go b/internal/provider/resource_vdb.go index e09a6e8..6a5e65d 100644 --- a/internal/provider/resource_vdb.go +++ b/internal/provider/resource_vdb.go @@ -3,11 +3,11 @@ package provider import ( "context" "encoding/json" - "github.com/hashicorp/terraform-plugin-log/tflog" "net/http" "time" dctapi "github.com/delphix/dct-sdk-go/v14" + "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -519,6 +519,10 @@ func resourceVdb() *schema.Resource { Type: schema.TypeBool, Optional: true, }, + "masked": { + Type: schema.TypeBool, + Optional: true, + }, "listener_ids": { Type: schema.TypeList, Optional: true, @@ -861,6 +865,9 @@ func helper_provision_by_snapshot(ctx context.Context, d *schema.ResourceData, m if v, has_v := d.GetOkExists("new_dbid"); has_v { provisionVDBBySnapshotParameters.SetNewDbid(v.(bool)) } + if v, has_v := d.GetOkExists("masked"); has_v { + provisionVDBBySnapshotParameters.SetMasked(v.(bool)) + } if v, has_v := d.GetOkExists("listener_ids"); has_v { provisionVDBBySnapshotParameters.SetListenerIds(toStringArray(v)) } @@ -1099,6 +1106,9 @@ func helper_provision_by_timestamp(ctx context.Context, d *schema.ResourceData, if v, has_v := d.GetOkExists("new_dbid"); has_v { provisionVDBByTimestampParameters.SetNewDbid(v.(bool)) } + if v, has_v := d.GetOkExists("masked"); has_v { + provisionVDBByTimestampParameters.SetMasked(v.(bool)) + } if v, has_v := d.GetOk("listener_ids"); has_v { provisionVDBByTimestampParameters.SetListenerIds(toStringArray(v)) } @@ -1340,6 +1350,9 @@ func helper_provision_by_bookmark(ctx context.Context, d *schema.ResourceData, m if v, has_v := d.GetOkExists("new_dbid"); has_v { provisionVDBFromBookmarkParameters.SetNewDbid(v.(bool)) } + if v, has_v := d.GetOkExists("masked"); has_v { + provisionVDBFromBookmarkParameters.SetMasked(v.(bool)) + } if v, has_v := d.GetOk("listener_ids"); has_v { provisionVDBFromBookmarkParameters.SetListenerIds(toStringArray(v)) } @@ -1549,7 +1562,6 @@ func resourceVdbRead(ctx context.Context, d *schema.ResourceData, meta interface config_params, _ := json.Marshal(result.GetConfigParams()) d.Set("config_params", string(config_params)) d.Set("additional_mount_points", flattenAdditionalMountPoints(result.GetAdditionalMountPoints())) - d.Set("id", vdbId) return diags From 390c830fbb0277fb3a63c7ea31a0e2fb37965722 Mon Sep 17 00:00:00 2001 From: Rafael Ribeiro Date: Fri, 14 Jun 2024 16:44:03 +0100 Subject: [PATCH 2/2] docs: add documentation for the masked flag on the vdb --- docs/resources/vdb.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/resources/vdb.md b/docs/resources/vdb.md index b6c7c60..2291469 100644 --- a/docs/resources/vdb.md +++ b/docs/resources/vdb.md @@ -202,6 +202,9 @@ resource "delphix_vdb" "vdb_name" { * `new_dbid` - (Optional) [Updatable] Option to generate a new DB ID for the created VDB (Oracle Only). +* `masked` - (Optional) Option to create a Masked VDB. Note: You should define a `configure_clone` script in the Hooks step to mask the dataset. The selection of the "Mask this VDB" option will cause the data to be marked as masked, whether you have defined a script to do so or not. +If you do not define a script to mask the dataset, the data will not be masked unless there is a masking job associated with the source dataset. + * `listener_ids` - (Optional) [Updatable] The listener IDs for this provision operation (Oracle Only). This is a list of listener ids. For eg: [ "listener-123", "listener-456" ] * `custom_env_vars` - (Optional)