@@ -3,7 +3,6 @@ package provider
33import (
44 "context"
55 "net/http"
6- "strconv"
76 "strings"
87
98 "github.com/hashicorp/terraform-plugin-log/tflog"
@@ -547,7 +546,6 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta i
547546 d .Set ("engine_id" , envRes .GetEngineId ())
548547 d .Set ("is_cluster" , envRes .GetIsCluster ())
549548 d .Set ("enabled" , envRes .GetEnabled ())
550- tflog .Info (ctx , "is WindowsTarget" + strconv .FormatBool (envRes .GetIsWindowsTarget ()))
551549 d .Set ("is_windows_target" , envRes .GetIsWindowsTarget ())
552550 d .Set ("staging_environment" , envRes .GetStagingEnvironment ())
553551 d .Set ("cluster_home" , envRes .GetClusterHome ())
@@ -580,16 +578,15 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
580578 changedKeys := make ([]string , 0 , len (d .State ().Attributes ))
581579 var modifiedChangedKeys []string
582580 for k := range d .State ().Attributes {
583- if strings .Contains (k , "tags" ) { // this is because the changed keys are of the form tag.0.keydi
581+ if strings .Contains (k , "tags" ) { // this is because the changed keys are of the form tag.0.key
584582 k = "tags"
585583 }
586584 if d .HasChange (k ) {
587- tflog .Info (ctx , ">>>>>@@@<<<<<<" + k )
588585 changedKeys = append (changedKeys , k )
589586 }
590587 }
591588 for _ , ck := range changedKeys {
592- tflog . Info ( ctx , "!!!!!!!!!!!!!!!" + ck ) // for hosts it will be in the form hosts.0.nfs_addresses.#
589+ // for hosts it will be in the form hosts.0.nfs_addresses.#
593590 if strings .Contains (ck , "hosts.0.hostname" ) ||
594591 strings .Contains (ck , "hosts.0.ssh_port" ) ||
595592 strings .Contains (ck , "hosts.0.toolkit_path" ) ||
@@ -599,9 +596,7 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
599596 }
600597 modifiedChangedKeys = append (modifiedChangedKeys , ck )
601598 }
602- for _ , mck := range modifiedChangedKeys {
603- tflog .Info (ctx , "!!!!!!!!mck!!!!!!!" + mck )
604- }
599+
605600 client := meta .(* apiClient ).client
606601 environmentId := d .Get ("id" ).(string )
607602 var updateFailure , destructiveUpdate bool = false , false
@@ -612,40 +607,35 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
612607 var disableDsourceFailure bool = false
613608 // if changedKeys contains non updatable field set a flag
614609 for _ , key := range modifiedChangedKeys {
615- tflog .Info (ctx , "!!!!!!!!!!!!!!!" + key )
616610 if ! updatableEnvKeys [key ] {
617611 // we stop the update process here if non supported attribute is detected here
618612 updateFailure = true
619- tflog .Info (ctx , ">>>>>!!!<<<<<<" + key )
620613 nonUpdatableField = append (nonUpdatableField , key )
621614 }
622615 }
623616
624617 if updateFailure {
625- tflog .Info (ctx , "######updatefailure" )
626618 revertChanges (d , changedKeys )
627619 return diag .Errorf ("cannot update options %v. Please refer to provider documentation for updatable params." , nonUpdatableField )
628620 }
629621 // find if destructive update
630622 for _ , key := range changedKeys {
631623 if isDestructiveEnvUpdate [key ] {
632- tflog .Info (ctx , "###### isDestructiveUpdate" + key )
624+ tflog .Info (ctx , "isDestructiveUpdate: " + key )
633625 destructiveUpdate = true
634626 }
635627 }
636628
637629 if destructiveUpdate {
638630 // get dsources and vdbs
639631 vdbs , vdbDiags = filterVDBs (ctx , client , environmentId )
640- tflog .Info (ctx , "######vdbs" )
641632 if vdbDiags .HasError () {
642633 revertChanges (d , changedKeys )
643634 return vdbDiags
644635 }
645636
646637 // get sources to get dsources
647638 sources , sourceDiag := filterSources (ctx , client , environmentId )
648- tflog .Info (ctx , "######sources" )
649639 if sourceDiag .HasError () {
650640 revertChanges (d , changedKeys )
651641 return sourceDiag
@@ -658,7 +648,6 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
658648 // retrieve dsources from source list
659649
660650 if len (sourceIds ) > 0 {
661- tflog .Info (ctx , "######DSource" )
662651 dsourceItems , dsourceDiags = filterdSources (ctx , client , sourceIds )
663652 if dsourceDiags != nil {
664653 revertChanges (d , changedKeys )
@@ -668,7 +657,6 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
668657
669658 // disable vdb
670659 for _ , item := range vdbs {
671- tflog .Info (ctx , "######disableVDB" )
672660 if diags := disableVDB (ctx , client , item .GetId ()); diags != nil {
673661 tflog .Error (ctx , "failure in disabling vdbs" )
674662 //disableVdbFailure = true
@@ -679,7 +667,6 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
679667
680668 // disable dsources
681669 for _ , item := range dsourceItems {
682- tflog .Info (ctx , "######disabledSource" )
683670 if diags := disabledSource (ctx , client , item .GetId ()); diags != nil {
684671 tflog .Error (ctx , "failure in disabling Dsources" )
685672 disableDsourceFailure = true
@@ -688,7 +675,6 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
688675 if disableDsourceFailure {
689676 //enable back vdbs and return
690677 for _ , item := range vdbs {
691- tflog .Info (ctx , "######disableDsourceFailure" )
692678 if diags := enableVDB (ctx , client , item .GetId ()); diags != nil {
693679 revertChanges (d , changedKeys )
694680 return diags
@@ -758,7 +744,7 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
758744 }
759745 }
760746 // get the user ref
761- tflog .Info (ctx , "~~~~~~~~ Getting the userlist" )
747+ tflog .Info (ctx , "Getting the userlist" )
762748 resUserList , httpResUserList , errUserList := client .EnvironmentsAPI .ListEnvironmentUsers (ctx , environmentId ).Execute ()
763749 if diags := apiErrorResponseHelper (ctx , resUserList , httpResUserList , errUserList ); diags != nil {
764750 revertChanges (d , changedKeys )
@@ -769,7 +755,7 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
769755
770756 username , _ := d .GetChange ("username" )
771757 for _ , users := range resUserList .GetUsers () {
772- tflog .Info (ctx , "~~~~~~~~ Getting the users" + users .GetUsername ())
758+ tflog .Info (ctx , "Getting the users: " + users .GetUsername ())
773759 if strings .EqualFold (users .GetUsername (), username .(string )) {
774760 user_ref = users .GetUserRef ()
775761 break
@@ -782,10 +768,10 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
782768
783769 // this is to propagate the value to read call which is defined at the end.
784770 // we will use the user_ref to filter from the list of users in the env
785- tflog .Info (ctx , "~~~~~~~~ Setting the user_ref" + user_ref )
771+ tflog .Info (ctx , "Setting the user_ref: " + user_ref )
786772 d .Set ("user_ref" , user_ref )
787773
788- tflog .Info (ctx , "~~~~~~~~ Updating the user" + user_ref )
774+ tflog .Info (ctx , "Updating the user: " + user_ref )
789775 resEnvUser , httpResEnvUser , errEnvUser := client .EnvironmentsAPI .UpdateEnvironmentUser (ctx , environmentId , user_ref ).EnvironmentUserParams (* envUserUpdateParam ).Execute ()
790776 if diags := apiErrorResponseHelper (ctx , resEnvUser , httpResEnvUser , errEnvUser ); diags != nil {
791777 revertChanges (d , changedKeys )
@@ -809,12 +795,6 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
809795 if d .HasChanges (
810796 "hosts" ,
811797 "connector_port" ,
812- // "java_home",
813- // "hostname",
814- // "ssh_port",
815- // "toolkit_path",
816- // "nfs_addresses",
817- // "oracle_tde_keystores_root_path",
818798 ) {
819799 tflog .Info (ctx , "hosts" )
820800 // host update
@@ -842,7 +822,7 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
842822 for _ , host := range hostsList {
843823 if oldHostName == host .(map [string ]interface {})["hostname" ].(string ) {
844824 hostId = host .(map [string ]interface {})["id" ].(string )
845- tflog .Info (ctx , "<>>>>>><<<<<<<>>>>>> hostsId: " + hostId )
825+ tflog .Info (ctx , "hostsId: " + hostId )
846826 break
847827 } else {
848828 // if not found, proceed with enable and finally display the failure events
@@ -907,16 +887,16 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
907887 if d .HasChanges (
908888 "tags" ,
909889 ) { // tags update
910- tflog .Info (ctx , ">>>>>>>>>>>> tags" )
890+ tflog .Info (ctx , "tags" )
911891 if d .HasChange ("tags" ) {
912892 // delete old tag
913- tflog .Info (ctx , ">>>>>>>>>>>> delete tags" )
893+ tflog .Info (ctx , "delete tags" )
914894 oldTag , newTag := d .GetChange ("tags" )
915895 if len (toTagArray (oldTag )) != 0 {
916- tflog .Info (ctx , "&&&&&&&&&&&>>>>>>>>>>>> delete tags" + toTagArray (oldTag )[0 ].GetKey ()+ " " + toTagArray (oldTag )[0 ].GetValue ())
896+ tflog .Info (ctx , "delete tags: " + toTagArray (oldTag )[0 ].GetKey ()+ " " + toTagArray (oldTag )[0 ].GetValue ())
917897 deleteTag := * dctapi .NewDeleteTag ()
918898 tagDelResp , tagDelErr := client .EnvironmentsAPI .DeleteEnvironmentTags (ctx , environmentId ).DeleteTag (deleteTag ).Execute ()
919- tflog .Info (ctx , ">> DELETE TAG RESP: " + tagDelResp .Status )
899+ tflog .Info (ctx , "DELETE TAG RESP: " + tagDelResp .Status )
920900 if diags := apiErrorResponseHelper (ctx , nil , tagDelResp , tagDelErr ); diags != nil {
921901 revertChanges (d , changedKeys )
922902 updateFailure = true
@@ -925,7 +905,7 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
925905 }
926906 // create tag
927907 if len (toTagArray (newTag )) != 0 {
928- tflog .Info (ctx , ">>>>>>>>>>>> create tags" )
908+ tflog .Info (ctx , "create tags" )
929909 _ , httpResp , tagCrtErr := client .EnvironmentsAPI .CreateEnvironmentTags (ctx , environmentId ).TagsRequest (* dctapi .NewTagsRequest (toTagArray (newTag ))).Execute ()
930910 if diags := apiErrorResponseHelper (ctx , nil , httpResp , tagCrtErr ); diags != nil {
931911 revertChanges (d , changedKeys )
@@ -953,7 +933,6 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta
953933
954934 // return the error back
955935 if updateFailure {
956- tflog .Error (ctx , "??????ERPRORORRRRRRRR???" )
957936 return diag .Errorf ("[NOT OK] Update failed with error %s" , failureEvents )
958937 }
959938
0 commit comments