Skip to content

Commit dc71c6f

Browse files
committed
omitting empty set in nsg request unless specified
1 parent c5cf3ed commit dc71c6f

5 files changed

+341
-27
lines changed

oci/database_data_guard_association_resource.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,11 @@ func (s *DatabaseDataGuardAssociationResourceCrud) SetData() error {
384384
s.D.Set("apply_rate", *s.Res.ApplyRate)
385385
}
386386

387+
//@Codegen: Unless explicitly specified by the user, network_security_group_ids will not be set in state as the feature may or may not be supported
387388
if backupNetworkNsgIds, ok := s.D.GetOkExists("backup_network_nsg_ids"); ok {
388389
s.D.Set("backup_network_nsg_ids", backupNetworkNsgIds)
389390
} else {
390-
s.D.Set("backup_network_nsg_ids", []string{})
391+
s.D.Set("backup_network_nsg_ids", nil)
391392
}
392393

393394
if s.Res.DatabaseId != nil {
@@ -397,11 +398,11 @@ func (s *DatabaseDataGuardAssociationResourceCrud) SetData() error {
397398
if s.Res.LifecycleDetails != nil {
398399
s.D.Set("lifecycle_details", *s.Res.LifecycleDetails)
399400
}
400-
401+
//@Codegen: Unless explicitly specified by the user, network_security_group_ids will not be set in state as the feature may or may not be supported
401402
if nsgIds, ok := s.D.GetOkExists("nsg_ids"); ok {
402403
s.D.Set("nsg_ids", nsgIds)
403404
} else {
404-
s.D.Set("nsg_ids", []string{})
405+
s.D.Set("nsg_ids", nil)
405406
}
406407

407408
if s.Res.PeerDataGuardAssociationId != nil {
@@ -474,7 +475,7 @@ func (s *DatabaseDataGuardAssociationResourceCrud) populateTopLevelPolymorphicCr
474475
tmp := availabilityDomain.(string)
475476
details.AvailabilityDomain = &tmp
476477
}
477-
details.BackupNetworkNsgIds = []string{}
478+
//@Codegen: Unless explicitly specified by the user, network_security_group_ids will not be supplied as the feature may or may not be supported
478479
if backupNetworkNsgIds, ok := s.D.GetOkExists("backup_network_nsg_ids"); ok {
479480
set := backupNetworkNsgIds.(*schema.Set)
480481
interfaces := set.List()
@@ -494,7 +495,7 @@ func (s *DatabaseDataGuardAssociationResourceCrud) populateTopLevelPolymorphicCr
494495
tmp := hostname.(string)
495496
details.Hostname = &tmp
496497
}
497-
details.NsgIds = []string{}
498+
//@Codegen: Unless explicitly specified by the user, network_security_group_ids will not be supplied as the feature may or may not be supported
498499
if nsgIds, ok := s.D.GetOkExists("nsg_ids"); ok {
499500
set := nsgIds.(*schema.Set)
500501
interfaces := set.List()

oci/database_db_system_resource.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ func (s *DatabaseDbSystemResourceCrud) Update() error {
741741
}
742742
request := oci_database.UpdateDbSystemRequest{}
743743

744-
request.BackupNetworkNsgIds = []string{}
744+
//@Codegen: Unless explicitly specified by the user, network_security_group_ids will not be supplied as the feature may or may not be supported
745745
if backupNetworkNsgIds, ok := s.D.GetOkExists("backup_network_nsg_ids"); ok {
746746
set := backupNetworkNsgIds.(*schema.Set)
747747
interfaces := set.List()
@@ -779,7 +779,7 @@ func (s *DatabaseDbSystemResourceCrud) Update() error {
779779
request.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))
780780
}
781781

782-
request.NsgIds = []string{}
782+
//@Codegen: Unless explicitly specified by the user, network_security_group_ids will not be supplied as the feature may or may not be supported
783783
if nsgIds, ok := s.D.GetOkExists("nsg_ids"); ok {
784784
set := nsgIds.(*schema.Set)
785785
interfaces := set.List()
@@ -915,11 +915,14 @@ func (s *DatabaseDbSystemResourceCrud) SetData() error {
915915
s.D.Set("availability_domain", *s.Res.AvailabilityDomain)
916916
}
917917

918-
backupNetworkNsgIds := []interface{}{}
919-
for _, item := range s.Res.BackupNetworkNsgIds {
920-
backupNetworkNsgIds = append(backupNetworkNsgIds, item)
918+
//@Codegen: Unless explicitly specified by the user, network_security_group_ids will not be set in state as the feature may or may not be supported
919+
if s.Res.BackupNetworkNsgIds != nil {
920+
backupNetworkNsgIds := []interface{}{}
921+
for _, item := range s.Res.BackupNetworkNsgIds {
922+
backupNetworkNsgIds = append(backupNetworkNsgIds, item)
923+
}
924+
s.D.Set("backup_network_nsg_ids", schema.NewSet(literalTypeHashCodeForSets, backupNetworkNsgIds))
921925
}
922-
s.D.Set("backup_network_nsg_ids", schema.NewSet(literalTypeHashCodeForSets, backupNetworkNsgIds))
923926

924927
if s.Res.BackupSubnetId != nil {
925928
s.D.Set("backup_subnet_id", *s.Res.BackupSubnetId)
@@ -987,11 +990,14 @@ func (s *DatabaseDbSystemResourceCrud) SetData() error {
987990
s.D.Set("node_count", *s.Res.NodeCount)
988991
}
989992

990-
nsgIds := []interface{}{}
991-
for _, item := range s.Res.NsgIds {
992-
nsgIds = append(nsgIds, item)
993+
//@Codegen: Unless explicitly specified by the user, network_security_group_ids will not be set in state as the feature may or may not be supported
994+
if s.Res.NsgIds != nil {
995+
nsgIds := []interface{}{}
996+
for _, item := range s.Res.NsgIds {
997+
nsgIds = append(nsgIds, item)
998+
}
999+
s.D.Set("nsg_ids", schema.NewSet(literalTypeHashCodeForSets, nsgIds))
9931000
}
994-
s.D.Set("nsg_ids", schema.NewSet(literalTypeHashCodeForSets, nsgIds))
9951001

9961002
if s.Res.RecoStorageSizeInGB != nil {
9971003
s.D.Set("reco_storage_size_in_gb", *s.Res.RecoStorageSizeInGB)
@@ -1512,7 +1518,8 @@ func (s *DatabaseDbSystemResourceCrud) populateTopLevelPolymorphicLaunchDbSystem
15121518
tmp := availabilityDomain.(string)
15131519
details.AvailabilityDomain = &tmp
15141520
}
1515-
details.BackupNetworkNsgIds = []string{}
1521+
1522+
// @Codegen: BackUpNsgIds is applicable only for exadata systems. If not specified, we don't set this field in request
15161523
if backupNetworkNsgIds, ok := s.D.GetOkExists("backup_network_nsg_ids"); ok {
15171524
set := backupNetworkNsgIds.(*schema.Set)
15181525
interfaces := set.List()
@@ -1585,7 +1592,8 @@ func (s *DatabaseDbSystemResourceCrud) populateTopLevelPolymorphicLaunchDbSystem
15851592
tmp := nodeCount.(int)
15861593
details.NodeCount = &tmp
15871594
}
1588-
details.NsgIds = []string{}
1595+
1596+
// @Codegen: BackUpNsgIds is applicable only for exadata systems. If not specified, we don't set this field in request
15891597
if nsgIds, ok := s.D.GetOkExists("nsg_ids"); ok {
15901598
set := nsgIds.(*schema.Set)
15911599
interfaces := set.List()
@@ -1650,7 +1658,7 @@ func (s *DatabaseDbSystemResourceCrud) populateTopLevelPolymorphicLaunchDbSystem
16501658
tmp := availabilityDomain.(string)
16511659
details.AvailabilityDomain = &tmp
16521660
}
1653-
details.BackupNetworkNsgIds = []string{}
1661+
// @Codegen: BackUpNsgIds is applicable only for exadata systems. If not specified, we don't set this field in request
16541662
if backupNetworkNsgIds, ok := s.D.GetOkExists("backup_network_nsg_ids"); ok {
16551663
set := backupNetworkNsgIds.(*schema.Set)
16561664
interfaces := set.List()
@@ -1723,7 +1731,7 @@ func (s *DatabaseDbSystemResourceCrud) populateTopLevelPolymorphicLaunchDbSystem
17231731
tmp := nodeCount.(int)
17241732
details.NodeCount = &tmp
17251733
}
1726-
details.NsgIds = []string{}
1734+
// @Codegen: BackUpNsgIds is applicable only for exadata systems. If not specified, we don't set this field in request
17271735
if nsgIds, ok := s.D.GetOkExists("nsg_ids"); ok {
17281736
set := nsgIds.(*schema.Set)
17291737
interfaces := set.List()

0 commit comments

Comments
 (0)