Skip to content

Commit 8391956

Browse files
authored
Release 3.22.0
Release 3.22.0
2 parents 4438c45 + ba7a6e6 commit 8391956

25 files changed

+207
-80
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
## 3.21.1 (Unreleased)
1+
## 3.22.0 (Unreleased)
2+
3+
### Added
4+
- Support for `compartment_id` filter in `email_senders` and `email_suppressions` data sources
5+
- Support for import in dbHomes and dbSystems
6+
7+
### Fixed
8+
- Backward compatibility for compositeId in Object Storage - Objects and PARs
9+
210
## 3.21.0 (April 03, 2019)
311

412
### Added

examples/object_storage/object.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
22

33
/* This example demonstrates object store object management. It uses Terraforms built-in `file` function to upload a file.
4-
*
4+
*
55
* WARNING: This should only be used with small files. The file helper does stringification so large files
66
* may cause terraform to slow, become unresponsive or exceed allowed memory usage.
77
*/

oci/crud_helpers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ func FilterMissingResourceError(sync ResourceVoider, err *error) {
419419
}
420420
}
421421

422+
// In the Exadata case the service return the hostname provided by the service with a suffix
423+
func dbSystemHostnameDiffSuppress(key string, old string, new string, d *schema.ResourceData) bool {
424+
return EqualIgnoreCaseSuppressDiff(key, old, new, d) || strings.HasPrefix(strings.ToLower(old), strings.ToLower(new))
425+
}
426+
422427
func EqualIgnoreCaseSuppressDiff(key string, old string, new string, d *schema.ResourceData) bool {
423428
return strings.EqualFold(old, new)
424429
}

oci/database_db_home_resource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import (
1616

1717
func DatabaseDbHomeResource() *schema.Resource {
1818
return &schema.Resource{
19+
Importer: &schema.ResourceImporter{
20+
State: schema.ImportStatePassthrough,
21+
},
1922
Timeouts: &schema.ResourceTimeout{
2023
Create: &TwelveHours,
2124
Delete: &TwoHours,
@@ -463,6 +466,9 @@ func (s *DatabaseDbHomeResourceCrud) SetData() error {
463466
s.D.Set("database", []interface{}{s.DatabaseToMap(s.Database)})
464467
}
465468

469+
if source, ok := s.D.GetOkExists("source"); !ok || source.(string) == "" {
470+
s.D.Set("source", "NONE")
471+
}
466472
return nil
467473
}
468474

oci/database_db_home_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,23 @@ func TestDatabaseDbHomeResource_basic(t *testing.T) {
241241
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
242242
),
243243
},
244+
// remove singular datasource from previous step so that it doesn't conflict with import tests
245+
{
246+
Config: config +
247+
compartmentIdVariableStr + DbHomeResourceDependencies +
248+
generateResourceFromRepresentationMap("oci_database_db_home", "test_db_home_source_none", Optional, Update, dbHomeRepresentationSourceNone) +
249+
generateResourceFromRepresentationMap("oci_database_db_home", "test_db_home_source_db_backup", Optional, Update, dbHomeRepresentationSourceDbBackup),
250+
},
251+
// verify resource import
252+
{
253+
Config: config,
254+
ImportState: true,
255+
ImportStateVerify: true,
256+
ImportStateVerifyIgnore: []string{
257+
"database.0.admin_password",
258+
},
259+
ResourceName: resourceName + "_source_none",
260+
},
244261
},
245262
})
246263
}

oci/database_db_system_resource.go

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import (
1717

1818
func DatabaseDbSystemResource() *schema.Resource {
1919
return &schema.Resource{
20+
Importer: &schema.ResourceImporter{
21+
State: schema.ImportStatePassthrough,
22+
},
2023
Timeouts: &schema.ResourceTimeout{
2124
// ZeroTime is a marker so a user supplied default is not overwritten. See CreateDBSystemResource
2225
Create: &ZeroTime,
@@ -244,7 +247,7 @@ func DatabaseDbSystemResource() *schema.Resource {
244247
Type: schema.TypeString,
245248
Required: true,
246249
ForceNew: true,
247-
DiffSuppressFunc: EqualIgnoreCaseSuppressDiff,
250+
DiffSuppressFunc: dbSystemHostnameDiffSuppress,
248251
},
249252
"shape": {
250253
Type: schema.TypeString,
@@ -648,7 +651,7 @@ func (s *DatabaseDbSystemResourceCrud) getDbHomeInfo() error {
648651
return err
649652
}
650653
if getDbHomeResponse.DbHome.LifecycleState == oci_database.DbHomeLifecycleStateTerminated {
651-
return fmt.Errorf("the associated dbHome is in a TERMINATED state")
654+
return fmt.Errorf("the associated dbHome %s is in a TERMINATED state", *dbHomeId)
652655
}
653656

654657
var databaseId *string
@@ -844,8 +847,9 @@ func (s *DatabaseDbSystemResourceCrud) SetData() error {
844847

845848
s.D.Set("freeform_tags", s.Res.FreeformTags)
846849

847-
// @codegen: Do not set hostname. Refreshing hostname causes undesirable diffs because the service may add a suffix
848-
// as in the case of Exadatas. Possible implication when importing the resource.
850+
if s.Res.Hostname != nil {
851+
s.D.Set("hostname", *s.Res.Hostname)
852+
}
849853

850854
if s.Res.LastPatchHistoryEntryId != nil {
851855
s.D.Set("last_patch_history_entry_id", *s.Res.LastPatchHistoryEntryId)
@@ -915,6 +919,10 @@ func (s *DatabaseDbSystemResourceCrud) SetData() error {
915919
s.D.Set("db_home", []interface{}{s.DbHomeToMap(s.DbHome)})
916920
}
917921

922+
if source, ok := s.D.GetOkExists("source"); !ok || source.(string) == "" {
923+
s.D.Set("source", "NONE")
924+
}
925+
918926
return nil
919927
}
920928

@@ -949,13 +957,6 @@ func (s *DatabaseDbSystemResourceCrud) mapToUpdateDatabaseDetails(fieldKeyFormat
949957

950958
func (s *DatabaseDbSystemResourceCrud) DbHomeToMap(obj *oci_database.DbHome) map[string]interface{} {
951959
result := map[string]interface{}{}
952-
if obj.CompartmentId != nil {
953-
result["compartment_id"] = string(*obj.CompartmentId)
954-
}
955-
956-
if obj.DbSystemId != nil {
957-
result["db_system_id"] = string(*obj.DbSystemId)
958-
}
959960

960961
if obj.DbVersion != nil {
961962
result["db_version"] = string(*obj.DbVersion)
@@ -1116,6 +1117,18 @@ func (s *DatabaseDbSystemResourceCrud) mapToCreateDatabaseDetails(fieldKeyFormat
11161117
result.DbWorkload = oci_database.CreateDatabaseDetailsDbWorkloadEnum(dbWorkload.(string))
11171118
}
11181119

1120+
if definedTags, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "defined_tags")); ok {
1121+
tmp, err := mapToDefinedTags(definedTags.(map[string]interface{}))
1122+
if err != nil {
1123+
return result, fmt.Errorf("unable to convert defined_tags, encountered error: %v", err)
1124+
}
1125+
result.DefinedTags = tmp
1126+
}
1127+
1128+
if freeformTags, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "freeform_tags")); ok {
1129+
result.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))
1130+
}
1131+
11191132
if ncharacterSet, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "ncharacter_set")); ok {
11201133
tmp := ncharacterSet.(string)
11211134
result.NcharacterSet = &tmp

oci/database_db_system_resource_test.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ func (s *ResourceDatabaseDBSystemTestSuite) TestAccResourceDatabaseDBSystemFromB
251251
resource.TestCheckResourceAttr(s.ResourceName, "license_model", "LICENSE_INCLUDED"),
252252
resource.TestCheckResourceAttr(s.ResourceName, "node_count", "1"),
253253
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.db_version", "12.1.0.2"),
254-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.display_name", ""),
255254
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.admin_password", "BEstrO0ng_#11"),
256255
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.db_name", "dbback"),
257256
resource.TestCheckResourceAttr(s.ResourceName, "state", string(database.DatabaseLifecycleStateAvailable)),
@@ -319,13 +318,8 @@ func (s *ResourceDatabaseDBSystemTestSuite) TestAccResourceDatabaseDBSystem_basi
319318
resource.TestCheckResourceAttr(s.ResourceName, "node_count", "1"),
320319
//resource.TestCheckResourceAttr(s.ResourceName, "fault_domains.#", "1"),
321320
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.db_version", "12.1.0.2"),
322-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.display_name", ""),
323321
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.admin_password", "BEstrO0ng_#11"),
324322
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.db_name", "aTFdb"),
325-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.character_set", ""),
326-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.ncharacter_set", ""),
327-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.db_workload", ""),
328-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.pdb_name", ""),
329323
resource.TestCheckResourceAttr(s.ResourceName, "state", string(database.DatabaseLifecycleStateAvailable)),
330324
),
331325
},
@@ -619,8 +613,8 @@ func (s *ResourceDatabaseDBSystemTestSuite) TestAccResourceDatabaseDBSystem_allV
619613
"admin_password" = "BEstrO0ng_#11"
620614
"db_name" = "aTFdb"
621615
character_set = "AL32UTF8"
622-
defined_tags = "${map("example-tag-namespace-all.example-tag", "originalValue")}"
623-
freeform_tags = {"Department" = "Finance"}
616+
//defined_tags = "${map("example-tag-namespace-all.example-tag", "originalValue")}" // service does not set tags of db tags in create
617+
//freeform_tags = {"Department" = "Finance"} // service does not set tags of db tags in create
624618
ncharacter_set = "AL16UTF16"
625619
db_workload = "OLTP"
626620
pdb_name = "pdbName"
@@ -700,8 +694,6 @@ func (s *ResourceDatabaseDBSystemTestSuite) TestAccResourceDatabaseDBSystem_allV
700694
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.admin_password", "BEstrO0ng_#11"),
701695
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.db_name", "aTFdb"),
702696
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.character_set", "AL32UTF8"),
703-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.defined_tags.example-tag-namespace-all.example-tag", "originalValue"),
704-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.freeform_tags.Department", "Finance"),
705697
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.ncharacter_set", "AL16UTF16"),
706698
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.db_workload", "OLTP"),
707699
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.pdb_name", "pdbName"),
@@ -1090,13 +1082,8 @@ func (s *ResourceDatabaseDBSystemTestSuite) TestAccResourceDatabaseDBSystem_Exad
10901082
resource.TestCheckResourceAttr(s.ResourceName, "license_model", "LICENSE_INCLUDED"),
10911083
resource.TestCheckResourceAttr(s.ResourceName, "node_count", "1"),
10921084
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.db_version", "12.1.0.2"),
1093-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.display_name", ""),
10941085
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.admin_password", "BEstrO0ng_#11"),
10951086
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.db_name", "aTFdb"),
1096-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.character_set", ""),
1097-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.ncharacter_set", ""),
1098-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.db_workload", ""),
1099-
resource.TestCheckResourceAttr(s.ResourceName, "db_home.0.database.0.pdb_name", ""),
11001087
resource.TestCheckResourceAttr(s.ResourceName, "state", string(database.DatabaseLifecycleStateAvailable)),
11011088
resource.TestCheckResourceAttr(s.ResourceName, "time_zone", "US/Pacific"),
11021089
),

oci/email_sender_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func TestEmailSenderResource_basic(t *testing.T) {
133133
resource.TestCheckResourceAttr(datasourceName, "state", "ACTIVE"),
134134

135135
resource.TestCheckResourceAttr(datasourceName, "senders.#", "1"),
136+
resource.TestCheckResourceAttr(datasourceName, "senders.0.compartment_id", compartmentId),
136137
resource.TestCheckResourceAttr(datasourceName, "senders.0.defined_tags.%", "1"),
137138
resource.TestCheckResourceAttr(datasourceName, "senders.0.email_address", "[email protected]"),
138139
resource.TestCheckResourceAttr(datasourceName, "senders.0.freeform_tags.%", "1"),

oci/email_senders_data_source.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ func (s *EmailSendersDataSourceCrud) SetData() error {
102102
resources := []map[string]interface{}{}
103103

104104
for _, r := range s.Res.Items {
105-
sender := map[string]interface{}{}
105+
sender := map[string]interface{}{
106+
"compartment_id": *r.CompartmentId,
107+
}
106108

107109
if r.DefinedTags != nil {
108110
sender["defined_tags"] = definedTagsToMap(r.DefinedTags)

oci/email_suppression_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func TestEmailSuppressionResource_basic(t *testing.T) {
8383
resource.TestCheckResourceAttr(datasourceName, "time_created_less_than", "2038-01-01T00:00:00.000Z"),
8484

8585
resource.TestCheckResourceAttr(datasourceName, "suppressions.#", "1"),
86+
resource.TestCheckResourceAttr(datasourceName, "suppressions.0.compartment_id", tenancyId),
8687
// email address is converted to lower case by the service
8788
resource.TestCheckResourceAttr(datasourceName, "suppressions.0.email_address", "[email protected]"),
8889
resource.TestCheckResourceAttrSet(datasourceName, "suppressions.0.time_created"),

0 commit comments

Comments
 (0)