Skip to content

Commit 421fa14

Browse files
committed
updating database datasource to include tags
1 parent 69c3614 commit 421fa14

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

docs/database/databases.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ The following attributes are exported:
2525
* `db_name` - The database name.
2626
* `db_unique_name` - A system-generated name for the database to ensure uniqueness within an Oracle Data Guard group (a primary database and its standby databases). The unique name cannot be changed.
2727
* `db_workload` - Database workload type.
28+
* `defined_tags` - Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see [Resource Tags](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm). Example: `{"Operations.CostCenter": "42"}`
29+
* `freeform_tags` - Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see [Resource Tags](https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm). Example: `{"Department": "Finance"}`
2830
* `id` - The OCID of the database.
2931
* `lifecycle_details` - Additional information about the current lifecycleState.
3032
* `ncharacter_set` - The national character set for the database.
@@ -41,7 +43,6 @@ data "oci_database_database" "test_database" {
4143
}
4244
```
4345

44-
4546
# oci_database_databases
4647

4748
## Database DataSource

provider/database_database_data_source.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ func DatabaseDataSource() *schema.Resource {
3434
Type: schema.TypeString,
3535
Computed: true,
3636
},
37+
"defined_tags": {
38+
Type: schema.TypeMap,
39+
Computed: true,
40+
DiffSuppressFunc: definedTagsDiffSuppressFunction,
41+
Elem: schema.TypeString,
42+
},
3743
"db_backup_config": {
3844
Type: schema.TypeList,
3945
Computed: true,
@@ -69,6 +75,11 @@ func DatabaseDataSource() *schema.Resource {
6975
Type: schema.TypeString,
7076
Computed: true,
7177
},
78+
"freeform_tags": {
79+
Type: schema.TypeMap,
80+
Computed: true,
81+
Elem: schema.TypeString,
82+
},
7283
"id": {
7384
Type: schema.TypeString,
7485
Computed: true,
@@ -159,6 +170,12 @@ func (s *DatabaseDataSourceCrud) SetData() {
159170
s.D.Set("db_workload", *s.Res.DbWorkload)
160171
}
161172

173+
if s.Res.DefinedTags != nil {
174+
s.D.Set("defined_tags", definedTagsToMap(s.Res.DefinedTags))
175+
}
176+
177+
s.D.Set("freeform_tags", s.Res.FreeformTags)
178+
162179
if s.Res.Id != nil {
163180
s.D.Set("id", *s.Res.Id)
164181
}

provider/database_databases_data_source.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ func (s *DatabasesDataSourceCrud) SetData() {
138138
database["db_workload"] = *r.DbWorkload
139139
}
140140

141+
if r.DefinedTags != nil {
142+
database["defined_tags"] = definedTagsToMap(r.DefinedTags)
143+
}
144+
145+
database["freeform_tags"] = r.FreeformTags
146+
141147
if r.Id != nil {
142148
database["id"] = *r.Id
143149
}

0 commit comments

Comments
 (0)