Skip to content

Commit d493376

Browse files
Paulo CelisMaxrovr
authored andcommitted
Added - Support for DBM: Database Life Cycle Management (Externally Registered Database Patching)
1 parent 1830674 commit d493376

11 files changed

+1420
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tenancy_ocid" {}
5+
variable "user_ocid" {}
6+
variable "fingerprint" {}
7+
variable "private_key_path" {}
8+
variable "region" {}
9+
variable "compartment_ocid" {}
10+
11+
12+
provider "oci" {
13+
tenancy_ocid = var.tenancy_ocid
14+
user_ocid = var.user_ocid
15+
fingerprint = var.fingerprint
16+
private_key_path = var.private_key_path
17+
region = var.region
18+
}
19+
20+
variable "database_release" {
21+
default = "19.0.0.0.0"
22+
}
23+
24+
data "oci_dblm_patch_management" "test_patch_management"{
25+
#Required
26+
compartment_id = var.compartment_ocid
27+
database_release = "19.0.0.0.0"
28+
time_started_greater_than_or_equal_to = "2006-01-02T15:04:05Z"
29+
time_started_less_than = "2026-01-02T15:04:05Z"
30+
}
31+
32+
data "oci_dblm_patch_management_databases" "test_dblm_patch_management_databases"{
33+
#Optional
34+
compartment_id = var.compartment_ocid
35+
database_release = var.database_release
36+
database_type = "SI"
37+
}

examples/dblm/dblm_vulnerability.tf renamed to examples/dblm/vulnerability/dblm_vulnerability.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ variable "dblm_display_name" {
2020
default = "displayName"
2121
}
2222

23+
variable "vulnerability_scan_vulnerability_scan_type" {
24+
default = "CVE"
25+
}
26+
2327

2428

2529
provider "oci" {
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
11+
12+
oci_dblm "github.com/oracle/oci-go-sdk/v65/dblm"
13+
"github.com/oracle/terraform-provider-oci/httpreplay"
14+
"github.com/oracle/terraform-provider-oci/internal/acctest"
15+
16+
"github.com/oracle/terraform-provider-oci/internal/utils"
17+
)
18+
19+
var (
20+
DblmPatchManagementDatabaseDataSourceRepresentation = map[string]interface{}{
21+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
22+
"database_release": acctest.Representation{RepType: acctest.Optional, Create: `19.0.0.0.0`},
23+
"database_type": acctest.Representation{RepType: acctest.Optional, Create: `SI`},
24+
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displayName`},
25+
"drifter_patch_id": acctest.Representation{RepType: acctest.Optional, Create: `1`},
26+
"image_compliance": acctest.Representation{RepType: acctest.Optional, Create: `NOT_SUBSCRIBED`},
27+
"image_id": acctest.Representation{RepType: acctest.Optional, Create: `imageId`},
28+
"severity_type": acctest.Representation{RepType: acctest.Optional, Create: []oci_dblm.ResourcesSeveritiesEnum{`CRITICAL`}},
29+
"state": acctest.Representation{RepType: acctest.Optional, Create: `ACTIVE`},
30+
}
31+
32+
DblmPatchManagementDatabaseResourceConfig = ""
33+
)
34+
35+
// issue-routing-tag: dblm/default
36+
func TestDblmPatchManagementDatabaseResource_basic(t *testing.T) {
37+
httpreplay.SetScenario("TestDblmPatchManagementDatabaseResource_basic")
38+
defer httpreplay.SaveScenario()
39+
40+
config := acctest.ProviderTestConfig()
41+
42+
// compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
43+
compartmentId := utils.GetEnvSettingWithBlankDefault("tenancy_ocid")
44+
// tenantId := utils.GetEnvSettingWithBlankDefault("tenancy_ocid")
45+
patchTypePlatformConfigurationId := utils.GetEnvSettingWithBlankDefault("test_patch_type_platform_configuration_id")
46+
productPlatformConfigurationId := utils.GetEnvSettingWithBlankDefault("test_product_platform_configuration_id")
47+
48+
platformConfigurationsStr := fmt.Sprintf(
49+
"variable \"patch_type_platform_configuration_id\" { default = \"%s\" }\n"+
50+
"variable \"product_platform_configuration_id\" { default = \"%s\" }\n"+
51+
"variable \"compartment_id\" { default = \"%s\" }\n",
52+
patchTypePlatformConfigurationId, productPlatformConfigurationId, compartmentId)
53+
54+
datasourceName := "data.oci_dblm_patch_management_databases.test_dblm_patch_management_databases"
55+
56+
acctest.SaveConfigContent("", "", "", t)
57+
58+
acctest.ResourceTest(t, nil, []resource.TestStep{
59+
// verify datasource
60+
{
61+
Config: config +
62+
acctest.GenerateDataSourceFromRepresentationMap("oci_dblm_patch_management_databases", "test_dblm_patch_management_databases", acctest.Optional, acctest.Create, DblmPatchManagementDatabaseDataSourceRepresentation) +
63+
platformConfigurationsStr + DblmPatchManagementDatabaseResourceConfig,
64+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
65+
resource.TestCheckResourceAttr(datasourceName, "compartment_id", compartmentId),
66+
resource.TestCheckResourceAttr(datasourceName, "database_release", "19.0.0.0.0"),
67+
resource.TestCheckResourceAttr(datasourceName, "database_type", "SI"),
68+
resource.TestCheckResourceAttr(datasourceName, "state", "ACTIVE"),
69+
70+
resource.TestCheckResourceAttrSet(datasourceName, "patch_databases_collection.#"),
71+
),
72+
},
73+
})
74+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
package integrationtest
5+
6+
import (
7+
"fmt"
8+
"testing"
9+
10+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
11+
12+
"github.com/oracle/terraform-provider-oci/httpreplay"
13+
"github.com/oracle/terraform-provider-oci/internal/acctest"
14+
15+
"github.com/oracle/terraform-provider-oci/internal/utils"
16+
)
17+
18+
var (
19+
DblmPatchManagementSingularDataSourceRepresentation = map[string]interface{}{
20+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
21+
"database_release": acctest.Representation{RepType: acctest.Optional, Create: `19.0.0.0.0`},
22+
"time_started_greater_than_or_equal_to": acctest.Representation{RepType: acctest.Optional, Create: `2006-01-02T15:04:05Z`},
23+
"time_started_less_than": acctest.Representation{RepType: acctest.Optional, Create: `2026-01-02T15:04:05Z`},
24+
}
25+
26+
DblmPatchManagementResourceConfig = ""
27+
)
28+
29+
// issue-routing-tag: dblm/default
30+
func TestDblmPatchManagementResource_basic(t *testing.T) {
31+
httpreplay.SetScenario("TestDblmPatchManagementResource_basic")
32+
defer httpreplay.SaveScenario()
33+
34+
config := acctest.ProviderTestConfig()
35+
36+
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
37+
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
38+
39+
singularDatasourceName := "data.oci_dblm_patch_management.test_patch_management"
40+
41+
acctest.SaveConfigContent("", "", "", t)
42+
43+
acctest.ResourceTest(t, nil, []resource.TestStep{
44+
// verify singular datasource
45+
{
46+
Config: config +
47+
acctest.GenerateDataSourceFromRepresentationMap("oci_dblm_patch_management", "test_patch_management", acctest.Optional, acctest.Create, DblmPatchManagementSingularDataSourceRepresentation) +
48+
compartmentIdVariableStr + DblmPatchManagementResourceConfig,
49+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
50+
resource.TestCheckResourceAttrSet(singularDatasourceName, "compartment_id"),
51+
resource.TestCheckResourceAttr(singularDatasourceName, "database_release", "19.0.0.0.0"),
52+
resource.TestCheckResourceAttr(singularDatasourceName, "time_started_greater_than_or_equal_to", "2006-01-02T15:04:05Z"),
53+
resource.TestCheckResourceAttr(singularDatasourceName, "time_started_less_than", "2026-01-02T15:04:05Z"),
54+
resource.TestCheckResourceAttrSet(singularDatasourceName, "images_patch_recommendation_summary.#"),
55+
resource.TestCheckResourceAttrSet(singularDatasourceName, "patch_operations_summary.#"),
56+
resource.TestCheckResourceAttrSet(singularDatasourceName, "resources_patch_compliance_summary.#"),
57+
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
58+
),
59+
},
60+
})
61+
}

0 commit comments

Comments
 (0)